Skip to content

Commit 4e71727

Browse files
committed
Revise build script.
1 parent 441ce89 commit 4e71727

File tree

8 files changed

+70
-51
lines changed

8 files changed

+70
-51
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ depends/ios/Frameworks/opencv2.framework
5454
depends/macos/Frameworks/ARX.framework/
5555
depends/macos/Frameworks/opencv2.framework
5656
depends/android/artoolkitx
57+
artoolkitX.for.iOS.v*.dmg
58+
artoolkitX.for.macOS.v*.dmg
5759

5860
# Build files
5961
Linux/build/

Android/app/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ android {
88
applicationId "org.artoolkitx.utilities.calibcameraandroid"
99
minSdkVersion 24
1010
targetSdkVersion 33
11-
versionCode 1
12-
versionName "1.0"
11+
compileSdkVersion 33
12+
versionCode 1010000
13+
versionName "1.1"
1314
externalNativeBuild {
1415
cmake {
1516
arguments "-DANDROID_APP_PLATFORM=android-24", "-DANDROID_STL=c++_shared"

Android/app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:versionCode="1"
4-
android:versionName="1.0"
53
android:installLocation="auto">
64

75
<uses-permission android:name="android.permission.CAMERA" />
File renamed without changes.

artoolkitx-version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.1.12

build.sh

Lines changed: 62 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,22 @@ set -x
1919
# Get our location.
2020
OURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2121

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}/"
2822

2923
VERSION=`sed -En -e 's/.*VERSION_STRING[[:space:]]+"([0-9]+\.[0-9]+(\.[0-9]+)*)".*/\1/p' ${OURDIR}/version.h`
3024
# If the tiny version number is 0, drop it.
3125
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}"
3238

3339
function usage {
3440
echo "Usage: $(basename $0) [--debug] (macos | ios | windows | linux | linux-raspbian) "
@@ -100,6 +106,15 @@ else
100106
CPUS=1
101107
fi
102108

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+
103118
# Function to allow check for required packages.
104119
function check_package {
105120
# Variant for distros that use debian packaging.
@@ -115,21 +130,11 @@ function check_package {
115130
fi
116131
}
117132

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
133138
}
134139

135140
if [ "$OS" = "Darwin" ] ; then
@@ -140,16 +145,18 @@ if [ "$OS" = "Darwin" ] ; then
140145
# macOS
141146
if [ $BUILD_MACOS ] ; then
142147

148+
cd "${OURDIR}"
143149
# 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}"
149155
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+
153160
# Make the version number available to Xcode.
154161
cp macOS/user-config-in.xcconfig macOS/user-config.xcconfig
155162
sed -E -i "" -e "s/@VERSION@/${VERSION}/" macOS/user-config.xcconfig
@@ -163,17 +170,19 @@ fi
163170
# iOS
164171
if [ $BUILD_IOS ] ; then
165172

173+
cd "${OURDIR}"
166174
# 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}"
172180
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
174182
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}"
177186

178187
# Make the version number available to Xcode.
179188
cp iOS/user-config-in.xcconfig iOS/user-config.xcconfig
@@ -187,15 +196,18 @@ fi
187196

188197
if [ $BUILD_ANDROID ] ; then
189198

199+
cd "${OURDIR}"
190200
# If artoolkitx folder is not a symlink, fetch artoolkitx from latest build into a location where the build can find it.
191201
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}"
196204
rm -rf "${OURDIR}/depends/android/artoolkitx"
197205
unzip "${OURDIR}/${SDK_FILENAME}" -d "${OURDIR}/depends/android/artoolkitx"
198206
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+
199211
(cd "${OURDIR}/Android"
200212
echo "Building Android project"
201213
./gradlew assembleRelease
@@ -258,17 +270,22 @@ if [ "$OS" = "Windows" ] ; then
258270
# Windows
259271
if [ $BUILD_WINDOWS ] ; then
260272

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+
261281
if [ ! -d "build-windows" ] ; then
262282
mkdir build-windows
263283
fi
264284

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-
268285
(cd Windows
269286
mkdir -p build
270287
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}"
272289
cmake.exe --build . --config ${DEBUG+Debug}${DEBUG-Release} --target install
273290
)
274291
fi

loc_strings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const std::unordered_map<const loc_string, const char*> loc_strings[] =
4343
{
4444
// en
4545
{
46-
{loc_string::Reintro, "Press 'space' to begin a calibration run.\n\nPress 'p' for settings and help."},
46+
{loc_string::Intro, "Welcome to artoolkitX Camera Calibrator\n(c)2023 artoolkitX Contributors.\n\nPress 'space' to begin a calibration run.\n\nPress 'p' for settings and help."},
4747
{loc_string::VideoOpenError, "Welcome to artoolkitX Camera Calibrator\n(c)2023 artoolkitX Contributors.\n\nUnable to open video source.\n\nPress 'p' for settings and help."},
4848
{loc_string::Reintro, "Press 'space' to begin a calibration run.\n\nPress 'p' for settings and help."},
4949
{loc_string::IntroTouchscreen, "Welcome to artoolkitX Camera Calibrator\n(c)2023 artoolkitX Contributors.\n\nTap '+' to begin a calibration run.\n\nTap the menu button for settings and help."},

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
extern "C" {
4343
#endif
4444

45-
#define VERSION_STRING "1.0.4"
45+
#define VERSION_STRING "1.1"
4646

4747
#ifdef __cplusplus
4848
}

0 commit comments

Comments
 (0)