From dc6e154f9d80bd48ff2648e650d3ec0636151943 Mon Sep 17 00:00:00 2001 From: Tim Arterbury Date: Sun, 18 Feb 2018 23:36:28 -0600 Subject: [PATCH 1/2] Allows install paths to have spaces and sets up git submodules automatically. --- scripts/macos/build-macos | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/scripts/macos/build-macos b/scripts/macos/build-macos index 88794996..2776714f 100644 --- a/scripts/macos/build-macos +++ b/scripts/macos/build-macos @@ -5,19 +5,26 @@ # # Determine PSMoveAPI root dir -export PSMOVEAPI_CHECKOUT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../../" +export PSMOVEAPI_CHECKOUT=$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../../ && pwd ) # Expands the relative path of ../../ so the following 3 exports are rendered correctly -export OPENCV_CHECKOUT_DIR=$PSMOVEAPI_CHECKOUT/external/opencv -export OPENCV_BUILD_DIR=$PSMOVEAPI_CHECKOUT/external/opencv/build -export OPENCV_INSTALL_DIR=$OPENCV_CHECKOUT_DIR/build/install +export OPENCV_CHECKOUT_DIR="$PSMOVEAPI_CHECKOUT/external/opencv" # Uses quotation marks to support spaces in the path +export OPENCV_BUILD_DIR="$PSMOVEAPI_CHECKOUT/external/opencv/build" # Uses quotation marks to support spaces in the path +export OPENCV_INSTALL_DIR="$OPENCV_CHECKOUT_DIR/build/install" # Uses quotation marks to support spaces in the path # For parallel builds MAKE_ARGS=-j4 +# Enter PS Move API directory to call the following git command in psmoveapi repository +cd "$PSMOVEAPI_CHECKOUT" # Uses quotation marks to support spaces in the PSMOVEAPI_CHECKOUT path + # Git revision identifier PSMOVEAPI_REVISION=$(git describe --tags) -if [ ! -f $PSMOVEAPI_CHECKOUT/CMakeLists.txt ]; then +# Initialize Submodules (if they were not initialized already) +git submodule init +git submodule update + +if [ ! -f "$PSMOVEAPI_CHECKOUT/CMakeLists.txt" ]; then # Adds quotation marks to support spaces in path echo "ERROR: You have to run this script in the PS Move API source root." exit 1 fi @@ -26,7 +33,7 @@ fi # needed for the PS3EYEDriver to access the PSEye # otherwise we'd dynamically link against some the Homebrew libusb ( - cd $PSMOVEAPI_CHECKOUT/external/libusb-1.0 + cd "$PSMOVEAPI_CHECKOUT/external/libusb-1.0" # Adds quotation marks to support spaces in path export ARCHFLAGS='-arch x86_64' export CFLAGS="$CFLAGS $ARCHFLAGS" export CXXFLAGS="$CXXFLAGS $ARCHFLAGS" @@ -35,10 +42,10 @@ fi make ${MAKE_ARGS} ) -cd $PSMOVEAPI_CHECKOUT +cd "$PSMOVEAPI_CHECKOUT" # Adds quotation marks to support spaces in path # Build OpenCV -if [ ! -d $OPENCV_INSTALL_DIR ]; then +if [ ! -d "$OPENCV_INSTALL_DIR" ]; then # Adds quotation marks to support spaces in path cd external if [ ! -d opencv ]; then git clone --depth 1 --branch 2.4 git://github.com/opencv/opencv.git @@ -85,7 +92,7 @@ if [ ! -d $OPENCV_INSTALL_DIR ]; then make install fi -cd $PSMOVEAPI_CHECKOUT +cd "$PSMOVEAPI_CHECKOUT" # Adds quotation marks to support spaces in path # Build PS Move API rm -rf build @@ -95,5 +102,5 @@ cmake -DPSMOVE_USE_PS3EYE_DRIVER=ON \ -DPSMOVE_BUILD_TRACKER=ON \ -DPSMOVE_BUILD_JAVA_BINDINGS=ON \ -DPSMOVE_BUILD_PROCESSING_BINDINGS=ON \ - -DOpenCV_DIR=${OPENCV_BUILD_DIR} .. + -DOpenCV_DIR="${OPENCV_BUILD_DIR}" .. # Uses quotation marks to support spaces in the path make ${MAKE_ARGS} From 50f419eda782c72815fcd1d74e3fc94080e3ea77 Mon Sep 17 00:00:00 2001 From: Tim Arterbury Date: Mon, 19 Feb 2018 14:29:09 -0600 Subject: [PATCH 2/2] Removes unnecessary comments I added and adds corrections from shellcheck --- scripts/macos/build-macos | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/scripts/macos/build-macos b/scripts/macos/build-macos index 2776714f..07387f53 100644 --- a/scripts/macos/build-macos +++ b/scripts/macos/build-macos @@ -1,30 +1,32 @@ -#!/bin/bash -x -e +#!/bin/bash -xe # # Script to build Mac OS X binary snapshots of PS Move API # Thomas Perl ; 2012-09-28 # # Determine PSMoveAPI root dir -export PSMOVEAPI_CHECKOUT=$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../../ && pwd ) # Expands the relative path of ../../ so the following 3 exports are rendered correctly +PSMOVEAPI_CHECKOUT=$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../../ && pwd ) +export PSMOVEAPI_CHECKOUT -export OPENCV_CHECKOUT_DIR="$PSMOVEAPI_CHECKOUT/external/opencv" # Uses quotation marks to support spaces in the path -export OPENCV_BUILD_DIR="$PSMOVEAPI_CHECKOUT/external/opencv/build" # Uses quotation marks to support spaces in the path -export OPENCV_INSTALL_DIR="$OPENCV_CHECKOUT_DIR/build/install" # Uses quotation marks to support spaces in the path +export OPENCV_CHECKOUT_DIR="$PSMOVEAPI_CHECKOUT/external/opencv" +export OPENCV_BUILD_DIR="$PSMOVEAPI_CHECKOUT/external/opencv/build" +export OPENCV_INSTALL_DIR="$OPENCV_CHECKOUT_DIR/build/install" # For parallel builds MAKE_ARGS=-j4 -# Enter PS Move API directory to call the following git command in psmoveapi repository -cd "$PSMOVEAPI_CHECKOUT" # Uses quotation marks to support spaces in the PSMOVEAPI_CHECKOUT path +# Enter PS Move API directory to call the following git commands in psmoveapi repository +cd "$PSMOVEAPI_CHECKOUT" # Git revision identifier PSMOVEAPI_REVISION=$(git describe --tags) +export PSMOVEAPI_REVISION -# Initialize Submodules (if they were not initialized already) +# Initialize Submodules of PS Move API git submodule init git submodule update -if [ ! -f "$PSMOVEAPI_CHECKOUT/CMakeLists.txt" ]; then # Adds quotation marks to support spaces in path +if [ ! -f "$PSMOVEAPI_CHECKOUT/CMakeLists.txt" ]; then echo "ERROR: You have to run this script in the PS Move API source root." exit 1 fi @@ -33,7 +35,7 @@ fi # needed for the PS3EYEDriver to access the PSEye # otherwise we'd dynamically link against some the Homebrew libusb ( - cd "$PSMOVEAPI_CHECKOUT/external/libusb-1.0" # Adds quotation marks to support spaces in path + cd "$PSMOVEAPI_CHECKOUT/external/libusb-1.0" export ARCHFLAGS='-arch x86_64' export CFLAGS="$CFLAGS $ARCHFLAGS" export CXXFLAGS="$CXXFLAGS $ARCHFLAGS" @@ -42,10 +44,8 @@ fi make ${MAKE_ARGS} ) -cd "$PSMOVEAPI_CHECKOUT" # Adds quotation marks to support spaces in path - # Build OpenCV -if [ ! -d "$OPENCV_INSTALL_DIR" ]; then # Adds quotation marks to support spaces in path +if [ ! -d "$OPENCV_INSTALL_DIR" ]; then cd external if [ ! -d opencv ]; then git clone --depth 1 --branch 2.4 git://github.com/opencv/opencv.git @@ -87,12 +87,13 @@ if [ ! -d "$OPENCV_INSTALL_DIR" ]; then # Adds quotation marks to support spaces -DWITH_GSTREAMER=OFF \ -DWITH_GPHOTO2=OFF \ -DCMAKE_OSX_ARCHITECTURES="x86_64" \ - -DCMAKE_INSTALL_PREFIX=$(pwd)/install .. + -DCMAKE_INSTALL_PREFIX="$(pwd)/install" .. make ${MAKE_ARGS} make install fi -cd "$PSMOVEAPI_CHECKOUT" # Adds quotation marks to support spaces in path +# Enter PS Move API directory to build +cd "$PSMOVEAPI_CHECKOUT" # Build PS Move API rm -rf build @@ -102,5 +103,5 @@ cmake -DPSMOVE_USE_PS3EYE_DRIVER=ON \ -DPSMOVE_BUILD_TRACKER=ON \ -DPSMOVE_BUILD_JAVA_BINDINGS=ON \ -DPSMOVE_BUILD_PROCESSING_BINDINGS=ON \ - -DOpenCV_DIR="${OPENCV_BUILD_DIR}" .. # Uses quotation marks to support spaces in the path + -DOpenCV_DIR="${OPENCV_BUILD_DIR}" .. make ${MAKE_ARGS}