Skip to content

Commit 756dba7

Browse files
author
Guido Marucci Blas
committed
Updates build scripts.
1 parent d01164e commit 756dba7

File tree

8 files changed

+145
-13
lines changed

8 files changed

+145
-13
lines changed

script/bootstrap

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ install_homebrew ()
1212
if type brew > /dev/null
1313
then
1414
echo " ✔ brew is already installed"
15-
echo ""
16-
echo " → Updating homebrew formulas"
17-
brew update > /dev/null || brew update > /dev/null
18-
echo " ✔ formulas updated"
15+
16+
if [ -z "$SKIP_BREW_FORMULAS_UPDATE" ]
17+
then
18+
echo ""
19+
echo " → Updating homebrew formulas"
20+
brew update > /dev/null || brew update > /dev/null
21+
echo " ✔ formulas updated"
22+
fi
1923
else
2024
command -v ruby >/dev/null 2>&1 || { echo >&2 "Error: Some ruby of version is required to install homebrew. Aborting"; exit 1; }
2125
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@@ -87,6 +91,7 @@ bundle_install ()
8791
"or try to install the gems globally by running the following command:"
8892
print_gem_install_cmd
8993
printf "\033[0m"
94+
exit 1
9095
fi
9196
}
9297

@@ -111,7 +116,7 @@ bootstrap_carthage ()
111116
echo ""
112117
echo " → Bootstrapping Carthage"
113118
echo ""
114-
carthage_cmd="time carthage bootstrap --platform ios"
119+
carthage_cmd="time carthage bootstrap --platform $CARTHAGE_BUILD_PLATFORM"
115120

116121
if [ "$USE_SSH" == "true" ]
117122
then
@@ -121,6 +126,12 @@ bootstrap_carthage ()
121126
then
122127
carthage_cmd="$carthage_cmd --use-submodules --no-build"
123128
fi
129+
130+
if [ "$CARTHAGE_NO_USE_BINARIES" == "true" ]
131+
then
132+
carthage_cmd="$carthage_cmd --no-use-binaries"
133+
fi
134+
124135
eval $carthage_cmd
125136
}
126137

@@ -165,6 +176,21 @@ install_dependencies ()
165176
fi
166177
}
167178

179+
install_carthage ()
180+
{
181+
source script/common/carthage
182+
183+
if type carthage > /dev/null
184+
then
185+
echo ""
186+
echo " → Checking installed version of carthage"
187+
echo ""
188+
check_carthage_version
189+
else
190+
force_install_carthage
191+
fi
192+
}
193+
168194
main ()
169195
{
170196
source script/.env
@@ -178,7 +204,7 @@ main ()
178204

179205
if [ -f Cartfile ]
180206
then
181-
brew_install "carthage"
207+
install_carthage
182208
bootstrap_carthage
183209
fi
184210

script/build

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
set -e
44

5+
source script/common/carthage
6+
57
build_using_carthage ()
68
{
7-
carthage_cmd="carthage build --no-skip-current --platform ios"
9+
check_carthage_version
10+
carthage_cmd="carthage build --no-skip-current --platform $CARTHAGE_BUILD_PLATFORM"
811
if [ "$USE_SSH" == "true" ]
912
then
1013
carthage_cmd="$carthage_cmd --use-ssh"

script/cibuild

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ KEYCHAIN=ios-build.keychain
1515

1616
main ()
1717
{
18-
if [ -f Cartfile ]
18+
if [ -f Cartfile ] && [ -f "$SCRIPT_DIR/certificates/cibot.p12" ]
1919
then
2020
echo ""
2121
echo "####### Importing Developer Certificates #######"
@@ -26,7 +26,7 @@ main ()
2626
echo ""
2727
echo "####### Bootstrap Phase #######"
2828
echo ""
29-
script/bootstrap
29+
NO_CARTHAGE_UPDATE=true script/bootstrap
3030
local status=$?
3131

3232
if [ $status -eq 0 ]
@@ -50,7 +50,10 @@ main ()
5050
fi
5151
fi
5252

53-
delete_keychain
53+
if [ -f Cartfile ] && [ -f "$SCRIPT_DIR/certificates/cibot.p12" ]
54+
then
55+
delete_keychain
56+
fi
5457
exit $status
5558
}
5659

script/common/carthage

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
force_install_carthage ()
2+
{
3+
echo ""
4+
echo " → Installing carthage '$REQUIRED_CARTHAGE_VERSION'"
5+
echo ""
6+
curl -s -L -O https://github.com/Carthage/Carthage/releases/download/$REQUIRED_CARTHAGE_VERSION/Carthage.pkg > /dev/null
7+
sudo installer -pkg Carthage.pkg -target / > /dev/null
8+
rm Carthage.pkg
9+
echo " ✔ carthage '$REQUIRED_CARTHAGE_VERSION' successfully installed"
10+
echo ""
11+
}
12+
13+
uninstall_carthage ()
14+
{
15+
echo ""
16+
echo " → Uninstalling carthage"
17+
echo ""
18+
local carthage_installed_version=`carthage version`
19+
if type brew > /dev/null && [ ! -z "$(brew list --versions carthage)" ]
20+
then
21+
brew uninstall carthage > /dev/null
22+
else
23+
sudo rm -frd /Library/Frameworks/CarthageKit.framework
24+
sudo rm /usr/local/bin/carthage
25+
fi
26+
echo " ✔ carthage '$carthage_installed_version' successfully uninstalled"
27+
}
28+
29+
check_carthage_version ()
30+
{
31+
local carthage_installed_version=`carthage version`
32+
if [ "$carthage_installed_version" != "$REQUIRED_CARTHAGE_VERSION" ]
33+
then
34+
printf "\033[1;31mError: carthage version '$carthage_installed_version' is not equal to '$REQUIRED_CARTHAGE_VERSION'"
35+
printf "\033[0m"
36+
if [ ! -z "$NO_CARTHAGE_UPDATE" ]
37+
then
38+
exit 1
39+
else
40+
echo ""
41+
echo ""
42+
echo "Would you like to update carthage to version '$REQUIRED_CARTHAGE_VERSION'? [N/y]"
43+
read update_carthage
44+
if [ "$update_carthage" == "y" ]
45+
then
46+
uninstall_carthage
47+
force_install_carthage
48+
else
49+
exit 1
50+
fi
51+
fi
52+
fi
53+
}

script/script_hooks/destinations

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
IOS_DESTINATION="'platform=iOS Simulator,name=$IOS_DESTINATION_SIMULATOR_NAME,OS=$IOS_DESTINATION_VERSION'"
4+
5+
if [ -z "$OSX_DESTINATION_ARCH" ]
6+
then
7+
OSX_DESTINATION="'platform=OS X'"
8+
else
9+
OSX_DESTINATION="'platform=OS X,arch=$OSX_DESTINATION_ARCH'"
10+
fi
11+
12+
scheme_destination ()
13+
{
14+
shopt -s nocasematch
15+
16+
case "$1" in
17+
*iOS)
18+
destination=$IOS_DESTINATION
19+
;;
20+
*OSX)
21+
destination=$OSX_DESTINATION
22+
;;
23+
*)
24+
destination=$IOS_DESTINATION
25+
;;
26+
esac
27+
28+
echo $destination
29+
}

