Debian Codegraph @

subprojects/fontconfig/.gitlab-ci/build.sh

raw symbols SCIP
1 #! /bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 set -ex
4 set -o pipefail
5
6 cidir=$(dirnamescip-shell system . . dirname. $0)
7 [scip-shell system . . `[`. -f ${cidir}/fcenv ] && . ${cidir}/fcenv
8
9 case "$OSTYPE" in
10 msys) MyPWD=$(pwdscip-shell system . . pwd. -W) ;;
11 *BSD) PATH=$PATH:/usr/local/bin ;&
12 *) MyPWD=$(pwdscip-shell system . . pwd.) ;;
13 esac
14 enable=()
15 disable=()
16 distcheck=0
17 enable_install=1
18 disable_check=0
19 clean_build=1
20 cross=0
21 subproject=0
22 subprojectname=""
23 buildsys="meson"
24 type="shared"
25 arch=""
26 buildopt=()
27 optimization=""
28 SRCDIR=$MyPWD
29 export MAKE=${MAKE:-make}
30 export BUILD_ID=${BUILD_ID:-fontconfig-$$}
31 export PREFIX=${PREFIX:-$MyPWD/prefix}
32 export BUILDDIR=${BUILDDIR:-$MyPWD/build}
33 export CI_MERGE_REQUEST_PROJECT_URL=${CI_MERGE_REQUEST_PROJECT_URL:-https://gitlab.freedesktop.org/fontconfig/fontconfig}
34 export CI_COMMIT_REF_NAME=${CI_COMMIT_REF_NAME:-main}
35
36 if [scip-shell system . . `[`. "x$FC_DISTRO_NAME" = "x" ]; then
37 . /etc/os-releasescip-shell source . . `/etc/os-release`. || :
38 FC_DISTRO_NAME=$ID
39 fi
40 if [scip-shell system . . `[`. "x$FC_DISTRO_NAME" = "x" ]; then
41 echoscip-shell system . . echo. "***"
42 echoscip-shell system . . echo. "*** Unable to detect OS. cross-compiling may not work. Please consider setting FC_DISTRO_NAME"
43 echoscip-shell system . . echo. "***"
44 sleepscip-shell system . . sleep. 3
45 fi
46
47 while getopts a:cCe:d:hINO:s:St:X: OPT
48 do
49 case $OPT in
50 'a') arch=$OPTARG ;;
51 'c') distcheck=1 ;;
52 'C') disable_check=1 ;;
53 'e') enable+=($OPTARG) ;;
54 'd') disable+=($OPTARG) ;;
55 'I') enable_install=0 ;;
56 'N') clean_build=0 ;;
57 'O') optimization=$OPTARG ;;
58 's') buildsys=$OPTARG ;;
59 'S') subproject=1 ;;
60 't') type=$OPTARG ;;
61 'X') backend=$OPTARG ;;
62 'h')
63 set +x
64 echoscip-shell system . . echo. "Usage: $0 [-a ARCH] [-c] [-C] [-e OPT] [-d OPT] [-h] [-I] [-N] [-O N] [-s BUILDSYS] [-S] [-t BUILDTYPE] [-X XMLBACKEND]"
65 echoscip-shell system . . echo. "Options:"
66 echoscip-shell system . . echo. " -a ARCH Use ARCH for cross-compile. Depends on BUILDSYS"
67 echoscip-shell system . . echo. " -c Run distcheck"
68 echoscip-shell system . . echo. " -C Do not run unit tests"
69 echoscip-shell system . . echo. " -e OPT Enable OPT feature to build"
70 echoscip-shell system . . echo. " -d OPT Disable OPT feature to build"
71 echoscip-shell system . . echo. " -I Run install"
72 echoscip-shell system . . echo. " -N Do not clean build directory"
73 echoscip-shell system . . echo. " -O N Optimization level to build"
74 echoscip-shell system . . echo. " -s BUILDSYS Use BUILDSYS to build (default: $buildsys)"
75 echoscip-shell system . . echo. " -S Run sub-project build. Take effect on meson only"
76 echoscip-shell system . . echo. " -t BUILDTYPE shared build or static build (default: $type)"
77 echoscip-shell system . . echo. " -X XMLBACKEND Use XMLBACKEND for xml parser library"
78 echoscip-shell system . . echo. ""
79 echoscip-shell system . . echo. "FC_BUILD_PLATFORM: Set a platform for cross-compiling, mingw or android"
80 exit 1
81 ;;
82 esac
83 done
84 case x"$FC_BUILD_PLATFORM" in
85 'xmingw') cross=1 ;;
86 'xandroid') cross=1 ;;
87 *) cross=0 ;;
88 esac
89
90 envscip-shell system . . env.
91
92 clean_exitscip-shell shell pango1.0 1.57.1-2 clean_exit().() {
93 rc=$?
94 trap - INT TERM ABRT EXIT
95 if [scip-shell system . . `[`. "x$TASK" != "x" ]; then
96 echoscip-shell system . . echo. "Aborting from \"$TASK\" with the exit code $rc"
97 fi
98 mvscip-shell system . . mv. /tmp/fc-build.logscip-shell filesystem . . `/tmp/fc-build.log`. . || :
99 exit $rc
100 }
101
102 trap clean_exit INT TERM ABRT EXIT
103
104 if [scip-shell system . . `[`. x"$buildsys" == "xautotools" ]; then
105 if [scip-shell system . . `[`. $subproject -eq 1 ]; then
106 echoscip-shell system . . echo. "Subproject build not supported in autotools"
107 exit 1
108 fi
109 for i in "${enable[@]}"; do
110 buildopt+=(--enable-$i)
111 done
112 for i in "${disable[@]}"; do
113 buildopt+=(--disable-$i)
114 done
115 case x"$backend" in
116 'xexpat')
117 buildopt+=(--disable-libxml2)
118 ;;
119 'xlibxml2')
120 buildopt+=(--enable-libxml2)
121 ;;
122 esac
123 case x"$type" in
124 'xshared')
125 buildopt+=(--enable-shared)
126 buildopt+=(--disable-static)
127 ;;
128 'xstatic')
129 buildopt+=(--disable-shared)
130 buildopt+=(--enable-static)
131 ;;
132 'both')
133 buildopt+=(--enable-shared)
134 buildopt+=(--enable-static)
135 ;;
136 esac
137 if [scip-shell system . . `[`. $cross -eq 1 -a -n "$arch" ]; then
138 buildopt+=(--host=$arch)
139 if [scip-shell system . . `[`. ! -f .gitlab-ci/${FC_DISTRO_NAME}-cross.sh ]; then
140 echoscip-shell system . . echo. "No ${FC_DISTRO_NAME}-cross.sh available"
141 exit 1
142 fi
143 . .gitlab-ci/${FC_DISTRO_NAME}-cross.sh
144 fi
145 if [scip-shell system . . `[`. $clean_build -eq 1 ]; then
146 rmscip-shell system . . rm. -rf "$BUILDDIR" "$PREFIX" || :
147 mkdirscip-shell system . . mkdir. "$BUILDDIR" "$PREFIX"
148 fi
149 cd "$BUILDDIR"
150 TASK="autogen.sh"
151 ../autogen.sh --prefix="$PREFIX" --disable-cache-build ${buildopt[*]} 2>&1 | teescip-shell system . . tee. /tmp/fc-build.logscip-shell filesystem . . `/tmp/fc-build.log`.
152 TASK="make"
153 $MAKE V=1 2>&1 | teescip-shell system . . tee. -a /tmp/fc-build.logscip-shell filesystem . . `/tmp/fc-build.log`.
154 if [scip-shell system . . `[`. $disable_check -eq 0 ]; then
155 TASK="make check"
156 $MAKE check V=1 2>&1 | teescip-shell system . . tee. -a /tmp/fc-build.logscip-shell filesystem . . `/tmp/fc-build.log`.
157 fi
158 if [scip-shell system . . `[`. $enable_install -eq 1 ]; then
159 TASK="make install"
160 $MAKE install V=1 2>&1 | teescip-shell system . . tee. -a /tmp/fc-build.logscip-shell filesystem . . `/tmp/fc-build.log`.
161 fi
162 if [scip-shell system . . `[`. $distcheck -eq 1 ]; then
163 TASK="make distcheck"
164 $MAKE distcheck V=1 2>&1 | teescip-shell system . . tee. -a /tmp/fc-build.logscip-shell filesystem . . `/tmp/fc-build.log`.
165 fi
166 elif [scip-shell system . . `[`. x"$buildsys" == "xmeson" ]; then
167 TASK="pip install"
168 pipscip-shell system . . pip. install "meson>=1.6.1"
169 # tomli not required for Python >= 3.11
170 pipscip-shell system . . pip. install tomli
171 pipscip-shell system . . pip. install pytest pytest-tap requests
172 for i in "${enable[@]}"; do
173 buildopt+=(-D$i=enabled)
174
175 # Update bindgen on Fontations builds to improve support for constants in fcint.h
176 if [[ "$i" == "fontations" ]]; then
177 TASK="cargo install"
178 cargoscip-shell system . . cargo. install bindgen-cli
179 # Prepend the cargo bin directory to PATH
180 if [[ -d "$HOME/.cargo/bin" ]]; then
181 export PATH="$HOME/.cargo/bin:$PATH"
182 echoscip-shell system . . echo. "Cargo bin directory added to PATH."
183 else
184 echoscip-shell system . . echo. "Cargo bin directory not found."
185 fi
186 fi
187 done
188 if [scip-shell system . . `[`. $subproject -eq 1 ]; then
189 buildopt+=(--force-fallback-for=fontconfig)
190 if [scip-shell system . . `[`. -d fc-ci-meson-subproject ]; then
191 rmscip-shell system . . rm. -rf fc-ci-meson-subproject
192 fi
193 TASK="git clone"
194 gitscip-shell system . . git. clone https://gitlab.freedesktop.org/fontconfig/fc-ci-meson-subproject.git
195 cd fc-ci-meson-subproject
196 pushd subprojects
197 gitscip-shell system . . git. clone ${CI_MERGE_REQUEST_PROJECT_URL}.git
198 if [scip-shell system . . `[`. -n "$CI_MERGE_REQUEST_IID" ]; then
199 pushd fontconfig
200 gitscip-shell system . . git. fetch origin merge-requests/$CI_MERGE_REQUEST_IID/head:$CI_COMMIT_REF_NAME
201 gitscip-shell system . . git. switch $CI_COMMIT_REF_NAME
202 popd
203 else
204 # use main branch instead
205 :
206 fi
207 popd
208 subprojectname="fontconfig:"
209 fi
210 TASK=
211 if [scip-shell system . . `[`. -n "$optimization" ]; then
212 buildopt+=(--optimization=$optimization)
213 fi
214 for i in "${disable[@]}"; do
215 buildopt+=(-D${subprojectname}$i=disabled)
216 done
217 case x"$backend" in
218 'xexpat')
219 buildopt+=(-D${subprojectname}xml-backend=expat)
220 ;;
221 'xlibxml2')
222 buildopt+=(-D${subprojectname}xml-backend=libxml2)
223 ;;
224 esac
225 if [scip-shell system . . `[`. $cross -eq 1 -a -n "$arch" ]; then
226 buildopt+=(--cross-file)
227 buildopt+=(.gitlab-ci/$arch.txt)
228 if [scip-shell system . . `[`. ! -f .gitlab-ci/$FC_DISTRO_NAME-cross.sh ]; then
229 echoscip-shell system . . echo. "No $FC_DISTRO_NAME-cross.sh available"
230 exit 1
231 fi
232 if [scip-shell system . . `[`. $subproject -eq 1 ]; then
233 . subprojects/fontconfig/.gitlab-ci/$FC_DISTRO_NAME-cross.sh
234 else
235 . .gitlab-ci/$FC_DISTRO_NAME-cross.sh
236 fi
237 fi
238 buildopt+=(--default-library=$type)
239 if [scip-shell system . . `[`. $clean_build -eq 1 ]; then
240 rmscip-shell system . . rm. -rf "$BUILDDIR" "$PREFIX" || :
241 fi
242 TASK="meson setup"
243 mesonscip-shell system . . meson. setup --prefix="$PREFIX" -D${subprojectname}nls=enabled -D${subprojectname}cache-build=disabled -D${subprojectname}iconv=enabled ${buildopt[*]} "$BUILDDIR" 2>&1 | teescip-shell system . . tee. /tmp/fc-build.logscip-shell filesystem . . `/tmp/fc-build.log`.
244 TASK="meson compile"
245 mesonscip-shell system . . meson. compile -v -C "$BUILDDIR" 2>&1 | teescip-shell system . . tee. -a /tmp/fc-build.logscip-shell filesystem . . `/tmp/fc-build.log`.
246 if [scip-shell system . . `[`. $disable_check -eq 0 ]; then
247 TASK="meson test"
248 mesonscip-shell system . . meson. test -v -C "$BUILDDIR" 2>&1 | teescip-shell system . . tee. -a /tmp/fc-build.logscip-shell filesystem . . `/tmp/fc-build.log`.
249 fi
250 if [scip-shell system . . `[`. $enable_install -eq 1 ]; then
251 TASK="meson install"
252 mesonscip-shell system . . meson. install -C "$BUILDDIR" 2>&1 | teescip-shell system . . tee. -a /tmp/fc-build.logscip-shell filesystem . . `/tmp/fc-build.log`.
253 fi
254 if [scip-shell system . . `[`. $distcheck -eq 1 ]; then
255 TASK="meson dist"
256 mesonscip-shell system . . meson. dist -C "$BUILDDIR" 2>&1 | teescip-shell system . . tee. -a /tmp/fc-build.logscip-shell filesystem . . `/tmp/fc-build.log`.
257 fi
258 fi
259 TASK=
260 exit 0