-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.sh
executable file
·143 lines (119 loc) · 3.19 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
#
# Script for building the unified modules + plugin for Hyperloop
#
SCRIPT_PATH=$(cd "$(dirname "$0")"; pwd)
cd $SCRIPT_PATH
onexit () {
cd $SCRIPT_PATH
# Reset the generated version of the manifest to VERSION
git checkout HEAD -- android/manifest
git checkout HEAD -- android/build.properties
git checkout HEAD -- iphone/manifest
git checkout HEAD -- iphone/titanium.xcconfig
rm -rf $SCRIPT_PATH/iphone/*.bak
rm -rf $SCRIPT_PATH/android/*.bak
}
trap onexit 0 1 2 3 6 9 15
TISDK_SEMVER=">=9.2.0"
CHECK="✓ "
# Make sure the Android SDK is installed
if [ "$ANDROID_SDK" = "" ];
then
if [ -d ~/Library/Android/sdk ];
then
export ANDROID_SDK=~/Library/Android/sdk
else
echo "Please set ANDROID_SDK environment variable and try again"
echo "Download Android Studio from https://developer.android.com/studio"
exit 1
fi
echo "$CHECK Android SDK is $ANDROID_SDK"
fi
# Make sure we have at least the Android 7.1 (SDK 25) installed
if [ ! -d "$ANDROID_SDK/platforms/android-33" ];
then
echo "Android 13 (Tiramisu) / (android-33) not installed"
echo "Download the Android 13 SDK using Android Studio"
exit 1
fi
# Use the default NDK-bundle if no one is specified
if [ "$ANDROID_NDK" = "" ];
then
export ANDROID_NDK=$ANDROID_SDK/ndk-bundle
fi
# Make sure the Android NDK is installed
if [ ! -f "$ANDROID_NDK/ndk-build" ];
then
echo "Android NDK not installed"
echo "Download Android NDK Tools using Android Studio"
exit 1
fi
# Make sure xcpretty is installed
XC=$(xcpretty --version)
if [ ! $? -eq 0 ];
then
echo "xcpretty not installed"
echo "Download by running sudo gem install xcpretty"
exit 1
fi
# Update our node-dependencies
npm install
# Receive the current Titanium SDK version
TISDK=$(node ./tools/tiver.js -minsdk "$TISDK_SEMVER")
if [ $? -eq 1 ];
then
echo "Minimum Titanium SDK not found. Must be $TISDK_SEMVER, current active SDK is: $TISDK"
exit 1
else
echo "$CHECK Current Titanium SDK is $TISDK"
fi
# Flush dist/ directory
rm -rf dist
mkdir dist
# Receive the current Hyperloop version from our manifest.json
VERSION=`grep "^\s*\"version\":" package.json | cut -d ":" -f2 | cut -d "\"" -f2`
# Force the version into the manifest files in iphone/android directories!
sed -i.bak 's/VERSION/'"$VERSION"'/g' ./android/manifest
sed -i.bak 's/VERSION/'"$VERSION"'/g' ./iphone/manifest
# Build Android module
echo "Building Android module..."
cd android
# These dirs need to exist for TRAVIS CI. Only create if doesn't exist
mkdir -p ./lib
rm -rf build/*
rm -rf libs/*
mkdir -p ./build
mkdir -p ./build/docs
rm -rf dist
appc run -p android --build-only
if [ $? -ne 0 ];
then
exit $?
fi
cp dist/*.zip ../dist
cd ..
echo "Unzipping Android zipfile..."
cd dist
unzip hyperloop-android-$VERSION.zip
rm hyperloop-android-$VERSION.zip
cd ..
# Builds iOS module
echo "Building iOS module..."
cd iphone
rm -rf build
rm -rf hyperloop-iphone-*.zip
./build.sh
if [ $? -ne 0 ];
then
exit $?
fi
cp -R build/zip/modules/ ../dist/modules
cd ..
# Combine all modules to one masterpiece
echo "Creating combined zip with iOS andAndroid..."
cd dist
zip -q -r hyperloop-$VERSION.zip *
echo "$CHECK Combined zip completed successfully"
echo "$CHECK Distribution is available at dist/hyperloop-$VERSION.zip"
exit 0