Repository navigation
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·418 lines (377 loc) · 11.3 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·418 lines (377 loc) · 11.3 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
#!/bin/bash -e
ROOT_DIR=$(dirname $(readlink -f $0))
BUILD_TARGET=Release
BUILD_DIR_NAME=.build-release
BUILD_DIR=${ROOT_DIR}/${BUILD_DIR_NAME}
OS_NAME="$(uname -s)"
FORCE_CMAKE=0
. ${ROOT_DIR}/scripts/functions.rc
INFO "Building CodeLite"
function check_cmake_modified() {
local build_dir=$1
find "${ROOT_DIR}" \
-not -path "*/.git/*" \
-not -path "*/.build*/*" \
-not -path "*/.codelite*/*" \
-not -path "*/.vscode/*" \
-not -path "*/.idea/*" \
-not -path "*/node_modules/*" \
-name "CMakeLists.txt" \
-newer "${build_dir}/Makefile" \
-print -quit | grep -q .
}
function check_prerequistes() {
if [[ "${OS_NAME}" == *MINGW* ]]; then
install_prerequistes_MSW
install_wx_config_MSW
fi
INFO "Checking build prerequisites"
local missing=0
local compiler
if [[ "${OS_NAME}" == "Linux" ]]; then
compiler="g++"
else
compiler="clang++"
fi
for tool in ${compiler} cmake git; do
if command -v "${tool}" >/dev/null 2>&1; then
INFO "Found ${tool}: $(command -v ${tool})"
else
ERROR "Missing required tool: ${tool}"
missing=1
fi
done
if [ "${missing}" -ne 0 ]; then
ERROR "Please install the missing prerequisites and try again"
exit 1
fi
}
function install_prerequistes_MSW() {
local marker="${BUILD_DIR}/.msys_packages_installed"
if [ -f "${marker}" ]; then
INFO "MSYS2 packages already installed; skipping"
return 0
fi
INFO "Installing MSYS2 packages for ${MSYS_ARCH}..."
mkdir -p ${BUILD_DIR}
pacman -S --needed --noconfirm --quiet \
git \
openssh \
mingw-w64-${MSYS_ARCH}-toolchain \
mingw-w64-${MSYS_ARCH}-python3 \
mingw-w64-${MSYS_ARCH}-cmake \
mingw-w64-${MSYS_ARCH}-libffi \
mingw-w64-${MSYS_ARCH}-jq \
mingw-w64-${MSYS_ARCH}-libxml2 \
mingw-w64-${MSYS_ARCH}-llvm-openmp \
mingw-w64-${MSYS_ARCH}-ntldd \
unzip \
mingw-w64-${MSYS_ARCH}-zlib \
mingw-w64-${MSYS_ARCH}-libssh \
mingw-w64-${MSYS_ARCH}-hunspell \
mingw-w64-${MSYS_ARCH}-openssl \
mingw-w64-${MSYS_ARCH}-sqlite3 \
mingw-w64-${MSYS_ARCH}-libmariadbclient \
mingw-w64-${MSYS_ARCH}-postgresql \
mingw-w64-${MSYS_ARCH}-ctags \
flex bison patch 2>${BUILD_DIR}/msys_install_packages_err.log
touch "${marker}"
}
function install_wx_config_MSW() {
INFO "Building wx-config for Windows"
local wx_config_install_dir=${BUILD_DIR}/wx-config-msys2-install
if [ -f "${wx_config_install_dir}/bin/wx-config.exe" ]; then
INFO "${wx_config_install_dir}/bin/wx-config.exe exists; skipping"
export PATH=${wx_config_install_dir}/bin:$PATH
return 0
fi
mkdir -p ${BUILD_DIR}
cd $_
git clone --depth 1 https://github.com/eranif/wx-config-msys2.git
cd wx-config-msys2
mkdir ${BUILD_DIR_NAME}
cd $_
cmake .. -DCMAKE_BUILD_TYPE=Release -G"MinGW Makefiles" -DCMAKE_INSTALL_PREFIX="${wx_config_install_dir}"
mingw32-make -j$(nproc) install
export PATH=${wx_config_install_dir}/bin:$PATH
}
function build_wx_widgets_Linux() {
local wx_install_dir=${BUILD_DIR}/wxWidgets-install
if [ -x "${wx_install_dir}/bin/wx-config" ]; then
INFO "wxWidgets already built at ${wx_install_dir}; skipping"
export PATH="${wx_install_dir}/bin":$PATH
return 0
fi
INFO "Building wxWidgets"
rm -fr ${BUILD_DIR}/wxWidgets
mkdir -p ${BUILD_DIR}
cd $_
git clone --depth 1 https://github.com/wxWidgets/wxWidgets.git
cd wxWidgets
git submodule update --init --depth 1
mkdir ${BUILD_DIR_NAME}
cd ${BUILD_DIR_NAME}
../configure --disable-debug_flag --with-gtk=3 --enable-stl --prefix=${wx_install_dir}
make -j$(nproc) install
export PATH="${wx_install_dir}/bin":$PATH
cd ${ROOT_DIR}
}
function build_wx_widgets_macOS() {
local wx_install_dir=${BUILD_DIR}/wxWidgets-install
if [ -x "${wx_install_dir}/bin/wx-config" ]; then
INFO "wxWidgets already built at ${wx_install_dir}; skipping"
export PATH="${wx_install_dir}/bin":$PATH
return 0
fi
INFO "Building wxWidgets"
rm -fr ${BUILD_DIR}/wxWidgets
mkdir -p ${BUILD_DIR}
cd $_
git clone --depth 1 https://github.com/wxWidgets/wxWidgets.git
cd wxWidgets
git submodule update --init --depth 1
mkdir ${BUILD_DIR_NAME}
cd ${BUILD_DIR_NAME}
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DwxBUILD_DEBUG_LEVEL=0 \
-DwxBUILD_MONOLITHIC=1 \
-DwxBUILD_SAMPLES=OFF \
-DwxUSE_SYS_LIBS=OFF \
-DwxUSE_LUNASVG=OFF \
-DCMAKE_INSTALL_PREFIX=${BUILD_DIR}/wxWidgets-install
make -j$(sysctl -n hw.physicalcpu) install
export PATH="${wx_install_dir}/bin":$PATH
cd ${ROOT_DIR}
}
function build_wx_widgets_MSW() {
local wx_install_dir=${BUILD_DIR}/wxWidgets-install
if ls ${wx_install_dir}/lib/clang*/wxmsw*.dll >/dev/null 2>&1; then
INFO "wxWidgets DLLs already found in ${wx_install_dir}; skipping build"
return 0
fi
INFO "Building wxWidgets"
mkdir -p ${BUILD_DIR}
cd $_
rm -fr wxWidgets # in case we aborted earlier
git clone --depth 1 https://github.com/wxWidgets/wxWidgets.git
cd wxWidgets
git submodule update --init --depth 1
mkdir ${BUILD_DIR_NAME}
cd ${BUILD_DIR_NAME}
cmake .. -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release \
-DwxBUILD_DEBUG_LEVEL=0 \
-DwxBUILD_MONOLITHIC=1 -DwxBUILD_SAMPLES=OFF -DwxUSE_STL=ON \
-DCMAKE_TLS_VERIFY=OFF \
-DCMAKE_INSTALL_PREFIX=${BUILD_DIR}/wxWidgets-install
make -j$(nproc) install
export WXWIN="${BUILD_DIR}/wxWidgets-install"
INFO "WXWIN is set to '${WXWIN}'"
cd ${ROOT_DIR}
}
function build_CodeLite_Linux() {
INFO "Building CodeLite"
local wx_install_dir=${BUILD_DIR}/wxWidgets-install
local wx_config=${wx_install_dir}/bin/wx-config
if [ ! -x "${wx_config}" ]; then
ERROR "Local wx-config not found at ${wx_config}"
exit 1
fi
INFO "Using local wx-config: ${wx_config}"
local CodeLite_build_dir=${ROOT_DIR}/${BUILD_DIR_NAME}
mkdir -p ${CodeLite_build_dir}
cd ${CodeLite_build_dir}
if [ "${FORCE_CMAKE}" -eq 1 ] || [ ! -f "${CodeLite_build_dir}/CMakeCache.txt" ] ||
check_cmake_modified "${CodeLite_build_dir}"; then
INFO "Configuring CodeLite"
rm -f ${CodeLite_build_dir}/CMakeCache.txt
cmake ${ROOT_DIR} -DCMAKE_BUILD_TYPE=${BUILD_TARGET} -DMAKE_DEB=1 -DCOPY_WX_LIBS=1 \
-DWITH_WX_CONFIG=${wx_config}
else
INFO "CodeLite already configured; skipping cmake"
fi
make -j$(nproc) #VERBOSE=1
INFO "CodeLite built successfully"
cd ${ROOT_DIR}
INFO ""
INFO "To run CodeLite:"
INFO "=============="
INFO "${BUILD_DIR}/install/bin/codelite"
INFO ""
}
function build_CodeLite_macOS() {
INFO "Building CodeLite"
local wx_install_dir=${BUILD_DIR}/wxWidgets-install
local wx_config=${wx_install_dir}/bin/wx-config
if [ ! -x "${wx_config}" ]; then
ERROR "Local wx-config not found at ${wx_config}"
exit 1
fi
INFO "Using local wx-config: ${wx_config}"
local CodeLite_build_dir=${ROOT_DIR}/${BUILD_DIR_NAME}
mkdir -p ${CodeLite_build_dir}
cd ${CodeLite_build_dir}
# Configure if the build tree has not been generated yet, or if
# CMakeLists.txt is newer than the generated cache.
if [ "${FORCE_CMAKE}" -eq 1 ] || [ ! -f "${CodeLite_build_dir}/CMakeCache.txt" ] || [ ! -d "${CodeLite_build_dir}/codelite.app" ] ||
check_cmake_modified "${CodeLite_build_dir}" ||
! grep -q "^CMAKE_OSX_DEPLOYMENT_TARGET:STRING=${MACOS_DEPLOYMENT_TARGET}$" "${CodeLite_build_dir}/CMakeCache.txt"; then
INFO "Configuring CodeLite"
rm -f ${CodeLite_build_dir}/CMakeCache.txt
cmake ${ROOT_DIR} -DCMAKE_BUILD_TYPE=${BUILD_TARGET} \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOS_DEPLOYMENT_TARGET} \
-DwxWidgets_CONFIG_EXECUTABLE=${wx_config}
else
INFO "CodeLite already configured; skipping cmake"
fi
make -j$(sysctl -n hw.physicalcpu) install
INFO "CodeLite built successfully"
cd ${ROOT_DIR}
INFO ""
INFO "To run CodeLite:"
INFO "=============="
INFO "open ${BUILD_DIR}/codelite.app"
INFO ""
}
function build_CodeLite_MSW() {
INFO "Building CodeLite"
local CodeLite_build_dir=${ROOT_DIR}/${BUILD_DIR_NAME}
mkdir -p ${CodeLite_build_dir}
cd ${CodeLite_build_dir}
# Configure if the build tree has not been generated yet, or if
# CMakeLists.txt is newer than the generated cache.
if [ "${FORCE_CMAKE}" -eq 1 ] || [ ! -f "${CodeLite_build_dir}/CMakeCache.txt" ] || [ ! -d "${CodeLite_build_dir}/install" ] ||
check_cmake_modified "${CodeLite_build_dir}"; then
INFO "Configuring CodeLite"
rm -f ${CodeLite_build_dir}/CMakeCache.txt
cmake ${ROOT_DIR} -DCMAKE_BUILD_TYPE=${BUILD_TARGET} -DWXWIN="${BUILD_DIR}/wxWidgets-install"
else
INFO "CodeLite already configured; skipping cmake"
fi
make -j$(nproc) install
INFO "CodeLite built successfully"
cd ${ROOT_DIR}
INFO ""
INFO "To run CodeLite:"
INFO "=============="
INFO ""
INFO "(cd ${BUILD_DIR}/install/bin && ./codelite.exe)"
INFO ""
}
function clean() {
if [ ! -d "${BUILD_DIR}" ]; then
INFO "Nothing to clean"
return 0
fi
INFO "Cleaning build artifacts"
make -C "${BUILD_DIR}" clean
INFO "Clean complete"
}
function distclean() {
INFO "Removing build directory: ${BUILD_DIR}"
rm -rf "${BUILD_DIR}"
INFO "Distclean complete"
}
function usage() {
echo "Usage: $(basename $0) [options] [target]"
echo ""
echo "Targets:"
echo " (none) Build CodeLite (default, release mode)"
echo " debug Build CodeLite (debug mode)"
echo " clean Remove build artifacts (make clean)"
echo " distclean Remove the entire build directory"
echo " package Create an installer suitable for the current platform"
echo ""
echo "Options:"
echo " --cmake Force the cmake configure stage even if it is up to date"
echo " -h, --help Show this help message"
}
function build() {
if [[ "${OS_NAME}" == *MINGW* ]]; then
INFO "On Windows"
build_wx_widgets_MSW
build_CodeLite_MSW
elif [[ "${OS_NAME}" == "Darwin" ]]; then
INFO "On macOS"
build_wx_widgets_macOS
build_CodeLite_macOS
elif [[ "${OS_NAME}" == "Linux" ]]; then
INFO "On Linux"
build_wx_widgets_Linux
build_CodeLite_Linux
else
ERROR "Unsupported operating system: ${OS_NAME}"
exit 1
fi
}
function package() {
build
if [[ "${OS_NAME}" == *MINGW* ]]; then
cd ${BUILD_DIR}
make -j$(nproc) setup/fast
elif [[ "${OS_NAME}" == "Darwin" ]]; then
cd ${BUILD_DIR}
if [ ! -d "codelite.app" ]; then
ERROR "codelite.app not found in ${BUILD_DIR}"
exit 1
fi
if [ -z "$CODELITE_PASSWORD" ]; then
ERROR "CODELITE_PASSWORD environment variable is not set"
exit 1
fi
rm -f *.zip
${ROOT_DIR}/scripts/weekly/macos-sign-app.sh --notarize --password $CODELITE_PASSWORD codelite.app
elif [[ "${OS_NAME}" == "Linux" ]]; then
INFO "Creating Linux package"
cd ${BUILD_DIR}
make -j$(nproc) package
fi
}
TARGET=""
while [ $# -gt 0 ]; do
case "${1}" in
--cmake)
FORCE_CMAKE=1
;;
-h | --help)
usage
exit 0
;;
clean | distclean | package | debug)
if [ -n "${TARGET}" ]; then
ERROR "Multiple targets specified: '${TARGET}' and '${1}'"
usage
exit 1
fi
TARGET="${1}"
;;
*)
ERROR "Unknown argument: ${1}"
usage
exit 1
;;
esac
shift
done
case "${TARGET}" in
clean)
clean
exit 0
;;
distclean)
distclean
exit 0
;;
package)
package
exit 0
;;
debug)
BUILD_TARGET=Debug
BUILD_DIR_NAME=.build-debug
BUILD_DIR=${ROOT_DIR}/${BUILD_DIR_NAME}
INFO "Building CodeLite in DEBUG mode"
;;
"") ;;
esac
check_prerequistes
build