Skip to content

Commit a03b7ed

Browse files
dwsuseigaw
authored andcommitted
build: do not rebuild muon/samu every time
There is not need to build the build tools everytime. Thus stage the samurai and muon build into a new top level directory .build-tools and only build them on demand. Signed-off-by: Daniel Wagner <[email protected]>
1 parent 2dffc6e commit a03b7ed

1 file changed

Lines changed: 36 additions & 23 deletions

File tree

scripts/build.sh

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ CONFIG=${1:-"default"}
5959
cd "$(git rev-parse --show-toplevel)" || exit 1
6060

6161
BUILDDIR="$(pwd)/.build-ci"
62+
TOOLDIR="$(pwd)/.build-tools"
6263

6364
fn_exists() { declare -F "$1" > /dev/null; }
6465

@@ -126,37 +127,46 @@ test_meson_coverage() {
126127
}
127128

128129
tools_build_samurai() {
129-
mkdir -p "${BUILDDIR}"/build-tools
130-
git clone --depth 1 https://github.com/michaelforney/samurai.git \
131-
"${BUILDDIR}/build-tools/samurai"
132-
pushd "${BUILDDIR}/build-tools/samurai" || exit 1
130+
if [ ! -d "${TOOLDIR}"/samurai ]; then
131+
git clone --depth 1 https://github.com/michaelforney/samurai.git \
132+
"${TOOLDIR}/samurai"
133+
fi
133134

134-
CC="${CC}" make
135-
SAMU="${BUILDDIR}/build-tools/samurai/samu"
135+
if [[ -f "${TOOLDIR}/samurai/samu" ]]; then
136+
return
137+
fi
136138

139+
pushd "${TOOLDIR}/samurai" || exit 1
140+
CC="${CC}" make
137141
popd || exit 1
138142
}
139143

140144
tools_build_muon() {
141-
mkdir -p "${BUILDDIR}"/build-tools
142-
git clone --depth 1 https://git.sr.ht/~lattis/muon \
143-
"${BUILDDIR}/build-tools/muon"
144-
pushd "${BUILDDIR}/build-tools/muon" || exit 1
145+
if [ ! -d "${TOOLDIR}/muon" ]; then
146+
git clone --depth 1 https://git.sr.ht/~lattis/muon \
147+
"${TOOLDIR}/muon"
148+
fi
149+
150+
if [[ -f "${TOOLDIR}/build-muon/muon" ]]; then
151+
return
152+
fi
153+
154+
pushd "${TOOLDIR}/muon" || exit 1
145155

146156
CC="${CC}" ninja="${SAMU}" ./bootstrap.sh stage1
147157

148158
CC="${CC}" ninja="${SAMU}" stage1/muon setup \
149-
-Dprefix="${BUILDDIR}/build-tools" \
150159
-Dlibcurl=enabled \
151160
-Dlibarchive=enabled \
152161
-Dlibpkgconf=enabled \
162+
-Dprefix="${TOOLDIR}" \
153163
-Ddocs=disabled \
154164
-Dsamurai=disabled \
155-
"${BUILDDIR}/build-tools/.build-muon"
156-
"${SAMU}" -C "${BUILDDIR}/build-tools/.build-muon"
157-
MUON="${BUILDDIR}/build-tools/.build-muon/muon"
165+
"${TOOLDIR}/build-muon"
166+
"${SAMU}" -C "${TOOLDIR}/build-muon"
158167

159-
# "${MUON}" -C "${BUILDDIR}/build-tools/.build-muon" test
168+
# "${TOOLDIR}/build-muon/muon" \
169+
# -C "${TOOLDIR}/build-muon" test
160170

161171
popd || exit 1
162172
}
@@ -181,22 +191,25 @@ test_muon() {
181191
ninja="${SAMU}" "${MUON}" -C "${BUILDDIR}" test
182192
}
183193

184-
rm -rf "${BUILDDIR}"
185-
186194
if [[ "${BUILDTOOL}" == "muon" ]]; then
187-
if ! which samu ; then
195+
SAMU="$(which samu 2> /dev/null)" || true
196+
if [[ -z "${SAMU}" ]]; then
188197
tools_build_samurai
189-
else
190-
SAMU="$(which samu)"
198+
SAMU="${TOOLDIR}/samurai/samu"
191199
fi
192200

193-
if ! which muon ; then
201+
MUON="$(which muon 2> /dev/null)" || true
202+
if [[ -z "${MUON}" ]]; then
194203
tools_build_muon
195-
else
196-
MUON="$(which muon)"
204+
MUON="${TOOLDIR}/build-muon/muon"
197205
fi
198206
fi
199207

208+
echo "samu: ${SAMU}"
209+
echo "muon: ${MUON}"
210+
211+
rm -rf "${BUILDDIR}"
212+
200213
config_"${BUILDTOOL}"_"${CONFIG}"
201214
fn_exists "build_${BUILDTOOL}_${CONFIG}" && "build_${BUILDTOOL}_${CONFIG}" || build_"${BUILDTOOL}"
202215
fn_exists "test_${BUILDTOOL}_${CONFIG}" && "test_${BUILDTOOL}_${CONFIG}" || test_"${BUILDTOOL}"

0 commit comments

Comments
 (0)