Skip to content

Commit e821f0a

Browse files
committed
cmake: Migrate Guix build scripts to CMake
1 parent 747adb6 commit e821f0a

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

contrib/guix/libexec/build.sh

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,13 @@ mkdir -p "$OUTDIR"
206206
###########################
207207

208208
# CONFIGFLAGS
209-
CONFIGFLAGS="--enable-reduce-exports --disable-bench --disable-gui-tests --disable-fuzz-binary"
209+
CONFIGFLAGS="-DREDUCE_EXPORTS=ON -DBUILD_BENCH=OFF -DBUILD_GUI_TESTS=OFF -DBUILD_FUZZ_BINARY=OFF"
210210

211211
# CFLAGS
212212
HOST_CFLAGS="-O2 -g"
213213
HOST_CFLAGS+=$(find /gnu/store -maxdepth 1 -mindepth 1 -type d -exec echo -n " -ffile-prefix-map={}=/usr" \;)
214214
case "$HOST" in
215-
*linux*) HOST_CFLAGS+=" -ffile-prefix-map=${PWD}=." ;;
215+
*linux*) HOST_CFLAGS+=" -ffile-prefix-map=${DISTSRC}/src=." ;;
216216
*mingw*) HOST_CFLAGS+=" -fno-ident" ;;
217217
*darwin*) unset HOST_CFLAGS ;;
218218
esac
@@ -239,38 +239,31 @@ mkdir -p "$DISTSRC"
239239
# Extract the source tarball
240240
tar --strip-components=1 -xf "${GIT_ARCHIVE}"
241241

242-
./autogen.sh
243-
244242
# Configure this DISTSRC for $HOST
245243
# shellcheck disable=SC2086
246-
env CONFIG_SITE="${BASEPREFIX}/${HOST}/share/config.site" \
247-
./configure --prefix=/ \
248-
--disable-ccache \
249-
--disable-maintainer-mode \
250-
--disable-dependency-tracking \
251-
${CONFIGFLAGS} \
252-
${HOST_CFLAGS:+CFLAGS="${HOST_CFLAGS}"} \
253-
${HOST_CXXFLAGS:+CXXFLAGS="${HOST_CXXFLAGS}"} \
254-
${HOST_LDFLAGS:+LDFLAGS="${HOST_LDFLAGS}"}
255-
256-
sed -i.old 's/-lstdc++ //g' config.status libtool
244+
env CFLAGS="${HOST_CFLAGS}" CXXFLAGS="${HOST_CXXFLAGS}" LDFLAGS="${HOST_LDFLAGS}" \
245+
cmake -S . -B build \
246+
--toolchain "${BASEPREFIX}/${HOST}/toolchain.cmake" \
247+
-DWITH_CCACHE=OFF \
248+
${CONFIGFLAGS}
257249

258250
# Build Bitcoin Core
259-
make --jobs="$JOBS" ${V:+V=1}
251+
cmake --build build -j "$JOBS" ${V:+--verbose}
260252

261253
# Check that symbol/security checks tools are sane.
262-
make test-security-check ${V:+V=1}
254+
cmake --build build --target test-security-check ${V:+--verbose}
263255
# Perform basic security checks on a series of executables.
264-
make -C src --jobs=1 check-security ${V:+V=1}
256+
cmake --build build -j 1 --target check-security ${V:+--verbose}
265257
# Check that executables only contain allowed version symbols.
266-
make -C src --jobs=1 check-symbols ${V:+V=1}
258+
cmake --build build -j 1 --target check-symbols ${V:+--verbose}
267259

268260
mkdir -p "$OUTDIR"
269261

270262
# Make the os-specific installers
271263
case "$HOST" in
272264
*mingw*)
273-
make deploy ${V:+V=1} BITCOIN_WIN_INSTALLER="${OUTDIR}/${DISTNAME}-win64-setup-unsigned.exe"
265+
cmake --build build -j "$JOBS" -t deploy ${V:+--verbose}
266+
mv build/bitcoin-win64-setup.exe "${OUTDIR}/${DISTNAME}-win64-setup-unsigned.exe"
274267
;;
275268
esac
276269

@@ -282,20 +275,25 @@ mkdir -p "$DISTSRC"
282275
# Install built Bitcoin Core to $INSTALLPATH
283276
case "$HOST" in
284277
*darwin*)
285-
make install-strip DESTDIR="${INSTALLPATH}" ${V:+V=1}
278+
# This workaround can be dropped for CMake >= 3.27.
279+
# See the upstream commit 689616785f76acd844fd448c51c5b2a0711aafa2.
280+
find build -name 'cmake_install.cmake' -exec sed -i 's| -u -r | |g' {} +
281+
282+
cmake --install build --strip --prefix "${INSTALLPATH}" ${V:+--verbose}
286283
;;
287284
*)
288-
make install DESTDIR="${INSTALLPATH}" ${V:+V=1}
285+
cmake --install build --prefix "${INSTALLPATH}" ${V:+--verbose}
289286
;;
290287
esac
291288

292289
case "$HOST" in
293290
*darwin*)
294-
make deploydir ${V:+V=1}
291+
cmake --build build --target deploy ${V:+--verbose}
292+
mv build/dist/Bitcoin-Core.zip "${OUTDIR}/${DISTNAME}-${HOST}-unsigned.zip"
295293
mkdir -p "unsigned-app-${HOST}"
296294
cp --target-directory="unsigned-app-${HOST}" \
297295
contrib/macdeploy/detached-sig-create.sh
298-
mv --target-directory="unsigned-app-${HOST}" dist
296+
mv --target-directory="unsigned-app-${HOST}" build/dist
299297
(
300298
cd "unsigned-app-${HOST}"
301299
find . -print0 \
@@ -304,23 +302,18 @@ mkdir -p "$DISTSRC"
304302
| gzip -9n > "${OUTDIR}/${DISTNAME}-${HOST}-unsigned.tar.gz" \
305303
|| ( rm -f "${OUTDIR}/${DISTNAME}-${HOST}-unsigned.tar.gz" && exit 1 )
306304
)
307-
make deploy ${V:+V=1} OSX_ZIP="${OUTDIR}/${DISTNAME}-${HOST}-unsigned.zip"
308305
;;
309306
esac
310307
(
311308
cd installed
312309

313-
# Prune libtool and object archives
314-
find . -name "lib*.la" -delete
315-
find . -name "lib*.a" -delete
316-
317310
case "$HOST" in
318311
*darwin*) ;;
319312
*)
320313
# Split binaries from their debug symbols
321314
{
322315
find "${DISTNAME}/bin" -type f -executable -print0
323-
} | xargs -0 -P"$JOBS" -I{} "${DISTSRC}/contrib/devtools/split-debug.sh" {} {} {}.dbg
316+
} | xargs -0 -P"$JOBS" -I{} "${DISTSRC}/build/split-debug.sh" {} {} {}.dbg
324317
;;
325318
esac
326319

0 commit comments

Comments
 (0)