script/script_hooks/schemes

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
schemes ()
22
{
3-
xcodebuild -list | awk '{if(found) print} /Schemes/{found=1}' | awk '{$1=$1};1'
3+
if [ -z "$SCHEME" ]
4+
then
5+
xcodebuild -list | awk '{if(found) print} /Schemes/{found=1}' | awk '{$1=$1};1'
6+
else
7+
echo $SCHEME
8+
fi
49
}

script/test

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,23 @@ set -e
44

55
source script/.env
66
source script/script_hooks/schemes
7+
source script/script_hooks/destinations
8+
source script/common/carthage
79

810
run_tests ()
911
{
1012
test_command="set -o pipefail && xcodebuild -scheme $1"
13+
1114
if [ -z "$XCODE_WORKSPACE" ]
1215
then
1316
test_command="$test_command -project $XCODE_PROJECT"
1417
else
1518
test_command="$test_command -workspace $XCODE_WORKSPACE"
1619
fi
17-
test_command="$test_command -sdk iphonesimulator -destination \"platform=iOS Simulator,OS=latest,name=iPhone 6\" clean build test -configuration Debug"
20+
21+
destination=$(scheme_destination $1)
22+
test_command="$test_command -destination $destination clean build test -configuration Debug"
23+
1824
if [ ! -z "$CIRCLE_ARTIFACTS" ]
1925
then
2026
test_command="$test_command | tee $CIRCLE_ARTIFACTS/xcode_raw.log"
@@ -38,6 +44,11 @@ run_tests ()
3844
eval $test_command
3945
}
4046

47+
if [ -f Cartfile ]
48+
then
49+
check_carthage_version
50+
fi
51+
4152
current_schemes=$(schemes)
4253
if [ -z "$current_schemes" ]
4354
then

script/update

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
set -e
44

55
source script/.env
6+
source script/common/carthage
67

78
if [ -f Cartfile ] && type carthage > /dev/null
89
then
9-
carthage_cmd="carthage update --platform ios"
10+
check_carthage_version
11+
carthage_cmd="carthage update --platform $CARTHAGE_BUILD_PLATFORM"
1012
if [ "$USE_SSH" == "true" ]
1113
then
1214
carthage_cmd="$carthage_cmd --use-ssh"

0 commit comments

Comments
 (0)