Subversion Repositories tpanel

Rev

Rev 444 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
373 andreas 1
#!/bin/bash
375 andreas 2
set -o pipefail
451 andreas 3
SRCDIR="`pwd`"
375 andreas 4
 
5
###########################################################################
6
# Adapt the below variables to your need                                  #
7
###########################################################################
399 andreas 8
QT_VERSION="6.6.1"
373 andreas 9
QT_VERSION_MAJOR=6
10
QT_PATH="$HOME/Qt"
11
QT_ARCHITECTURE="arm64"
375 andreas 12
QT_MACROS="${QT_PATH}/Qt?Creator.app/Contents/Resources/package-manager"
373 andreas 13
 
14
QTBASE="${QT_PATH}/$QT_VERSION"
15
QTDIR="${QTBASE}/ios"
16
 
444 andreas 17
IOS_VERSION="17.0"
374 andreas 18
BUILDPATH="tpanel-ios"
373 andreas 19
OSX_SYSROOT="iphoneos"
20
#OSX_SYSROOT="iphonesimulator"
374 andreas 21
SIGNING_IDENTITY="<YOUR_SIGNING_IDENTITY>"
373 andreas 22
 
374 andreas 23
LOGFILE="${SRCDIR}/build.log"
376 andreas 24
EXT_LIB_PATH="${SRCDIR}/SDKs"
373 andreas 25
 
26
###########################################################################
27
# DO NOT EDIT ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING! #
28
###########################################################################
29
 
375 andreas 30
if [ -z "$OSTYPE" ]
31
then
32
    echo "Unknown operating system! This script must run on Mac OSX!"
33
    exit 1
34
fi
35
 
36
echo "$OSTYPE" | grep darwin > /dev/null
37
 
38
if [ $? -ne 0 ]
39
then
40
    echo "Unsupported OS $OSTYPE!"
41
    echo "This script must run on a Mac!"
42
    exit 1
43
fi
44
 
376 andreas 45
export EXT_LIB_PATH
373 andreas 46
GENERATOR="Xcode"
451 andreas 47
PROJECT_INCLUDE_BEFORE="${SRCDIR}/${BUILDPATH}/src/.qtc/package-manager/auto-setup.cmake"
373 andreas 48
QMAKE="${QTDIR}/bin/qmake"
49
PREFIX="${QTDIR}"
50
CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
51
CXX="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
52
TOOLCHAIN="${QTDIR}/lib/cmake/Qt6/qt.toolchain.cmake"
53
 
54
function usage() {
376 andreas 55
     echo "build_ios.sh [clean] [debug] [sign] [id <ID>] [help|--help|-h]"
373 andreas 56
     echo "   clean     Delete old build, if there is one, and start a new clean build."
57
     echo "   debug     Create a binary with debugging enabled."
58
     echo "   sign      Sign the resulting app."
374 andreas 59
     echo "   id <ID>   The signing identity (team ID)"
373 andreas 60
     echo
61
     echo "   help | --help | -h   Displays this help screen and exit."
62
     echo
63
     echo "Without parameters the source is compiled, if there were changes, and then"
374 andreas 64
     echo "an iOS package is created."
373 andreas 65
}
66
 
67
function log() {
68
     echo "$@"
374 andreas 69
     echo "$@" >> ${LOGFILE}
373 andreas 70
}
71
 
72
> ${LOGFILE}
73
 
74
if [ "$OSX_SYSROOT" != "iphoneos" -a "$OSX_SYSROOT" != "iphonesimulator" ]
75
then
76
    log "Invalid target: $OSX_SYSROOT!"
77
    log "OSX_SYSROOT must be \"iphoneos\" or \"iphonesimulator\"."
78
    exit 1
79
fi
80
 
374 andreas 81
#
82
# The following statement determines the number of CPUs. This is used for the
83
# cmake command to let run the compiler in parallel.
84
#
85
CPUS=2
86
type nproc > /dev/null 2>&1
373 andreas 87
 
88
if [ $? -eq 0 ]
89
then
374 andreas 90
     CPUS=`nproc`
