From c72167162e92412a1073d88c7982b90385a7ce2c Mon Sep 17 00:00:00 2001 From: Will Anderson Date: Wed, 10 Jun 2015 16:20:15 -0700 Subject: [PATCH] Update build scripts to run more robustly using xctool --- scripts/build-and-test.sh | 45 +++++++++++++++++++++++++++++++++++++++ scripts/start-packager.sh | 6 ++++++ scripts/stop-packager.sh | 8 +++++++ start-packager.sh | 3 --- stop-packager.sh | 3 --- 5 files changed, 59 insertions(+), 6 deletions(-) create mode 100755 scripts/build-and-test.sh create mode 100755 scripts/start-packager.sh create mode 100755 scripts/stop-packager.sh delete mode 100755 start-packager.sh delete mode 100755 stop-packager.sh diff --git a/scripts/build-and-test.sh b/scripts/build-and-test.sh new file mode 100755 index 0000000..f0db861 --- /dev/null +++ b/scripts/build-and-test.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +set -e + +SCRIPTS_PATH=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) + +ROOT=$1 +XCODEPROJ=$2 +XCODESCHEME=$3 + +export REACT_PACKAGER_LOG="$ROOT/server.log" + +cd $ROOT + +function cleanup { + EXIT_CODE=$? + set +e + + sleep 3 + $SCRIPTS_PATH/stop-packager.sh + + if [ $EXIT_CODE -ne 0 ]; + then + WATCHMAN_LOGS=/usr/local/Cellar/watchman/3.1/var/run/watchman/$USER.log + #[ -f $WATCHMAN_LOGS ] && cat $WATCHMAN_LOGS + + #[ -f $REACT_PACKAGER_LOG ] && cat $REACT_PACKAGER_LOG + fi +} +trap cleanup EXIT + +#$SCRIPTS_PATH/stop-packager.sh +$SCRIPTS_PATH/start-packager.sh $ROOT + +xctool \ + -project $XCODEPROJ \ + -scheme $XCODESCHEME -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 5,OS=8.3' \ + build + +xctool \ + -project $XCODEPROJ \ + -scheme $XCODESCHEME -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 5,OS=8.3' \ + test + + diff --git a/scripts/start-packager.sh b/scripts/start-packager.sh new file mode 100755 index 0000000..669659b --- /dev/null +++ b/scripts/start-packager.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +$ROOT=$1 + +command=`node -e "console.log(require('./package').scripts.start)"` +$command & diff --git a/scripts/stop-packager.sh b/scripts/stop-packager.sh new file mode 100755 index 0000000..2dd845e --- /dev/null +++ b/scripts/stop-packager.sh @@ -0,0 +1,8 @@ +#!/bin/sh +result=`lsof -t -i4TCP:8081` + +if [ $result ] +then + kill -9 `lsof -t -i4TCP:8081` +fi + diff --git a/start-packager.sh b/start-packager.sh deleted file mode 100755 index 4d8804e..0000000 --- a/start-packager.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -npm start & diff --git a/stop-packager.sh b/stop-packager.sh deleted file mode 100755 index 7844456..0000000 --- a/stop-packager.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -kill -9 `lsof -t -i4TCP:8081`