Repository navigation
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·669 lines (613 loc) · 19.3 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·669 lines (613 loc) · 19.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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
#!/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)"
# MSYS2 (MinGW) provides mingw32-make; its CMake generates "MinGW Makefiles"
if [[ "${OS_NAME}" == *MINGW* ]]; then
MAKE_CMD=mingw32-make
# Without this, CMake picks Ninja (when available), but we build with mingw32-make
export CMAKE_GENERATOR="MinGW Makefiles"
else
MAKE_CMD=make
fi
FORCE_CMAKE=0
WITH_TESTS=0
NO_BUILD=0
WITH_OPENGL=0
WX_VERSION=v3.3.4
WXCRAFTER_BUILD_DIR_NAME=.build-release-wxcrafter
WXCRAFTER_BUILD_DIR=${ROOT_DIR}/${WXCRAFTER_BUILD_DIR_NAME}
. ${ROOT_DIR}/scripts/functions.rc
# Terminal integration. Everything is sent to stderr, and only when it is a terminal.
case "${OS_NAME}" in
*MINGW*) PLATFORM=Windows ;;
Darwin) PLATFORM=macOS ;;
*) PLATFORM="${OS_NAME}" ;;
esac
# OSC 9;4 progress bar: 3 = indeterminate (pulsing), 0 = remove
function progress_bar() {
[ -t 2 ] || return 0
printf '\033]9;4;%s;\a' "$1" >&2
}
# OSC 7501 program status: working, done, error or clear
function program_status() {
[ -t 2 ] || return 0
printf '\033]7501;state=%s\a' "$1" >&2
}
# OSC 0 terminal title. An empty title resets it.
function set_title() {
[ -t 2 ] || return 0
if [ -n "$1" ]; then
printf '\033]0;%s (%s)\a' "$1" "${PLATFORM}" >&2
else
printf '\033]0;\a' >&2
fi
}
function on_exit() {
local rc=$?
trap - EXIT
progress_bar 0
if [ ${rc} -eq 0 ]; then
program_status done
else
program_status error
fi
program_status clear
set_title ""
exit ${rc}
}
trap on_exit EXIT
trap 'exit 130' INT
trap 'exit 143' TERM
progress_bar 3
program_status working
set_title "Building CodeLite"
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 run_make() {
if [ "${NO_BUILD}" -eq 1 ]; then
INFO "--no-build was passed; skipping: make $*"
return 0
fi
${MAKE_CMD} "$@"
}
function check_prerequistes() {
if [[ "${OS_NAME}" == *MINGW* ]]; then
install_prerequistes_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 [[ "${OS_NAME}" == "Linux" ]] && [ "${WITH_OPENGL}" -eq 1 ]; then
# The OpenGL terminal needs the GL and GLEW development headers
for header in GL/gl.h GL/glew.h; do
if [ ! -f "/usr/include/${header}" ] && [ ! -f "/usr/local/include/${header}" ]; then
ERROR "Missing OpenGL header: ${header} (install libgl-dev and libglew-dev)"
missing=1
fi
done
fi
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}-python \
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 \
mingw-w64-${MSYS_ARCH}-glew \
flex bison patch 2>${BUILD_DIR}/msys_install_packages_err.log || {
cat "${BUILD_DIR}/msys_install_packages_err.log" >&2
ERROR "Failed to install the MSYS2 packages"
exit 1
}
touch "${marker}"
}
function build_wx_widgets_MSW() {
local wx_install_dir=${BUILD_DIR}/wxWidgets-install
# Windows only: CL_WX_VERSION (a wxWidgets tag or branch, e.g. v3.2.11) overrides the pinned version
local wx_version=${CL_WX_VERSION:-${WX_VERSION}}
local wx_version_file=${wx_install_dir}/.wx_version
if ls ${wx_install_dir}/lib/clang*/wxmsw*.dll >/dev/null 2>&1; then
local built_version=""
[ -f "${wx_version_file}" ] && built_version=$(cat "${wx_version_file}")
if [ -z "${built_version}" ] || [ "${built_version}" == "${wx_version}" ]; then
INFO "wxWidgets DLLs already found in ${wx_install_dir} (version: ${built_version:-unknown}); skipping build"
return 0
fi
INFO "wxWidgets ${built_version} was built, but ${wx_version} was requested; rebuilding"
rm -fr "${wx_install_dir}"
# The CodeLite and wxCrafter build trees hold values computed from the old wxWidgets (version, DLL name, ...),
# remove their cache so they are configured again
rm -f "${BUILD_DIR}/CMakeCache.txt" "${WXCRAFTER_BUILD_DIR}/CMakeCache.txt"
fi
INFO "Building wxWidgets"
set_title "Building wxWidgets"
INFO "Checking out wxWidgets version: ${wx_version}"
mkdir -p ${BUILD_DIR}
cd $_
rm -fr wxWidgets # in case we aborted earlier
git clone --depth 1 --branch ${wx_version} https://github.com/wxWidgets/wxWidgets.git
cd wxWidgets
git submodule update --init --depth 1
mkdir .build-release
cd .build-release
apply_wx_patches
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_CMD} -j$(nproc) install
echo "${wx_version}" >"${wx_version_file}"
export WXWIN="${BUILD_DIR}/wxWidgets-install"
INFO "WXWIN is set to '${WXWIN}'"
cd ${ROOT_DIR}
}
# Applies our patches to the wxWidgets sources (the current directory is
# .build-release/wxWidgets/.build-release). The patches are shared with the
# wxTerminalEmulator submodule. A patch that does not apply, for example because
# it is already in the wxWidgets version, is skipped.
function apply_wx_patches() {
local patch
local reason
local wx_version
wx_version=$(git -C .. describe --tags --always 2>/dev/null)
for patch in "${ROOT_DIR}"/submodules/wxTerminalEmulator/patches/wxwidgets-*.patch; do
[ -f "${patch}" ] || continue
# --ignore-whitespace: the wxWidgets sources can have CRLF line endings on
# Windows, the patches have LF.
if reason=$(git -C .. apply --check --ignore-whitespace "${patch}" 2>&1); then
INFO "Applying $(basename "${patch}") to wxWidgets"
git -C .. apply --ignore-whitespace "${patch}"
else
WARN "Skipping $(basename "${patch}"): it does not apply to wxWidgets ${wx_version}"
WARN "${reason}"
fi
done
}
function build_wx_widgets_Linux() {
local wx_install_dir=${BUILD_DIR}/wxWidgets-install
# Do not use v3.3.3 or newer on Linux for now: wxGTK clipboard copy (Ctrl-C) crashes WSLg's Weston
local wx_version=v3.3.2
if [ -x "${wx_install_dir}/bin/wx-config" ]; then
if [ "${WITH_OPENGL}" -eq 1 ] && ! "${wx_install_dir}/bin/wx-config" --libs gl >/dev/null 2>&1; then
ERROR "The wxWidgets build at ${wx_install_dir} has no OpenGL (gl) support"
ERROR "Remove ${wx_install_dir} (or run: $(basename $0) distclean) and build again with --opengl"
exit 1
fi
INFO "wxWidgets already built at ${wx_install_dir}; skipping"
export PATH="${wx_install_dir}/bin":$PATH
return 0
fi
INFO "Building wxWidgets"
set_title "Building wxWidgets"
INFO "Checking out wxWidgets version: ${wx_version}"
rm -fr ${BUILD_DIR}/wxWidgets
mkdir -p ${BUILD_DIR}
cd $_
git clone --depth 1 --branch ${wx_version} https://github.com/wxWidgets/wxWidgets.git
cd wxWidgets
git submodule update --init --depth 1
mkdir ${BUILD_DIR_NAME}
cd ${BUILD_DIR_NAME}
apply_wx_patches
local wx_gl_opt=""
if [ "${WITH_OPENGL}" -eq 1 ]; then
wx_gl_opt="--with-opengl"
INFO "Building wxWidgets with OpenGL support"
fi
../configure --disable-debug_flag --with-gtk=3 --enable-stl ${wx_gl_opt} --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"
set_title "Building wxWidgets"
INFO "Checking out wxWidgets version: ${WX_VERSION}"
rm -fr ${BUILD_DIR}/wxWidgets
mkdir -p ${BUILD_DIR}
cd $_
git clone --depth 1 --branch ${WX_VERSION} https://github.com/wxWidgets/wxWidgets.git
cd wxWidgets
git submodule update --init --depth 1
mkdir ${BUILD_DIR_NAME}
cd ${BUILD_DIR_NAME}
apply_wx_patches
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_CodeLite_Linux() {
INFO "Building CodeLite"
set_title "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
local buildTests=""
if [ "${WITH_TESTS}" -eq 1 ]; then
buildTests="-DBUILD_TESTING=1"
INFO "Building with UT enabled"
fi
local installPrefix=""
if [ "${BUILD_TARGET}" == "Debug" ]; then
installPrefix="-DCMAKE_INSTALL_PREFIX=${HOME}/root"
fi
local openGL="-DUSE_OPENGL=OFF"
if [ "${WITH_OPENGL}" -eq 1 ]; then
openGL="-DUSE_OPENGL=ON"
INFO "Building with the OpenGL terminal enabled"
fi
cmake ${ROOT_DIR} -DCMAKE_BUILD_TYPE=${BUILD_TARGET} -DMAKE_DEB=1 -DCOPY_WX_LIBS=1 \
-DWITH_WX_CONFIG=${wx_config} ${buildTests} ${installPrefix} ${openGL}
else
INFO "CodeLite already configured; skipping cmake"
fi
run_make -j$(nproc) #VERBOSE=1
if [ "${NO_BUILD}" -eq 1 ]; then
cd ${ROOT_DIR}
return 0
fi
INFO "CodeLite built successfully"
cd ${ROOT_DIR}
INFO ""
INFO "To run CodeLite:"
INFO "=============="
if [ "${BUILD_TARGET}" == "Debug" ]; then
INFO "cd ${BUILD_DIR} && make -j$(nproc) install"
INFO "${HOME}/root/bin/codelite"
else
INFO "${BUILD_DIR}/bin/codelite"
fi
INFO ""
}
function build_CodeLite_macOS() {
INFO "Building CodeLite"
set_title "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
local buildTests=""
if [ "${WITH_TESTS}" -eq 1 ]; then
buildTests="-DBUILD_TESTING=1"
INFO "Building with UT enabled"
fi
cmake ${ROOT_DIR} -DCMAKE_BUILD_TYPE=${BUILD_TARGET} \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOS_DEPLOYMENT_TARGET} \
-DwxWidgets_CONFIG_EXECUTABLE=${wx_config} ${buildTests}
else
INFO "CodeLite already configured; skipping cmake"
fi
run_make -j$(sysctl -n hw.physicalcpu) install
if [ "${NO_BUILD}" -eq 1 ]; then
cd ${ROOT_DIR}
return 0
fi
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"
set_title "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
local buildTests=""
if [ "${WITH_TESTS}" -eq 1 ]; then
buildTests="-DBUILD_TESTING=1"
INFO "Building with UT enabled"
fi
INFO "Configuring CodeLite"
rm -f ${CodeLite_build_dir}/CMakeCache.txt
cmake ${ROOT_DIR} -DCMAKE_BUILD_TYPE=${BUILD_TARGET} -DWXWIN="${BUILD_DIR}/wxWidgets-install" ${buildTests}
else
INFO "CodeLite already configured; skipping cmake"
fi
run_make -j$(nproc) install
if [ "${NO_BUILD}" -eq 1 ]; then
cd ${ROOT_DIR}
return 0
fi
INFO "CodeLite built successfully"
cd ${ROOT_DIR}
INFO ""
INFO "To run CodeLite:"
INFO "=============="
INFO ""
INFO "(cd ${BUILD_DIR}/install/bin && ./codelite.exe)"
INFO ""
}
function build_wxCrafter_MSW() {
INFO "Building wxCrafter"
set_title "Building wxCrafter"
# wxCrafter must be built against the exact same wxWidgets build used for CodeLite,
# so make sure it exists first (this reuses ${BUILD_DIR}/wxWidgets-install; it does
# NOT build a separate copy of wxWidgets for wxCrafter).
build_wx_widgets_MSW
local wx_install_dir=${BUILD_DIR}/wxWidgets-install
mkdir -p ${WXCRAFTER_BUILD_DIR}
cd ${WXCRAFTER_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 "${WXCRAFTER_BUILD_DIR}/CMakeCache.txt" ] || [ ! -d "${WXCRAFTER_BUILD_DIR}/install" ] ||
check_cmake_modified "${WXCRAFTER_BUILD_DIR}"; then
INFO "Configuring wxCrafter"
rm -f ${WXCRAFTER_BUILD_DIR}/CMakeCache.txt
cmake ${ROOT_DIR} -DCMAKE_BUILD_TYPE=${BUILD_TARGET} -DWXC_APP=1 -DWXWIN="${wx_install_dir}"
else
INFO "wxCrafter already configured; skipping cmake"
fi
run_make -j$(nproc) install
if [ "${NO_BUILD}" -eq 1 ]; then
cd ${ROOT_DIR}
return 0
fi
INFO "wxCrafter built successfully"
cd ${ROOT_DIR}
INFO ""
INFO "To run wxCrafter:"
INFO "================="
INFO ""
INFO "(cd ${WXCRAFTER_BUILD_DIR}/install/bin && ./wxcrafter.exe)"
INFO ""
}
function package_wxCrafter_MSW() {
build_wxCrafter_MSW
cd ${WXCRAFTER_BUILD_DIR}
${MAKE_CMD} -j$(nproc) setup
cd ${ROOT_DIR}
}
function clean() {
if [ ! -d "${BUILD_DIR}" ]; then
INFO "Nothing to clean"
return 0
fi
INFO "Cleaning build artifacts"
${MAKE_CMD} -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 " wxcrafter Build wxCrafter (Windows only)"
echo " package_wxcrafter Build wxCrafter and create an installer for it (Windows only)"
echo ""
echo "Options:"
echo " --cmake Force the cmake configure stage even if it is up to date"
echo " --tests Enable Tests"
echo " --no-build Run cmake only, skip the build step (make)"
echo " --opengl Linux only: build the terminal with OpenGL (needs libgl-dev, libglew-dev)"
echo ""
echo "Environment:"
echo " CL_WX_VERSION Windows only: the wxWidgets tag or branch to build (e.g. v3.2.11 or master)"
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_CMD} -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"
set_title "Packaging CodeLite"
cd ${BUILD_DIR}
make -j$(nproc) package
fi
}
TARGET=""
while [ $# -gt 0 ]; do
case "${1}" in
--cmake)
FORCE_CMAKE=1
;;
--tests)
WITH_TESTS=1
;;
--no-build)
NO_BUILD=1
;;
--opengl)
if [[ "${OS_NAME}" != "Linux" ]]; then
ERROR "--opengl is only supported on Linux"
exit 1
fi
WITH_OPENGL=1
FORCE_CMAKE=1
;;
-h | --help)
usage
exit 0
;;
clean | distclean | package | debug | wxcrafter | package_wxcrafter)
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
;;
wxcrafter | package_wxcrafter)
if [[ "${OS_NAME}" != *MINGW* ]]; then
ERROR "'${TARGET}' is only supported on Windows"
exit 1
fi
check_prerequistes
if [ "${TARGET}" == "wxcrafter" ]; then
build_wxCrafter_MSW
else
package_wxCrafter_MSW
fi
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