Skip to content

Commit 0bc86cd

Browse files
committed
Updates build scripts.
1 parent b715f06 commit 0bc86cd

File tree

5 files changed

+62
-23
lines changed

5 files changed

+62
-23
lines changed

script/build

+11-6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ build_using_carthage ()
99
then
1010
carthage_cmd="$carthage_cmd --use-ssh"
1111
fi
12+
if [ ! -z "$VERBOSE" ]
13+
then
14+
echo $carthage_cmd
15+
fi
1216
eval $carthage_cmd
1317
}
1418

@@ -21,7 +25,7 @@ build_using_xcodebuild ()
2125
else
2226
build_command="$build_command -workspace $XCODE_WORKSPACE"
2327
fi
24-
build_command="$build_command build"
28+
build_command="$build_command -sdk iphonesimulator build -configuration Debug"
2529

2630
if type bundle > /dev/null && bundle show xcpretty > /dev/null
2731
then
@@ -31,20 +35,21 @@ build_using_xcodebuild ()
3135
echo ""
3236
echo " → Building scheme '$1'"
3337
echo ""
38+
if [ ! -z "$VERBOSE" ]
39+
then
40+
echo $build_command
41+
fi
3442
eval $build_command
3543
}
3644

37-
schemes ()
38-
{
39-
xcodebuild -list | awk '{if(found) print} /Schemes/{found=1}' | awk '{$1=$1};1'
40-
}
41-
4245
if [ ! -f $XCODE_WORKSPACE ] && [ -f Cartfile ] && type carthage > /dev/null
4346
then
4447
build_using_carthage
4548
else
4649
source script/.env
50+
source script/script_hooks/schemes
4751

52+
current_schemes=$(schemes)
4853
if [ -z "$current_schemes" ]
4954
then
5055
echo ""

script/cibuild

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ main ()
3535
echo ""
3636
echo "####### Build & Test Phase #######"
3737
echo ""
38-
script/test | tee /tmp/build.test-output.txt
38+
set -o pipefail && script/test 2>&1 | tee /tmp/build.test-output.txt
3939
status=$?
4040
if [ ! $status -eq 0 ]
4141
then
42-
log_file_path=`cat /tmp/build.test-output.txt | perl -l -ne '/(\/var\/folders.*\/com\.apple\.dt\.XCTest-status.*)\)/ && print $1'`
42+
log_file_path=`cat /tmp/build.test-output.txt | tail -n 100 | perl -l -ne '/(\/var\/folders.*\/com\.apple\.dt\.XCTest-status.*)\)/ && print $1'`
4343
if [ ! -z "$log_file_path" ]
4444
then
4545
echo ""

script/script_hooks/destinations

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
if [ -z "$DEFAULT_OSX_DESTINATION" ]; then
4+
DEFAULT_OSX_DESTINATION="'platform=OS X'"
5+
fi
6+
7+
if [ -z "$IOS_OS_VERSION" ]; then
8+
IOS_OS_VERSION="latest"
9+
fi
10+
11+
if [ -z "$IOS_SIMULATOR_NAME" ]; then
12+
IOS_SIMULATOR_NAME="iPhone 6"
13+
fi
14+
15+
if [ -z "$DEFAULT_IOS_DESTINATION" ]; then
16+
DEFAULT_IOS_DESTINATION="'platform=iOS Simulator,name=$IOS_SIMULATOR_NAME,OS=$IOS_OS_VERSION'"
17+
fi
18+
19+
scheme_destination ()
20+
{
21+
shopt -s nocasematch
22+
23+
case "$1" in
24+
*iOS)
25+
destination=$DEFAULT_IOS_DESTINATION
26+
;;
27+
*OSX)
28+
destination=$DEFAULT_OSX_DESTINATION
29+
;;
30+
*)
31+
destination=$DEFAULT_IOS_DESTINATION
32+
;;
33+
esac
34+
35+
echo $destination
36+
}

script/script_hooks/schemes

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
schemes ()
2+
{
3+
xcodebuild -list | awk '{if(found) print} /Schemes/{found=1}' | awk '{$1=$1};1'
4+
}

script/test

+9-15
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,23 @@
33
set -e
44

55
source script/.env
6-
7-
schemes ()
8-
{
9-
xcodebuild -list | awk '{if(found) print} /Schemes/{found=1}' | awk '{$1=$1};1'
10-
}
6+
source script/script_hooks/schemes
7+
source script/script_hooks/destinations
118

129
run_tests ()
1310
{
1411
test_command="set -o pipefail && xcodebuild -scheme $1"
12+
1513
if [ -z "$XCODE_WORKSPACE" ]
1614
then
1715
test_command="$test_command -project $XCODE_PROJECT"
1816
else
1917
test_command="$test_command -workspace $XCODE_WORKSPACE"
2018
fi
21-
test_command="$test_command test"
2219

23-
shopt -s nocasematch
20+
destination=$(scheme_destination $1)
21+
test_command="$test_command -destination $destination clean build test -configuration Debug"
2422

25-
case "$1" in
26-
27-
*iOS) test_command="$test_command -destination 'platform=iOS Simulator,name=iPhone 6'"
28-
;;
29-
*OSX) test_command="$test_command -destination 'platform=OS X'"
30-
;;
31-
32-
esac
3323
if [ ! -z "$CIRCLE_ARTIFACTS" ]
3424
then
3525
test_command="$test_command | tee $CIRCLE_ARTIFACTS/xcode_raw.log"
@@ -46,6 +36,10 @@ esac
4636
echo ""
4737
echo " → Running tests for scheme '$1'"
4838
echo ""
39+
if [ ! -z "$VERBOSE" ]
40+
then
41+
echo $test_command
42+
fi
4943
eval $test_command
5044
}
5145

0 commit comments

Comments
 (0)