@@ -59,6 +59,7 @@ CONFIG=${1:-"default"}
5959cd " $( git rev-parse --show-toplevel) " || exit 1
6060
6161BUILDDIR=" $( pwd) /.build-ci"
62+ TOOLDIR=" $( pwd) /.build-tools"
6263
6364fn_exists () { declare -F " $1 " > /dev/null; }
6465
@@ -126,37 +127,46 @@ test_meson_coverage() {
126127}
127128
128129tools_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
140144tools_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-
186194if [[ " ${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
198206fi
199207
208+ echo " samu: ${SAMU} "
209+ echo " muon: ${MUON} "
210+
211+ rm -rf " ${BUILDDIR} "
212+
200213config_" ${BUILDTOOL} " _" ${CONFIG} "
201214fn_exists " build_${BUILDTOOL} _${CONFIG} " && " build_${BUILDTOOL} _${CONFIG} " || build_" ${BUILDTOOL} "
202215fn_exists " test_${BUILDTOOL} _${CONFIG} " && " test_${BUILDTOOL} _${CONFIG} " || test_" ${BUILDTOOL} "
0 commit comments