Skip to content
This repository was archived by the owner on Apr 19, 2023. It is now read-only.

Commit f8aa1dc

Browse files
committed
Remove excess code from build_examples.sh
1 parent 1f0977a commit f8aa1dc

File tree

1 file changed

+13
-104
lines changed

1 file changed

+13
-104
lines changed

build_examples.sh

Lines changed: 13 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,133 +1,42 @@
11
#!/usr/bin/env bash
22

3-
# This script is intended to be run from an Ubuntu 18.04 Docker image.
4-
# Since it uses `apt-get` to install dependencies required by the examples,
5-
# it may also run on other versions of Ubuntu, or other Debian-derived distros.
6-
# It will definitely not run without `apt-get` installed!
3+
# This script is intended to be run from an Ubuntu Docker image (or other Debian-derived distros).
4+
# It uses `apt-get` to install dependencies required by the examples,
75

86
set -euo pipefail
97

10-
DEFAULT_BUILD_DIR="build"
11-
BUILD_DIR="${DEFAULT_BUILD_DIR}"
12-
SCRIPT_NAME=$(basename $0)
13-
PROJECT_DIRNAME=$(dirname $(readlink -f $0))
14-
USAGE="Usage: ${SCRIPT_NAME} [options]...
15-
16-
Options:
17-
-h, --help Print this message
18-
-b, --build-dir BUILD_DIR Build examples in BUILD_DIR instead of default '${DEFAULT_BUILD_DIR}'
19-
--all Build all the examples available
20-
--fltk Build fltk example
21-
--gtkmm Build gtkmm example
22-
--imgui Build imgui example
23-
--nana Build nana example
24-
--qt Build qt example
25-
--sdl Build sdl example
26-
"
27-
28-
function build_fltk() {
8+
function install_fltk() {
299
apt-get install -y --no-install-recommends libfltk1.3-dev libgl1-mesa-dev fluid
30-
BUILD_DIR="${1:-build-fltk}"
31-
mkdir -p "${BUILD_DIR}"
32-
cmake -S "${PROJECT_DIRNAME}" -B "${BUILD_DIR}" -DCPP_STARTER_USE_FLTK=ON
33-
cmake --build "${BUILD_DIR}" -j
3410
}
3511

36-
function build_gtkmm() {
12+
function install_gtkmm() {
3713
apt-get install -y --no-install-recommends pkg-config libgtkmm-3.0-dev
38-
BUILD_DIR="${1:-build-gtkmm}"
39-
mkdir -p "${BUILD_DIR}"
40-
cmake -S "${PROJECT_DIRNAME}" -B "${BUILD_DIR}" -DCPP_STARTER_USE_GTKMM=ON
41-
cmake --build "${BUILD_DIR}" -j
4214
}
4315

44-
function build_imgui() {
16+
function install_imgui() {
4517
apt-get install -y --no-install-recommends pkg-config libgl1-mesa-dev
46-
BUILD_DIR="${1:-build-imgui}"
47-
mkdir -p "${BUILD_DIR}"
48-
cmake -S "${PROJECT_DIRNAME}" -B "${BUILD_DIR}" -DCPP_STARTER_USE_IMGUI=ON
49-
cmake --build "${BUILD_DIR}" -j
5018
}
5119

52-
function build_nana() {
20+
function install_nana() {
5321
# CMakeLists.txt is 'supposed' to install all of these automatically, but for
5422
# some reason it doesn't always work. Installing them manually does work.
5523
apt-get install -y --no-install-recommends libjpeg8-dev libpng-dev \
5624
libasound2-dev alsa-utils alsa-oss libx11-dev libxft-dev libxcursor-dev
57-
BUILD_DIR="${1:-build-nana}"
58-
mkdir -p "${BUILD_DIR}"
5925
# Note: Nana's headers trigger the -Wshadow warning, and cannot be compiled with -Werror.
6026
# Supposedly, this is fixed in the develop-1.8 branch, but I cannot confirm.
61-
cmake -S "${PROJECT_DIRNAME}" -B "${BUILD_DIR}" -DCPP_STARTER_USE_NANA=ON -DWARNINGS_AS_ERRORS=FALSE
62-
cmake --build "${BUILD_DIR}" -j
6327
}
6428

65-
function build_qt() {
29+
function install_qt() {
6630
apt-get install -y --no-install-recommends qt5-default qtbase5-dev
67-
BUILD_DIR="${1:-build-qt}"
68-
mkdir -p "${BUILD_DIR}"
69-
cmake -S "${PROJECT_DIRNAME}" -B "${BUILD_DIR}" -DCPP_STARTER_USE_QT=ON
70-
cmake --build "${BUILD_DIR}" -j
7131
}
7232

73-
function build_sdl() {
33+
function install_sdl() {
7434
pip install mako
75-
BUILD_DIR="${1:-build-sdl}"
76-
mkdir -p "${BUILD_DIR}"
77-
cmake -S "${PROJECT_DIRNAME}" -B "${BUILD_DIR}" -DCPP_STARTER_USE_SDL=ON
78-
cmake --build "${BUILD_DIR}" -j
79-
}
80-
81-
function build_all() {
82-
build_fltk
83-
build_gtkmm
84-
build_imgui
85-
build_nana
86-
build_qt
87-
build_sdl
8835
}
8936

90-
# Parse the available options
91-
PARSED_OPTIONS=$(getopt -n "$0" -o h: --long "fltk,gtkmm,imgui,nana,qt,sdl,all,help,build:" -- "$@")
92-
eval set -- "${PARSED_OPTIONS}"
37+
# call the above functions to install the required dependencies. As an example for qt:
38+
# install_qt
9339

94-
# Handle all the options
95-
while true;
96-
do
97-
case "$1" in
98-
--help|-h)
99-
echo "${USAGE}"
100-
shift;;
101-
--build-dir|-b)
102-
if [ -n "$2" ];
103-
then
104-
BUILD_DIR="$2"
105-
echo "Using BUILD_DIR='${BUILD_DIR}'"
106-
fi
107-
shift 2;;
108-
--all)
109-
build_all $BUILD_DIR
110-
shift;;
111-
--fltk)
112-
build_fltk $BUILD_DIR
113-
shift;;
114-
--gtkmm)
115-
build_gtkmm $BUILD_DIR
116-
shift;;
117-
--imgui)
118-
build_imgui $BUILD_DIR
119-
shift;;
120-
--nana)
121-
build_nana $BUILD_DIR
122-
shift;;
123-
--qt)
124-
build_qt $BUILD_DIR
125-
shift;;
126-
--sdl)
127-
build_sdl $BUILD_DIR
128-
shift;;
129-
--)
130-
shift
131-
break;;
132-
esac
133-
done
40+
# build with:
41+
cmake -S . -B "./build"
42+
cmake --build "./build"

0 commit comments

Comments
 (0)