@@ -19,16 +19,22 @@ set -x
19
19
# Get our location.
20
20
OURDIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
21
21
22
- SDK_VERSION=' 1.1.12'
23
- # If the version number includes a dev build number, drop it.
24
- SDK_VERSION_CANON=` echo -n " ${SDK_VERSION} " | sed -E -e ' s/([0-9]+\.[0-9]+\.[0-9]+)(\.[0-9])?/\1/' `
25
- # If the tiny version number is 0, drop it.
26
- SDK_VERSION_PRETTY=` echo -n " ${SDK_VERSION_CANON} " | sed -E -e ' s/([0-9]+\.[0-9]+)\.0/\1/' `
27
- SDK_URL_DIR=" https://github.com/artoolkitx/artoolkitx/releases/download/${SDK_VERSION} /"
28
22
29
23
VERSION=` sed -En -e ' s/.*VERSION_STRING[[:space:]]+"([0-9]+\.[0-9]+(\.[0-9]+)*)".*/\1/p' ${OURDIR} /version.h`
30
24
# If the tiny version number is 0, drop it.
31
25
VERSION=` echo -n " ${VERSION} " | sed -E -e ' s/([0-9]+\.[0-9]+)\.0/\1/' `
26
+ # Process for version number parts.
27
+ VERSION_MAJOR=$( echo ${VERSION} | sed -E -e ' s/^([0-9]+).*/\1/' )
28
+ VERSION_MINOR=$( echo ${VERSION} | sed -E -e ' s/^[0-9]+\.([0-9]+).*/\1/' )
29
+ # VERSION_TINY and its preceding dot can be absent, so allow for that in our regexp and set to 0 in that case.
30
+ VERSION_TINY=$( echo ${VERSION} | sed -E -e ' s/^[0-9]+\.[0-9]+\.*([0-9]+)*.*/\1/' )
31
+ VERSION_TINY=${VERSION_TINY:- 0}
32
+ # VERSION_BUILD can be overridden in the environment, but defaults to 0.
33
+ VERSION_BUILD=${VERSION_BUILD:- 0}
34
+ # Convert version to an integer (e.g. for use in incremental build numbering, as on Android).
35
+ VERSION_INT=$( printf " %d%02d%02d%02d" ${VERSION_MAJOR} ${VERSION_MINOR} ${VERSION_TINY} ${VERSION_BUILD} )
36
+
37
+ echo " Build version ${VERSION_INT} "
32
38
33
39
function usage {
34
40
echo " Usage: $( basename $0 ) [--debug] (macos | ios | windows | linux | linux-raspbian) "
@@ -100,6 +106,15 @@ else
100
106
CPUS=1
101
107
fi
102
108
109
+ ARTOOLKITX_VERSION=$( cat ${OURDIR} /artoolkitx-version.txt | tr -d ' [:space:]' )
110
+
111
+ # Set default CMake generator for Windows.
112
+ echo " $CMAKE_GENERATOR "
113
+ if [ $OS = " Windows" ] && test -z " $CMAKE_GENERATOR " ; then
114
+ CMAKE_GENERATOR=" Visual Studio 16 2019"
115
+ CMAKE_ARCH=" x64"
116
+ fi
117
+
103
118
# Function to allow check for required packages.
104
119
function check_package {
105
120
# Variant for distros that use debian packaging.
@@ -115,21 +130,11 @@ function check_package {
115
130
fi
116
131
}
117
132
118
- function rawurlencode() {
119
- local string=" ${1} "
120
- local strlen=${# string}
121
- local encoded=" "
122
- local pos c o
123
-
124
- for (( pos= 0 ; pos< strlen ; pos++ )) ; do
125
- c=${string: $pos : 1}
126
- case " $c " in
127
- [-_.~a-zA-Z0-9] ) o=" ${c} " ;;
128
- * ) printf -v o ' %%%02x' " '$c "
129
- esac
130
- encoded+=" ${o} "
131
- done
132
- echo -n " ${encoded} "
133
+ find_or_fetch_artoolkitx () {
134
+ if [ ! -f " ${1} " ] ; then
135
+ echo " Downloading ${1} ..."
136
+ curl --location " https://github.com/artoolkitx/artoolkitx/releases/download/${ARTOOLKITX_VERSION} /${1} " -O
137
+ fi
133
138
}
134
139
135
140
if [ " $OS " = " Darwin" ] ; then
@@ -140,16 +145,18 @@ if [ "$OS" = "Darwin" ] ; then
140
145
# macOS
141
146
if [ $BUILD_MACOS ] ; then
142
147
148
+ cd " ${OURDIR} "
143
149
# Fetch the ARX.framework from latest build into a location where Xcode will find it.
144
- SDK_FILENAME= " artoolkitX.for.macOS.v ${SDK_VERSION_PRETTY} .dmg "
145
- if [ ! -f " ${SDK_FILENAME} " ] ; then
146
- curl -f -o " ${SDK_FILENAME} " --location " ${SDK_URL_DIR} $( rawurlencode " ${SDK_FILENAME} " ) "
147
- fi
148
- hdiutil attach " ${SDK_FILENAME } " -noautoopen -quiet -mountpoint " SDK "
150
+ MOUNTPOINT=mnt $$
151
+ IMAGE= " artoolkitX.for.macOS.v ${ARTOOLKITX_VERSION} .dmg "
152
+ find_or_fetch_artoolkitx " ${IMAGE} "
153
+ mkdir -p " ${MOUNTPOINT} "
154
+ hdiutil attach " ${IMAGE } " -noautoopen -quiet -mountpoint " ${MOUNTPOINT} "
149
155
rm -rf depends/macOS/Frameworks/ARX.framework
150
- cp -af SDK/artoolkitX/SDK/Frameworks/ARX.framework depends/macOS/Frameworks
151
- hdiutil detach " SDK" -quiet -force
152
-
156
+ ditto " ${MOUNTPOINT} /artoolkitX/SDK/Frameworks/ARX.framework" depends/macOS/Frameworks/ARX.framework
157
+ hdiutil detach " ${MOUNTPOINT} " -quiet -force
158
+ rmdir " ${MOUNTPOINT} "
159
+
153
160
# Make the version number available to Xcode.
154
161
cp macOS/user-config-in.xcconfig macOS/user-config.xcconfig
155
162
sed -E -i " " -e " s/@VERSION@/${VERSION} /" macOS/user-config.xcconfig
163
170
# iOS
164
171
if [ $BUILD_IOS ] ; then
165
172
173
+ cd " ${OURDIR} "
166
174
# Fetch libARX from latest build into a location where Xcode will find it.
167
- SDK_FILENAME= " artoolkitX.for.iOS.v ${SDK_VERSION_PRETTY} .dmg "
168
- if [ ! -f " ${SDK_FILENAME} " ] ; then
169
- curl -f -o " ${SDK_FILENAME} " --location " ${SDK_URL_DIR} $( rawurlencode " ${SDK_FILENAME} " ) "
170
- fi
171
- hdiutil attach " ${SDK_FILENAME } " -noautoopen -quiet -mountpoint " SDK "
175
+ MOUNTPOINT=mnt $$
176
+ IMAGE= " artoolkitX.for.iOS.v ${ARTOOLKITX_VERSION} .dmg "
177
+ find_or_fetch_artoolkitx " ${IMAGE} "
178
+ mkdir -p " ${MOUNTPOINT} "
179
+ hdiutil attach " ${IMAGE } " -noautoopen -quiet -mountpoint " ${MOUNTPOINT} "
172
180
rm -rf depends/iOS/include/ARX/
173
- cp -af SDK /artoolkitX/SDK/include/ARX depends/iOS/include
181
+ cp -af " ${MOUNTPOINT} /artoolkitX/SDK/include/ARX" depends/iOS/include
174
182
rm -f depends/iOS/lib/libARX.a
175
- cp -af SDK/artoolkitX/SDK/lib/libARX.a depends/iOS/lib
176
- hdiutil detach " SDK" -quiet -force
183
+ cp -af " ${MOUNTPOINT} /artoolkitX/SDK/lib/libARX.a" depends/iOS/lib
184
+ hdiutil detach " ${MOUNTPOINT} " -quiet -force
185
+ rmdir " ${MOUNTPOINT} "
177
186
178
187
# Make the version number available to Xcode.
179
188
cp iOS/user-config-in.xcconfig iOS/user-config.xcconfig
187
196
188
197
if [ $BUILD_ANDROID ] ; then
189
198
199
+ cd " ${OURDIR} "
190
200
# If artoolkitx folder is not a symlink, fetch artoolkitx from latest build into a location where the build can find it.
191
201
if [[ ! -L " ${OURDIR} /depends/android/artoolkitx" ]] ; then
192
- SDK_FILENAME=" artoolkitx-${SDK_VERSION_PRETTY} -Android.zip"
193
- if [ ! -f " ${OURDIR} /${SDK_FILENAME} " ] ; then
194
- curl -f -o " ${OURDIR} /${SDK_FILENAME} " --location " ${SDK_URL_DIR} $( rawurlencode " ${SDK_FILENAME} " ) "
195
- fi
202
+ IMAGE=" artoolkitx-${ARTOOLKITX_VERSION} -Android.zip"
203
+ find_or_fetch_artoolkitx " ${IMAGE} "
196
204
rm -rf " ${OURDIR} /depends/android/artoolkitx"
197
205
unzip " ${OURDIR} /${SDK_FILENAME} " -d " ${OURDIR} /depends/android/artoolkitx"
198
206
fi
207
+
208
+ # Make the version number available to Gradle.
209
+ sed -E -i " " -e " s/versionCode [0-9]+/versionCode ${VERSION_INT} /" -e " s/versionName \" [0-9\.]+\" /versionName \" ${VERSION} \" /" Android/app/build.gradle
210
+
199
211
(cd " ${OURDIR} /Android"
200
212
echo " Building Android project"
201
213
./gradlew assembleRelease
@@ -258,17 +270,22 @@ if [ "$OS" = "Windows" ] ; then
258
270
# Windows
259
271
if [ $BUILD_WINDOWS ] ; then
260
272
273
+ cd " ${OURDIR} "
274
+ MOUNTPOINT=mnt$$
275
+ IMAGE=" artoolkitX-${ARTOOLKITX_VERSION} -Windows.zip"
276
+ find_or_fetch_artoolkitx " ${IMAGE} "
277
+ unzip -q -o " ${IMAGE} " -d " ${MOUNTPOINT} "
278
+ # TODO COPY FROM "${MOUNTPOINT}/artoolkitX"
279
+ rm -rf " ${MOUNTPOINT} "
280
+
261
281
if [ ! -d " build-windows" ] ; then
262
282
mkdir build-windows
263
283
fi
264
284
265
- SDK_FILENAME=" artoolkitX.for.Windows.v${SDK_VERSION_PRETTY} .zip"
266
- curl -f -o " ${SDK_FILENAME} " --location " ${SDK_URL_DIR} $( rawurlencode " ${SDK_FILENAME} " ) "
267
-
268
285
(cd Windows
269
286
mkdir -p build
270
287
cd build
271
- cmake.exe .. -DCMAKE_CONFIGURATION_TYPES=${DEBUG+Debug}${DEBUG-Release} " -GVisual Studio 15 2017 Win64 " -D" VERSION=${VERSION} "
288
+ cmake.exe .. -DCMAKE_CONFIGURATION_TYPES=${DEBUG+Debug}${DEBUG-Release} -G " $CMAKE_GENERATOR " ${CMAKE_ARCH+-A ${CMAKE_ARCH} } -D" VERSION=${VERSION} "
272
289
cmake.exe --build . --config ${DEBUG+Debug}${DEBUG-Release} --target install
273
290
)
274
291
fi
0 commit comments