From 2b6f2286b11169bba66be4dfc8b6547924ef2243 Mon Sep 17 00:00:00 2001 From: Ben Grande Date: Fri, 17 Jan 2025 11:35:38 +0100 Subject: [PATCH] feat: build Bitcoin with Cmake Fixes: https://github.com/ben-grande/qusal/issues/102 --- salt/sys-bitcoin/configure-builder-source.sls | 92 +++++++++---------- salt/sys-bitcoin/install-source.sls | 12 +-- 2 files changed, 51 insertions(+), 53 deletions(-) diff --git a/salt/sys-bitcoin/configure-builder-source.sls b/salt/sys-bitcoin/configure-builder-source.sls index cd6661c..0ab8fbb 100644 --- a/salt/sys-bitcoin/configure-builder-source.sls +++ b/salt/sys-bitcoin/configure-builder-source.sls @@ -1,5 +1,5 @@ {# -SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. +SPDX-FileCopyrightText: 2024 - 2025 Benjamin Grande M. S. SPDX-License-Identifier: AGPL-3.0-or-later #} @@ -49,57 +49,55 @@ include: - cwd: /home/user/src/bitcoin - runas: user -"{{ slsdotpath }}-source-build-autogen": - cmd.run: - - require: - - cmd: "{{ slsdotpath }}-source-git-checkout-tag-{{ bitcoin_tag }}" - - name: ./autogen.sh - - cwd: /home/user/src/bitcoin - - runas: user - "{{ slsdotpath }}-source-build-configure": cmd.run: - require: - - cmd: "{{ slsdotpath }}-source-build-autogen" - - env: - - CXX: "clang++" - - CC: "clang" + - cmd: "{{ slsdotpath }}-source-git-checkout-tag-{{ bitcoin_tag }}" - name: | - ./configure \ - --prefix=/home/user/bitcoin-build \ - --disable-maintainer-mode \ - --disable-tests \ - --disable-bench \ - --disable-fuzz-binary \ - --disable-shared \ - --disable-dependency-tracking \ - --without-miniupnpc \ - --without-natpmp \ - --without-bdb \ - --without-libs + cmake \ + -B /home/user/bitcoin-build \ + -DCMAKE_CXX_COMPILER=clang++ \ + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g0" \ + -DCMAKE_C_COMPILER=clang \ + -DBUILD_BENCH=OFF \ + -DBUILD_CLI=ON \ + -DBUILD_DAEMON=ON \ + -DBUILD_FOR_FUZZING=OFF \ + -DBUILD_GUI=ON \ + -DBUILD_SHARED_LIBS=OFF \ + -DBUILD_TESTS=OFF \ + -DBUILD_TX=ON \ + -DBUILD_UTIL=ON \ + -DBUILD_UTIL_CHAINSTATE=ON \ + -DBUILD_WALLET_TOOL=ON \ + -DENABLE_EXTERNAL_SIGNER=ON \ + -DENABLE_HARDENING=ON \ + -DENABLE_WALLET=ON \ + -DWITH_BDB=OFF \ + -DWITH_CCACHE=ON \ + -DWITH_MINIUPNPC=OFF \ + -DWITH_SQLITE=ON \ + -DWITH_USDT=OFF \ + -DWITH_ZMQ=ON - cwd: /home/user/src/bitcoin - runas: user -"{{ slsdotpath }}-source-build-make-clean": +"{{ slsdotpath }}-source-build-execute": cmd.run: - require: - cmd: "{{ slsdotpath }}-source-build-configure" - - name: make clean - - cwd: /home/user/src/bitcoin - - runas: user - -"{{ slsdotpath }}-source-build-make": - cmd.run: - - require: - - cmd: "{{ slsdotpath }}-source-build-make-clean" - - name: make -j "$(($(nproc)+1))" + - name: | + cmake \ + --build /home/user/bitcoin-build \ + --parallel "$(($(nproc)+1))" \ + --clean-first - cwd: /home/user/src/bitcoin - runas: user "{{ slsdotpath }}-source-build-gen-manpages": cmd.run: - require: - - cmd: "{{ slsdotpath }}-source-build-make" + - cmd: "{{ slsdotpath }}-source-build-execute" - name: ./contrib/devtools/gen-manpages.py - cwd: /home/user/src/bitcoin - runas: user @@ -107,23 +105,23 @@ include: "{{ slsdotpath }}-source-build-gen-bitcoin-conf": cmd.run: - require: - - cmd: "{{ slsdotpath }}-source-build-make" + - cmd: "{{ slsdotpath }}-source-build-execute" - name: ./contrib/devtools/gen-bitcoin-conf.sh - cwd: /home/user/src/bitcoin - runas: user -"{{ slsdotpath }}-source-build-make-install": +"{{ slsdotpath }}-source-build-install": cmd.run: - require: - - cmd: "{{ slsdotpath }}-source-build-make" - - name: make install + - cmd: "{{ slsdotpath }}-source-build-execute" + - name: cmake --install /home/user/bitcoin-build - cwd: /home/user/src/bitcoin - runas: user "{{ slsdotpath }}-source-readme": cmd.run: - require: - - cmd: "{{ slsdotpath }}-source-build-make-install" + - cmd: "{{ slsdotpath }}-source-build-install" - name: | \mkdir -p -- share/bitcoin \cp -v -- ~/src/bitcoin/README.md share/bitcoin/ @@ -133,7 +131,7 @@ include: "{{ slsdotpath }}-source-share-examples": cmd.run: - require: - - cmd: "{{ slsdotpath }}-source-build-make-install" + - cmd: "{{ slsdotpath }}-source-build-install" - name: | \cp -v -- ~/src/bitcoin/share/examples/bitcoin.conf bitcoin.conf - cwd: /home/user/bitcoin-build @@ -142,7 +140,7 @@ include: "{{ slsdotpath }}-source-shell-completion": cmd.run: - require: - - cmd: "{{ slsdotpath }}-source-build-make-install" + - cmd: "{{ slsdotpath }}-source-build-install" - name: | \mkdir -p -- share/bash-completion/completions/ \cp -v -- ~/src/bitcoin/contrib/completions/bash/* share/bash-completion/completions/ @@ -152,17 +150,17 @@ include: "{{ slsdotpath }}-source-rpcauth": cmd.run: - require: - - cmd: "{{ slsdotpath }}-source-build-make-install" + - cmd: "{{ slsdotpath }}-source-build-install" - name: | \mkdir -p -- share/rpcauth \cp -v -- ~/src/bitcoin/share/rpcauth/rpcauth.py share/rpcauth/ - cwd: /home/user/bitcoin-build - runas: user -"{{ slsdotpath }}-source-rpcauth": +"{{ slsdotpath }}-source-gui-icons": cmd.run: - require: - - cmd: "{{ slsdotpath }}-source-build-make-install" + - cmd: "{{ slsdotpath }}-source-build-install" - name: | \mkdir -p -- share/icons/hicolor/scalable/apps/ \cp -v -- ~/src/bitcoin/src/qt/res/src/bitcoin.svg share/icons/hicolor/scalable/apps/ @@ -172,7 +170,7 @@ include: "{{ slsdotpath }}-source-copy-files-to-template": cmd.run: - require: - - cmd: "{{ slsdotpath }}-source-build-make" + - cmd: "{{ slsdotpath }}-source-build-install" - name: qrexec-client-vm -T -- @default qusal.InstallBitcoin /usr/lib/qubes/qfile-agent /home/user/bitcoin-build/* - runas: user diff --git a/salt/sys-bitcoin/install-source.sls b/salt/sys-bitcoin/install-source.sls index 1676418..600ac8c 100644 --- a/salt/sys-bitcoin/install-source.sls +++ b/salt/sys-bitcoin/install-source.sls @@ -1,5 +1,5 @@ {# -SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. +SPDX-FileCopyrightText: 2024 - 2025 Benjamin Grande M. S. SPDX-License-Identifier: AGPL-3.0-or-later #} @@ -21,19 +21,19 @@ include: - skip_suggestions: True - setopt: "install_weak_deps=False" - pkgs: - - clang + - cmake + - clang-16 - ccache - help2man {% set pkg = { 'Debian': { - 'pkg': ['build-essential', 'libtool', 'autotools-dev', 'automake', - 'pkg-config', 'bsdmainutils', 'python3', 'libevent-dev', + 'pkg': ['build-essential', 'pkg-config', 'python3', 'libevent-dev', 'libboost-dev', 'libsqlite3-dev', 'libzmq3-dev'], }, 'RedHat': { - 'pkg': ['gcc-c++', 'libtool', 'make', 'autoconf', 'automake', 'python3', - 'libevent-devel', 'boost-devel', 'sqlite-devel', 'zeromq-devel'], + 'pkg': ['gcc-c++', 'make', 'python3', 'libevent-devel', 'boost-devel', + 'sqlite-devel', 'zeromq-devel'], }, }.get(grains.os_family) -%}