373 andreas 91
fi
92
 
93
OPT_CLEAN=0
94
OPT_DEBUG=0
95
OPT_SIGN=0
96
OPT_VERBOSE=0
374 andreas 97
_loop=0
373 andreas 98
 
99
for par in "$@"
100
do
374 andreas 101
    if [ $_loop -eq 1 ]
102
    then
103
        SIGNING_IDENTITY="$par"
104
        _loop=0
105
        continue
106
    fi
107
 
373 andreas 108
    if [ "$par" == "clean" ]
109
    then
110
        OPT_CLEAN=1
111
    elif [ "$par" == "debug" ]
112
    then
113
        OPT_DEBUG=1
114
    elif [ "$par" == "sign" ]
115
    then
116
        OPT_SIGN=1
374 andreas 117
    elif [ "$par" == "id" ]
118
    then
119
        _loop=1
120
        continue
373 andreas 121
    elif [ "$par" == "--verbose" ] || [ "$par" == "-v" ] || [ "$par" == "verbose" ]
122
    then
123
        OPT_VERBOSE=1
124
    elif [ "$par" == "help" ] || [ "$par" == "--help" ] || [ "$par" == "-h" ]
125
    then
126
        usage
127
        exit 0
128
    fi
129
done
130
 
375 andreas 131
if [ -z $TERM_PROGRAM ] || [ "$TERM_PROGRAM" != "Apple_Terminal" ]
132
then
133
    if [ $OPT_SIGN -eq 1 ]
134
    then
135
        log "WARNING: This script is not running directly in an Apple console on a Mac!"
136
        log "         This may cause signing to fail!"
137
        log
138
    fi
139
fi
140
 
374 andreas 141
if [ "${SIGNING_IDENTITY}" == "<YOUR_SIGNING_IDENTITY>" ]
142
then
375 andreas 143
    log "Missing the signing identity (team ID)!"
144
    log "Please enter it in the head of this script or set it with parameter \"id\"!"
145
    log
374 andreas 146
    security find-identity -vp codesigning 2>&1 | tee -a ${LOGFILE}
375 andreas 147
 
148
    if [ $? -ne 0 ]
149
    then
150
        log "Couldn't find any signing identities!"
151
        exit 1
152
    fi
153
 
154
    read -p "Enter the signing identity (team ID) [CTRL+C to stop script]: " SIGNING_IDENTITY
155
 
156
    if [ -z $SIGNING_IDENTITY ]
157
    then
158
        log "No signing identity!"
159
        exit 1
160
    fi
161
 
162
    security find-identity -vp codesigning | grep "${SIGNING_IDENTITY}" > /dev/null 2>&1
163
 
164
    if [ $? -ne 0 ]
165
    then
166
        log "The signing identity \"$SIGNING_IDENTITY\" was not found!"
167
        exit 1
168
    fi
374 andreas 169
fi
170
 
373 andreas 171
if [ $OPT_CLEAN -eq 1 ]
172
then
173
    if [ -d "${BUILDPATH}" ]
174
    then
175
        log "Deleting the build path at $BUILDPATH ..."
176
        rm -rf "${BUILDPATH}"
177
    fi
178
fi
179
 
180
if [ ! -d "${BUILDPATH}" ]
181
then
182
    log "Creating directory $BUILDPATH ..."
451 andreas 183
    mkdir -p "${BUILDPATH}/src/.qtc/package-manager"
375 andreas 184
    log "Copy macros from $QT_MACROS ..."
451 andreas 185
    cp ${QT_MACROS}/* "${BUILDPATH}/src/.qtc/package-manager"
373 andreas 186
fi
187
 
188
_extra=""
189
 
190
if [ $OPT_SIGN -eq 1 -a "$OSX_SYSROOT" == "iphoneos" ]
191
then
374 andreas 192
    _extra="-DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM:STRING=${SIGNING_IDENTITY}"
373 andreas 193
elif [ "${OSX_SYSROOT}" == "iphonesimulator" ]
194
then
195
    log "The build for iPhone simulator is not signable!"
196
fi
197
 
374 andreas 198
_config="Release"
199
 
373 andreas 200
if [ $OPT_DEBUG -eq 1 ]
201
then
374 andreas 202
    _extra="$_extra -DCMAKE_VERBOSE_MAKEFILE:STRING=1"
203
    _config="Debug"
373 andreas 204
fi
205
 
206
log "Creating build files in $BUILDPATH ..."
207
 
208
if [ $OPT_DEBUG -eq 1 ]
209
then
376 andreas 210
    log "cmake -S "${SRCDIR}" -B \"${BUILDPATH}\" -DAPPLE:STRING=1 -DIOS:STRING=1 -DCMAKE_GENERATOR:STRING=\"$GENERATOR\" -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=\"${PROJECT_INCLUDE_BEFORE}\" -DQT_QMAKE_EXECUTABLE:FILEPATH=\"${QMAKE}\" -DCMAKE_PREFIX_PATH:PATH=\"${PREFIX}\" -DCMAKE_C_COMPILER:FILEPATH=\"${CC}\" -DCMAKE_CXX_COMPILER:FILEPATH=\"${CXX}\" -DCMAKE_TOOLCHAIN_FILE:FILEPATH=\"${TOOLCHAIN}\" -DCMAKE_OSX_ARCHITECTURES:STRING=\"$QT_ARCHITECTURE\" -DCMAKE_OSX_SYSROOT:STRING=\"${OSX_SYSROOT}\" -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=\"${IOS_VERSION}\" ${_extra}"
373 andreas 211
fi
212
 
374 andreas 213
cmake -S "${SRCDIR}" \
214
      -B "${BUILDPATH}" \
215
      -DAPPLE:STRING=1 \
216
      -DIOS:STRING=1 \
217
      -DCMAKE_GENERATOR:STRING="$GENERATOR" \
218
      -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH="${PROJECT_INCLUDE_BEFORE}" \
219
      -DQT_QMAKE_EXECUTABLE:FILEPATH="${QMAKE}" \
220
      -DCMAKE_PREFIX_PATH:PATH="${PREFIX}" \
221
      -DCMAKE_C_COMPILER:FILEPATH="${CC}" \
222
      -DCMAKE_CXX_COMPILER:FILEPATH="${CXX}" \
223
      -DCMAKE_TOOLCHAIN_FILE:FILEPATH="${TOOLCHAIN}" \
224
      -DCMAKE_OSX_ARCHITECTURES:STRING="$QT_ARCHITECTURE" \
225
      -DCMAKE_OSX_SYSROOT:STRING="${OSX_SYSROOT}" \
376 andreas 226
      -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="${IOS_VERSION}" \
375 andreas 227
      ${_extra} 2>&1 | tee -a ${LOGFILE}
373 andreas 228
 
229
if [ $? -ne 0 ]
230
then
374 andreas 231
    log "Error configuring the build pipeline!"
232
    log "For details look at \"${LOGFILE}\"."
373 andreas 233
    exit 1
234
fi
235
 
236
log "Compiling the code ..."
237
 
238
if [ $OPT_DEBUG -eq 1 ]
239
then
374 andreas 240
    log "cmake --build \"${BUILDPATH}\" --target ALL_BUILD --config ${_config} -j$CPUS -- -allowProvisioningUpdates"
373 andreas 241
fi
242
 
375 andreas 243
cmake --build "${BUILDPATH}" --target ALL_BUILD --config ${_config} -j$CPUS -- -allowProvisioningUpdates -strictVerify=false 2>&1 | tee -a ${LOGFILE}
373 andreas 244
 
245
if [ $? -ne 0 ]
246
then
374 andreas 247
    log "Error compiling!"
248
    log "For details look at \"${LOGFILE}\"."
373 andreas 249
    exit 1
250
fi
251
 
375 andreas 252
log "** Success **"
374 andreas 253
log "You can find the details at \"${LOGFILE}\""
373 andreas 254
exit 0
255