diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d4a411a7..9209c2c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,807 +5,432 @@ # ############################################################################### -name: Continuous Integration Build +name: Continuous Integration on: [ pull_request, push, workflow_dispatch ] jobs: - autotools: + gnu: strategy: fail-fast: false matrix: include: - - os: ubuntu-24.04 - cxx: "clang++-18" + - image: macos-latest + config: "release" link: "dynamic" - optimization: "debug" - assert: "debug" - coverage: "nocov" - detectcpuflags: "ignore" + cc: "clang" + cxx: "clang++" + flags: "" + coverage: "" boost: "--build-boost" - llvm: "" secp256k1: "--build-secp256k1" - cc: "clang-18" - flags: "-Og -fPIE" options: "--enable-isystem" - packager: "apt" - packages: "" - - os: ubuntu-24.04 - cxx: "clang++-18" + - image: macos-latest + config: "release" link: "static" - optimization: "size" - assert: "ndebug" - coverage: "nocov" - detectcpuflags: "ignore" + cc: "clang" + cxx: "clang++" + flags: "" + coverage: "" boost: "--build-boost" - llvm: "" secp256k1: "--build-secp256k1" - cc: "clang-18" - flags: "-Os -fPIE" options: "--enable-isystem" - packager: "apt" - packages: "" - - os: ubuntu-24.04 - cxx: "g++-12" + - image: ubuntu-24.04 + config: "debug" link: "dynamic" - optimization: "size" - assert: "ndebug" - coverage: "nocov" - detectcpuflags: "ignore" + cc: "clang-18" + cxx: "clang++-18" + flags: "" + coverage: "" boost: "--build-boost" - llvm: "" secp256k1: "--build-secp256k1" - cc: "gcc-12" - flags: "-Os -fPIE" options: "--enable-isystem" - packager: "apt" - packages: "" - - os: ubuntu-24.04 - cxx: "g++" + - image: ubuntu-24.04 + config: "release" link: "static" - optimization: "size" - assert: "ndebug" - coverage: "cov" - detectcpuflags: "detect" + cc: "clang-18" + cxx: "clang++-18" + flags: "" + coverage: "" boost: "--build-boost" - llvm: "" secp256k1: "--build-secp256k1" - cc: "gcc" - flags: "-Os -g --coverage -fPIE" options: "--enable-isystem" - packager: "apt" - packages: "lcov" - - os: macos-latest - cxx: "clang++" + - image: ubuntu-24.04 + config: "release" link: "dynamic" - optimization: "size" - assert: "ndebug" - coverage: "nocov" - detectcpuflags: "ignore" + cc: "gcc-12" + cxx: "g++-12" + flags: "" + coverage: "" boost: "--build-boost" - llvm: "" secp256k1: "--build-secp256k1" - cc: "clang" - flags: "-Os -fPIE" options: "--enable-isystem" - packager: "brew" - packages: "" - - os: macos-latest - cxx: "clang++" + - image: ubuntu-24.04 + config: "debug" link: "static" - optimization: "size" - assert: "ndebug" - coverage: "nocov" - detectcpuflags: "ignore" + cc: "gcc" + cxx: "g++" + flags: "--coverage" + coverage: "lcov" boost: "--build-boost" - llvm: "" secp256k1: "--build-secp256k1" - cc: "clang" - flags: "-Os -fvisibility=hidden -fPIE" options: "--enable-isystem" - packager: "brew" - packages: "" - - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.image }} env: CC: '${{ matrix.cc }}' CXX: '${{ matrix.cxx }}' CFLAGS: '${{ matrix.flags }}' CXXFLAGS: '${{ matrix.flags }}' - CI_REPOSITORY: '${{ github.repository }}' steps: - name: Checkout repository uses: actions/checkout@v6 - - name: Prepare toolchain [generic] + - name: Sources directory path assignment + shell: bash run: | - git config --global init.defaultBranch master + cd .. + echo SRC_PATH="$(pwd)" >> $GITHUB_ENV - - name: Prepare toolchain [apt] - if: ${{ matrix.packager == 'apt' }} + - name: Prepare toolchain [linux] + if: ${{ startsWith(matrix.image, 'ubuntu') }} + shell: bash run: | sudo apt-get update - sudo apt-get install git build-essential autoconf automake libtool pkg-config ${{ matrix.packages }} - - - name: Prepare toolchain [brew] - if: ${{ matrix.packager == 'brew' }} - run: | - brew install autoconf automake libtool ${{ matrix.packages }} - if [[ -n "${{ matrix.llvm }}" ]]; then - echo "PATH=/opt/homebrew/opt/${{ matrix.llvm }}/bin:$PATH" >> $GITHUB_ENV + sudo apt-get install git build-essential autoconf automake libtool pkg-config ${{ matrix.package || '' }} + if [[ "${{ matrix.coverage }}" == "lcov" ]]; then + sudo apt-get install lcov fi - - name: Determine CPU flags + - name: Prepare toolchain [macos] + if: ${{ startsWith(matrix.image, 'macos') }} shell: bash run: | - if [[ -n $(cat /proc/cpuinfo | grep flags | grep " sse4_1 ") ]]; then - echo "CPU_SUPPORT_SSE41=--enable-sse41" >> $GITHUB_ENV - fi - - if [[ -n $(cat /proc/cpuinfo | grep flags | grep " avx " | grep " avx2 ") ]]; then - echo "CPU_SUPPORT_AVX2=--enable-avx2" >> $GITHUB_ENV - fi - - if [[ -n $(cat /proc/cpuinfo | grep flags | grep " avx512bw ") ]]; then - echo "CPU_SUPPORT_AVX512=--enable-avx512" >> $GITHUB_ENV - fi - - if [[ -n $(cat /proc/cpuinfo | grep flags | grep " sha_ni ") ]]; then - echo "CPU_SUPPORT_SHANI=--enable-shani" >> $GITHUB_ENV - fi - - if [[ ${{ matrix.detectcpuflags }} == 'detect' ]]; then - echo "CPU_SUPPORTED_FLAGS='$CPU_SUPPORT_SSE41 $CPU_SUPPORT_AVX2 $CPU_SUPPORT_AVX512 $CPU_SUPPORT_SHANI'" >> $GITHUB_ENV + brew install autoconf automake libtool ${{ matrix.package || '' }} + if [[ -n "${{ matrix.llvm }}" ]]; then + echo "PATH=/opt/homebrew/opt/${{ matrix.llvm }}/bin:${PATH}" >> $GITHUB_ENV fi - - name: Denormalize parameterization + - name: Environmental Computation shell: bash run: | - WORKSPACE_SUBPATH="${GITHUB_WORKSPACE%libbitcoin-node}" - echo "LIBBITCOIN_SRC_PATH=${WORKSPACE_SUBPATH}" >> $GITHUB_ENV - if [[ ${{ matrix.assert }} == 'ndebug' ]]; then - echo "ASSERT_NDEBUG=--enable-ndebug" >> $GITHUB_ENV - else - echo "ASSERT_NDEBUG=--disable-ndebug" >> $GITHUB_ENV - fi - if [[ ${{ matrix.link }} == 'dynamic' ]]; then - echo "LINKAGE=--disable-static" >> $GITHUB_ENV - else - echo "LINKAGE=--disable-shared" >> $GITHUB_ENV - fi - if [[ ${{ matrix.link }} == 'dynamic' ]]; then - echo "LDFLAGS=-Wl,-rpath,${WORKSPACE_SUBPATH}prefix/lib" >> $GITHUB_ENV + if [[ "${{ matrix.link }}" == "dynamic" ]]; then + echo "LDFLAGS=-Wl,-rpath,${{ env.SRC_PATH }}/prefix/lib" >> $GITHUB_ENV fi - - name: Display Compiler details + - name: Execute installation shell: bash - run: | - ${CC} -v - ${CXX} -v - - - name: Display CPU details - if: ${{ (runner.os == 'Linux') }} - shell: bash - run: | - lscpu - - - name: Execute install.sh run: > - ./install.sh - --build-dir=${{ env.LIBBITCOIN_SRC_PATH }} ${{ matrix.options }} - --prefix=${{ env.LIBBITCOIN_SRC_PATH }}prefix - ${{ env.LINKAGE }} - ${{ env.ASSERT_NDEBUG }} - ${{ env.CPU_SUPPORTED_FLAGS }} + ./builds/gnu/install-gnu.sh + --build-use-local-src + --build-src-dir="${{ env.SRC_PATH }}" + --prefix="${{ env.SRC_PATH }}/prefix" + --build-obj-dir="obj" + --build-obj-dir-relative + --build-config="${{ matrix.config }}" + --build-link="${{ matrix.link }}" ${{ matrix.boost }} ${{ matrix.secp256k1 }} + ${{ matrix.options }} - - name: Coveralls Calculation - if: ${{ matrix.coverage == 'cov' }} + - name: Coverage calculation + if: ${{ matrix.coverage == 'lcov' }} + shell: bash run: | lcov --ignore-errors version,gcov,mismatch,mismatch --directory . --capture --output-file coverage.info - lcov --ignore-errors unused --remove coverage.info "/usr/*" "${{ env.LIBBITCOIN_SRC_PATH }}prefix/*" "${{ github.workspace }}/examples/*" "${{ github.workspace }}/test/*" --output-file coverage.info - lcov --list coverage.info + lcov --ignore-errors unused --remove coverage.info "${{ env.SRC_PATH }}/prefix/*" "${{ github.workspace }}/examples/*" "${{ github.workspace }}/test/*" --output-file coverage.info - - name: Coveralls.io Upload - if: ${{ matrix.coverage == 'cov' }} - uses: coverallsapp/github-action@v2.3.0 + - name: Coveralls.io upload + if: ${{ matrix.coverage == 'lcov' }} + uses: coverallsapp/github-action@v2.3.6 with: format: lcov files: "./coverage.info" github-token: ${{ secrets.github_token }} - - name: Failure display available binaries - if: ${{ failure() }} - run: | - ls -la /usr/bin - - - name: Failure display selected compiler version - if: ${{ failure() }} - run: | - ${CC} -v - ${CXX} -v - - - name: Failure display default compiler version - if: ${{ failure() }} - run: | - clang -v - gcc -v - - - name: Failure display env - if: ${{ failure() }} - run: | - env - - - name: Failure list libdir - if: ${{ failure() }} - run: | - ls -la ${{ env.LIBBITCOIN_SRC_PATH }}prefix/lib - - - name: Failure display boost bootstrap.log [--build-boost] - if: ${{ failure() && (matrix.boost == '--build-boost') }} - run: | - cat ${{ github.workspace }}/build/build-*/bootstrap.log - - - - name: Failure display otool output - if: ${{ failure() && startsWith(matrix.os, 'macos') }} - run: | - otool -L ${{ github.workspace }}/test/.libs/libbitcoin-node-test - - - name: Failure display DYLD_PRINT_LIBRARIES - if: ${{ failure() && startsWith(matrix.os, 'macos') }} - run: | - DYLD_PRINT_LIBRARIES=1 ${{ github.workspace }}/test/.libs/libbitcoin-node-test - - - name: Failure display pkgconfig - if: ${{ failure() }} - run: | - ls ${{ env.LIBBITCOIN_SRC_PATH }}prefix/lib/pkgconfig/ - cat ${{ env.LIBBITCOIN_SRC_PATH }}prefix/lib/pkgconfig/*.pc - cmake: - strategy: fail-fast: false matrix: include: - - os: ubuntu-24.04 - cxx: "clang++-18" + - image: macos-latest + config: "release" link: "dynamic" - optimization: "debug" - assert: "debug" - coverage: "nocov" - detectcpuflags: "ignore" + cc: "clang" + cxx: "clang++" + flags: "-DNDEBUG" + coverage: "" boost: "--build-boost" - llvm: "" secp256k1: "--build-secp256k1" - cc: "clang-18" - flags: "-Og -fPIE" - options: "" - packager: "apt" - packages: "" + options: "--verbose" - - os: ubuntu-24.04 - cxx: "clang++-18" + - image: macos-latest + config: "release" link: "static" - optimization: "size" - assert: "ndebug" - coverage: "nocov" - detectcpuflags: "ignore" + cc: "clang" + cxx: "clang++" + flags: "" + coverage: "" boost: "--build-boost" - llvm: "" secp256k1: "--build-secp256k1" - cc: "clang-18" - flags: "-Os -fPIE" - options: "" - packager: "apt" - packages: "" + options: "--verbose" - - os: ubuntu-24.04 - cxx: "g++-12" + - image: ubuntu-24.04 + config: "debug" link: "dynamic" - optimization: "size" - assert: "ndebug" - coverage: "nocov" - detectcpuflags: "ignore" + cc: "clang-18" + cxx: "clang++-18" + flags: "" + coverage: "" boost: "--build-boost" - llvm: "" secp256k1: "--build-secp256k1" - cc: "gcc-12" - flags: "-Os -fPIE" options: "" - packager: "apt" - packages: "" - - os: ubuntu-24.04 - cxx: "g++-12" + - image: ubuntu-24.04 + config: "release" link: "static" - optimization: "size" - assert: "ndebug" - coverage: "nocov" - detectcpuflags: "ignore" + cc: "clang-18" + cxx: "clang++-18" + flags: "" + coverage: "" boost: "--build-boost" - llvm: "" secp256k1: "--build-secp256k1" - cc: "gcc-12" - flags: "-Os -fPIE" options: "" - packager: "apt" - packages: "" - - os: macos-latest - cxx: "clang++" + - image: ubuntu-24.04 + config: "release" link: "dynamic" - optimization: "size" - assert: "ndebug" - coverage: "nocov" - detectcpuflags: "ignore" + cc: "gcc-12" + cxx: "g++-12" + flags: "" + coverage: "" boost: "--build-boost" - llvm: "" secp256k1: "--build-secp256k1" - cc: "clang" - flags: "-Os -fPIE" options: "" - packager: "brew" - packages: "" - - os: macos-latest - cxx: "clang++" + - image: ubuntu-24.04 + config: "debug" link: "static" - optimization: "size" - assert: "ndebug" - coverage: "nocov" - detectcpuflags: "ignore" + cc: "gcc" + cxx: "g++" + flags: "" + coverage: "" boost: "--build-boost" - llvm: "" secp256k1: "--build-secp256k1" - cc: "clang" - flags: "-Os -fvisibility=hidden -fPIE" options: "" - packager: "brew" - packages: "" - - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.image }} env: CC: '${{ matrix.cc }}' CXX: '${{ matrix.cxx }}' CFLAGS: '${{ matrix.flags }}' CXXFLAGS: '${{ matrix.flags }}' - CI_REPOSITORY: '${{ github.repository }}' steps: - name: Checkout repository uses: actions/checkout@v6 - - name: Prepare toolchain [generic] + - name: Sources directory path assignment + shell: bash run: | - git config --global init.defaultBranch master + cd .. + echo SRC_PATH="$(pwd)" >> $GITHUB_ENV - - name: Prepare toolchain [apt] - if: ${{ matrix.packager == 'apt' }} + - name: Prepare toolchain [linux] + if: ${{ startsWith(matrix.image, 'ubuntu') }} + shell: bash run: | sudo apt-get update - sudo apt-get install git build-essential autoconf automake libtool pkg-config ${{ matrix.packages }} - - - name: Prepare toolchain [brew] - if: ${{ matrix.packager == 'brew' }} - run: | - brew install autoconf automake libtool ${{ matrix.packages }} - if [[ -n "${{ matrix.llvm }}" ]]; then - echo "PATH=/opt/homebrew/opt/${{ matrix.llvm }}/bin:$PATH" >> $GITHUB_ENV + sudo apt-get install git build-essential autoconf automake libtool pkg-config ${{ matrix.package || '' }} + if [[ "${{ matrix.coverage }}" == "lcov" ]]; then + sudo apt-get install lcov fi - - name: Determine CPU flags + - name: Prepare toolchain [macos] + if: ${{ startsWith(matrix.image, 'macos') }} shell: bash run: | - if [[ -n $(cat /proc/cpuinfo | grep flags | grep " sse4_1 ") ]]; then - echo "CPU_SUPPORT_SSE41=-Denable-sse41=on" >> $GITHUB_ENV - fi - - if [[ -n $(cat /proc/cpuinfo | grep flags | grep " avx " | grep " avx2 ") ]]; then - echo "CPU_SUPPORT_AVX2=-Denable-avx2=on" >> $GITHUB_ENV - fi - - if [[ -n $(cat /proc/cpuinfo | grep flags | grep " avx512bw ") ]]; then - echo "CPU_SUPPORT_AVX512=-Denable-avx512=on" >> $GITHUB_ENV - fi - - if [[ -n $(cat /proc/cpuinfo | grep flags | grep " sha_ni ") ]]; then - echo "CPU_SUPPORT_SHANI=-Denable-shani=on" >> $GITHUB_ENV - fi - - if [[ ${{ matrix.detectcpuflags }} == 'detect' ]]; then - echo "CPU_SUPPORTED_FLAGS='$CPU_SUPPORT_SSE41 $CPU_SUPPORT_AVX2 $CPU_SUPPORT_AVX512 $CPU_SUPPORT_SHANI'" >> $GITHUB_ENV + brew install autoconf automake libtool ${{ matrix.package || '' }} + if [[ -n "${{ matrix.llvm }}" ]]; then + echo "PATH=/opt/homebrew/opt/${{ matrix.llvm }}/bin:${PATH}" >> $GITHUB_ENV fi - - name: Denormalize parameterization + - name: Environmental Computation shell: bash run: | - WORKSPACE_SUBPATH="${GITHUB_WORKSPACE%libbitcoin-node}" - echo "LIBBITCOIN_SRC_PATH=${WORKSPACE_SUBPATH}" >> $GITHUB_ENV - if [[ ${{ matrix.packager }} == 'brew' ]]; then - echo "CMAKE_LIBRARY_PATH=/usr/local/lib" >> $GITHUB_ENV - fi - if [[ ${{ matrix.assert }} == 'ndebug' ]]; then - echo "ASSERT_NDEBUG=--enable-ndebug" >> $GITHUB_ENV - else - echo "ASSERT_NDEBUG=--disable-ndebug" >> $GITHUB_ENV - fi - if [[ ${{ matrix.link }} == 'dynamic' ]]; then - echo "LINKAGE=--disable-static" >> $GITHUB_ENV - else - echo "LINKAGE=--disable-shared" >> $GITHUB_ENV - fi - if [[ ${{ matrix.link }} == 'dynamic' ]]; then - echo "LDFLAGS=-Wl,-rpath,${WORKSPACE_SUBPATH}prefix/lib" >> $GITHUB_ENV + if [[ "${{ matrix.link }}" == "dynamic" ]]; then + echo "LDFLAGS=-Wl,-rpath,${{ env.SRC_PATH }}/prefix/lib" >> $GITHUB_ENV fi - - name: Display Compiler details - shell: bash - run: | - ${CC} -v - ${CXX} -v - - - name: Display CPU details - if: ${{ (runner.os == 'Linux') }} + - name: Execute installation shell: bash - run: | - lscpu - - - name: Execute install-cmake.sh run: > - ./install-cmake.sh - --build-dir=${{ env.LIBBITCOIN_SRC_PATH }} ${{ matrix.options }} - --prefix=${{ env.LIBBITCOIN_SRC_PATH }}prefix - ${{ env.LINKAGE }} - ${{ env.ASSERT_NDEBUG }} - ${{ env.CPU_SUPPORTED_FLAGS }} + ./builds/cmake/install-cmake.sh + --build-use-local-src + --build-src-dir="${{ env.SRC_PATH }}" + --prefix="${{ env.SRC_PATH }}/prefix" + --build-obj-dir="obj" + --build-obj-dir-relative + --build-config="${{ matrix.config }}" + --build-link="${{ matrix.link }}" ${{ matrix.boost }} ${{ matrix.secp256k1 }} + ${{ matrix.options }} - - name: Coveralls Calculation - if: ${{ matrix.coverage == 'cov' }} + - name: Coverage calculation + if: ${{ matrix.coverage == 'lcov' }} + shell: bash run: | lcov --ignore-errors version,gcov,mismatch,mismatch --directory . --capture --output-file coverage.info - lcov --ignore-errors unused --remove coverage.info "/usr/*" "${{ env.LIBBITCOIN_SRC_PATH }}prefix/*" "${{ github.workspace }}/examples/*" "${{ github.workspace }}/test/*" --output-file coverage.info - lcov --list coverage.info + lcov --ignore-errors unused --remove coverage.info "${{ env.SRC_PATH }}/prefix/*" "${{ github.workspace }}/examples/*" "${{ github.workspace }}/test/*" --output-file coverage.info - - name: Coveralls.io Upload - if: ${{ matrix.coverage == 'cov' }} - uses: coverallsapp/github-action@v2.3.0 + - name: Coveralls.io upload + if: ${{ matrix.coverage == 'lcov' }} + uses: coverallsapp/github-action@v2.3.6 with: format: lcov files: "./coverage.info" github-token: ${{ secrets.github_token }} - - name: Failure display available binaries - if: ${{ failure() }} - run: | - ls -la /usr/bin - - - name: Failure display selected compiler version - if: ${{ failure() }} - run: | - ${CC} -v - ${CXX} -v - - - name: Failure display default compiler version - if: ${{ failure() }} - run: | - clang -v - gcc -v - - - name: Failure display env - if: ${{ failure() }} - run: | - env - - - name: Failure list libdir - if: ${{ failure() }} - run: | - ls -la ${{ env.LIBBITCOIN_SRC_PATH }}prefix/lib - - - name: Failure display boost bootstrap.log [--build-boost] - if: ${{ failure() && (matrix.boost == '--build-boost') }} - run: | - cat ${{ github.workspace }}/build/build-*/bootstrap.log - - - - name: Failure display otool output - if: ${{ failure() && startsWith(matrix.os, 'macos') }} - run: | - otool -L ${{ github.workspace }}/test/.libs/libbitcoin-node-test - - - name: Failure display DYLD_PRINT_LIBRARIES - if: ${{ failure() && startsWith(matrix.os, 'macos') }} - run: | - DYLD_PRINT_LIBRARIES=1 ${{ github.workspace }}/test/.libs/libbitcoin-node-test - - - name: Failure display pkgconfig - if: ${{ failure() }} - run: | - ls ${{ env.LIBBITCOIN_SRC_PATH }}prefix/lib/pkgconfig/ - cat ${{ env.LIBBITCOIN_SRC_PATH }}prefix/lib/pkgconfig/*.pc - - - name: Failure display cmake specific libraries - if: ${{ failure() }} - run: | - ls ${{ env.LIBBITCOIN_SRC_PATH }}prefix/lib/cmake - - - name: Failure display cmake LastTest.log - if: ${{ failure() }} - run: | - cat ${{ github.workspace }}/Testing/Temporary/LastTest.log - - preset: - + presets: strategy: fail-fast: false matrix: include: - - os: ubuntu-24.04 + - image: ubuntu-24.04 preset: "nix-gnu-debug-shared" + cc: "clang-18" cxx: "clang++-18" - link: "dynamic" - optimization: "debug" - assert: "debug" - coverage: "nocov" - detectcpuflags: "ignore" + flags: "" + coverage: "" boost: "--build-boost" - llvm: "" secp256k1: "--build-secp256k1" - cc: "clang-18" - flags: "-Og -fPIE" options: "" - packager: "apt" - packages: "" - - os: ubuntu-24.04 + - image: ubuntu-24.04 preset: "nix-gnu-release-static" + cc: "clang-18" cxx: "clang++-18" - link: "static" - optimization: "size" - assert: "ndebug" - coverage: "nocov" - detectcpuflags: "ignore" + flags: "" + coverage: "" boost: "--build-boost" - llvm: "" secp256k1: "--build-secp256k1" - cc: "clang-18" - flags: "-Os -fPIE" options: "" - packager: "apt" - packages: "" - - os: ubuntu-24.04 + - image: ubuntu-24.04 preset: "nix-gnu-release-shared" + cc: "gcc-12" cxx: "g++-12" - link: "dynamic" - optimization: "size" - assert: "ndebug" - coverage: "nocov" - detectcpuflags: "ignore" + flags: "" + coverage: "" boost: "--build-boost" - llvm: "" secp256k1: "--build-secp256k1" - cc: "gcc-12" - flags: "-Os -fPIE" options: "" - packager: "apt" - packages: "" - - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.image }} env: CC: '${{ matrix.cc }}' CXX: '${{ matrix.cxx }}' CFLAGS: '${{ matrix.flags }}' CXXFLAGS: '${{ matrix.flags }}' - CI_REPOSITORY: '${{ github.repository }}' steps: - name: Checkout repository uses: actions/checkout@v6 - - name: Prepare toolchain [generic] + - name: Sources directory path assignment + shell: bash run: | - git config --global init.defaultBranch master + cd .. + echo SRC_PATH="$(pwd)" >> $GITHUB_ENV - - name: Prepare toolchain [apt] - if: ${{ matrix.packager == 'apt' }} + - name: Prepare toolchain [linux] + if: ${{ startsWith(matrix.image, 'ubuntu') }} + shell: bash run: | sudo apt-get update - sudo apt-get install git build-essential autoconf automake libtool pkg-config ${{ matrix.packages }} - - - name: Prepare toolchain [brew] - if: ${{ matrix.packager == 'brew' }} - run: | - brew install autoconf automake libtool ${{ matrix.packages }} - if [[ -n "${{ matrix.llvm }}" ]]; then - echo "PATH=/opt/homebrew/opt/${{ matrix.llvm }}/bin:$PATH" >> $GITHUB_ENV + sudo apt-get install git build-essential autoconf automake libtool pkg-config ${{ matrix.package || '' }} + if [[ "${{ matrix.coverage }}" == "lcov" ]]; then + sudo apt-get install lcov fi - - name: Determine CPU flags + - name: Prepare toolchain [macos] + if: ${{ startsWith(matrix.image, 'macos') }} shell: bash run: | - if [[ -n $(cat /proc/cpuinfo | grep flags | grep " sse4_1 ") ]]; then - echo "CPU_SUPPORT_SSE41=-Denable-sse41=on" >> $GITHUB_ENV - fi - - if [[ -n $(cat /proc/cpuinfo | grep flags | grep " avx " | grep " avx2 ") ]]; then - echo "CPU_SUPPORT_AVX2=-Denable-avx2=on" >> $GITHUB_ENV - fi - - if [[ -n $(cat /proc/cpuinfo | grep flags | grep " avx512bw ") ]]; then - echo "CPU_SUPPORT_AVX512=-Denable-avx512=on" >> $GITHUB_ENV - fi - - if [[ -n $(cat /proc/cpuinfo | grep flags | grep " sha_ni ") ]]; then - echo "CPU_SUPPORT_SHANI=-Denable-shani=on" >> $GITHUB_ENV - fi - - if [[ ${{ matrix.detectcpuflags }} == 'detect' ]]; then - echo "CPU_SUPPORTED_FLAGS='$CPU_SUPPORT_SSE41 $CPU_SUPPORT_AVX2 $CPU_SUPPORT_AVX512 $CPU_SUPPORT_SHANI'" >> $GITHUB_ENV + brew install autoconf automake libtool ${{ matrix.package || '' }} + if [[ -n "${{ matrix.llvm }}" ]]; then + echo "PATH=/opt/homebrew/opt/${{ matrix.llvm }}/bin:${PATH}" >> $GITHUB_ENV fi - - name: Denormalize parameterization + - name: Environmental Computation shell: bash run: | - WORKSPACE_SUBPATH="${GITHUB_WORKSPACE%libbitcoin-node}" - echo "LIBBITCOIN_SRC_PATH=${WORKSPACE_SUBPATH}" >> $GITHUB_ENV - if [[ ${{ matrix.packager }} == 'brew' ]]; then - echo "CMAKE_LIBRARY_PATH=/usr/local/lib" >> $GITHUB_ENV - fi - if [[ ${{ matrix.assert }} == 'ndebug' ]]; then - echo "ASSERT_NDEBUG=--enable-ndebug" >> $GITHUB_ENV - else - echo "ASSERT_NDEBUG=--disable-ndebug" >> $GITHUB_ENV - fi - if [[ ${{ matrix.link }} == 'dynamic' ]]; then - echo "LINKAGE=--disable-static" >> $GITHUB_ENV - else - echo "LINKAGE=--disable-shared" >> $GITHUB_ENV + if [[ "${{ matrix.preset }}" == *shared* ]]; then + echo "LDFLAGS=-Wl,-rpath,${{ env.SRC_PATH }}/prefix/lib" >> $GITHUB_ENV fi - if [[ ${{ matrix.link }} == 'dynamic' ]]; then - echo "LDFLAGS=-Wl,-rpath,${WORKSPACE_SUBPATH}prefix/${{ matrix.preset }}/lib" >> $GITHUB_ENV - fi - - - name: Display Compiler details - shell: bash - run: | - ${CC} -v - ${CXX} -v - - name: Display CPU details - if: ${{ (runner.os == 'Linux') }} + - name: Execute installation shell: bash - run: | - lscpu - - - name: Execute install-cmakepresets.sh run: > - ./install-cmakepresets.sh - --build-dir=${{ env.LIBBITCOIN_SRC_PATH }} ${{ matrix.options }} - --prefix=${{ env.LIBBITCOIN_SRC_PATH }}prefix/${{ matrix.preset }} - --preset=${{ matrix.preset }} - ${{ env.LINKAGE }} - ${{ env.ASSERT_NDEBUG }} - ${{ env.CPU_SUPPORTED_FLAGS }} + ./builds/cmake/install-presets.sh + --build-use-local-src + --build-src-dir="${{ env.SRC_PATH }}" + --build-preset="${{ matrix.preset }}" ${{ matrix.boost }} ${{ matrix.secp256k1 }} + ${{ matrix.options }} - - name: Coveralls Calculation - if: ${{ matrix.coverage == 'cov' }} + - name: Coverage calculation + if: ${{ matrix.coverage == 'lcov' }} + shell: bash run: | lcov --ignore-errors version,gcov,mismatch,mismatch --directory . --capture --output-file coverage.info - lcov --ignore-errors unused --remove coverage.info "/usr/*" "${{ env.LIBBITCOIN_SRC_PATH }}prefix/*" "${{ github.workspace }}/examples/*" "${{ github.workspace }}/test/*" --output-file coverage.info - lcov --list coverage.info + lcov --ignore-errors unused --remove coverage.info "${{ env.SRC_PATH }}/prefix/*" "${{ github.workspace }}/examples/*" "${{ github.workspace }}/test/*" --output-file coverage.info - - name: Coveralls.io Upload - if: ${{ matrix.coverage == 'cov' }} - uses: coverallsapp/github-action@v2.3.0 + - name: Coveralls.io upload + if: ${{ matrix.coverage == 'lcov' }} + uses: coverallsapp/github-action@v2.3.6 with: format: lcov files: "./coverage.info" github-token: ${{ secrets.github_token }} - - name: Failure display available binaries - if: ${{ failure() }} - run: | - ls -la /usr/bin - - - name: Failure display selected compiler version - if: ${{ failure() }} - run: | - ${CC} -v - ${CXX} -v - - - name: Failure display default compiler version - if: ${{ failure() }} - run: | - clang -v - gcc -v - - - name: Failure display env - if: ${{ failure() }} - run: | - env - - - name: Failure list libdir - if: ${{ failure() }} - run: | - ls -la ${{ env.LIBBITCOIN_SRC_PATH }}prefix/lib - - - name: Failure display boost bootstrap.log [--build-boost] - if: ${{ failure() && (matrix.boost == '--build-boost') }} - run: | - cat ${{ github.workspace }}/build/build-*/bootstrap.log - - - - name: Failure display otool output - if: ${{ failure() && startsWith(matrix.os, 'macos') }} - run: | - otool -L ${{ github.workspace }}/test/.libs/libbitcoin-node-test - - - name: Failure display DYLD_PRINT_LIBRARIES - if: ${{ failure() && startsWith(matrix.os, 'macos') }} - run: | - DYLD_PRINT_LIBRARIES=1 ${{ github.workspace }}/test/.libs/libbitcoin-node-test - - - name: Failure display pkgconfig - if: ${{ failure() }} - run: | - ls ${{ env.LIBBITCOIN_SRC_PATH }}prefix/lib/pkgconfig/ - cat ${{ env.LIBBITCOIN_SRC_PATH }}prefix/lib/pkgconfig/*.pc - - - name: Failure display cmake specific libraries - if: ${{ failure() }} - run: | - ls ${{ env.LIBBITCOIN_SRC_PATH }}prefix/lib/cmake - - - name: Failure display cmake LastTest.log - if: ${{ failure() }} - run: | - cat ${{ github.workspace }}/Testing/Temporary/LastTest.log - - msbuild: + msvc: strategy: fail-fast: false matrix: include: - - os: windows-latest - configuration: "StaticDebug" + - image: windows-latest + configuration: "StaticRelease" platform: "x64" version: "vs2022" tests: "*" - - os: windows-latest - configuration: "StaticRelease" + - image: windows-latest + configuration: "StaticDebug" platform: "x64" version: "vs2022" tests: "*" - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.image }} steps: - - name: Add msbuild to PATH + - name: Set msbuild path uses: microsoft/setup-msbuild@v3 with: msbuild-architecture: x64 @@ -813,30 +438,15 @@ jobs: - name: Checkout repository uses: actions/checkout@v6 - - name: Initialize SDK - shell: powershell - run: | - try { - Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/p/?LinkId=323507" -OutFile "sdksetup.exe" - - $FeatureList = "OptionId.WindowsDesktopSoftwareDevelopmentKit OptionId.NetFxSoftwareDevelopmentKit" - $Args = "/q /norestart /features $FeatureList" - $setup = Start-Process -PassThru -FilePath "sdksetup.exe" -ArgumentList $Args - - $setup.WaitForExit() - if ($setup.ExitCode -ne 0) { - Write-Host "Test execution failure: " $setup.ExitCode -ForegroundColor Red; - exit $setup.ExitCode; - } - } - catch { - $ERR = $_; - Write-Host "Initialization failure: " $ERR -ForegroundColor Red; - exit $ERR; - } - - name: Execute build - run: .\build.cmd .. ${{ matrix.platform }} ${{ matrix.configuration }} x64 ${{ matrix.version }} + shell: cmd + run: > + .\builds\msvc\build-msvc.cmd + --build-src-dir "%RUNNER_WORKSPACE%" + --build-config ${{ matrix.configuration }} + --build-platform ${{ matrix.platform }} + --build-version ${{ matrix.version }} + --build-use-local-src - name: Execute tests shell: powershell diff --git a/build.cmd b/build.cmd deleted file mode 100644 index 22fcb7b7..00000000 --- a/build.cmd +++ /dev/null @@ -1,128 +0,0 @@ -REM ########################################################################### -REM # Copyright (c) 2014-2026 libbitcoin-node developers (see COPYING). -REM # -REM # GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY -REM # -REM ########################################################################### -@echo off -SETLOCAL ENABLEEXTENSIONS -SET "parent=%~dp0" -SET "relative_path_base=%~1" -call cd /d "%relative_path_base%" -SET "path_base=%cd%" -SET "nuget_pkg_path=%path_base%\.nuget\packages" -SET "msbuild_args=/verbosity:minimal /p:Platform=%~2 /p:Configuration=%~3 /p:PreferredToolArchitecture=%~4" -SET "proj_version=%~5" -SET "msbuild_exe=msbuild" -IF EXIST "%~6" SET "msbuild_exe=%~6" - -call :pending "Build initialized..." -IF NOT EXIST "%nuget_pkg_path%" ( - call mkdir "%nuget_pkg_path%" - IF %ERRORLEVEL% NEQ 0 ( - call :failure "mkdir %nuget_pkg_path% failed." - exit /b 1 - ) -) - -call :init libbitcoin libbitcoin-system master -IF %ERRORLEVEL% NEQ 0 ( - call :failure "Initializing repository libbitcoin libbitcoin-system master failed." - exit /b 1 -) -call :init libbitcoin libbitcoin-network master -IF %ERRORLEVEL% NEQ 0 ( - call :failure "Initializing repository libbitcoin libbitcoin-network master failed." - exit /b 1 -) -call :init libbitcoin libbitcoin-database master -IF %ERRORLEVEL% NEQ 0 ( - call :failure "Initializing repository libbitcoin libbitcoin-database master failed." - exit /b 1 -) -call :bld_repo libbitcoin-node -IF %ERRORLEVEL% NEQ 0 ( - call :failure "Building libbitcoin-node failed." - exit /b 1 -) - -call :success "Build complete." -exit /b 0 - - - -:init -call :pending "Initializing repository %~1/%~2/%~3..." -IF NOT EXIST "%path_base%\%~2" ( - call git clone -q --branch=%~3 https://github.com/%~1/%~2 "%path_base%\%~2" - IF %ERRORLEVEL% NEQ 0 ( - call :failure "git clone %~1/%~2 failed." - exit /b 1 - ) -) ELSE ( - call :success "%path_base%\%~2 exists, assuming valid clone." -) - -call :bld_proj %~2 -IF %ERRORLEVEL% NEQ 0 ( - call :failure "Building project %~2 failed." - exit /b 1 -) -call :success "Initialization of %~1/%~2/%~3 complete." -exit /b 0 - -:bld_repo -call :pending "Building respository %~1..." -call :depends "%~1" -IF %ERRORLEVEL% NEQ 0 ( - call :failure "Initializing dependencies %~1 failed." - exit /b 1 -) -call cd /d "%path_base%\%~1\builds\msvc\%proj_version%" -call "%msbuild_exe%" %msbuild_args% %~1.sln /p:PreBuildEventUseInBuild=false /p:PostBuildEventUseInBuild=false -IF %ERRORLEVEL% NEQ 0 ( - call :failure "%msbuild_exe% %msbuild_args% %~1.sln failed." - exit /b 1 -) -call :success "Building repository %~1 execution complete." -call cd /d "%path_base%" -exit /b 0 - -:bld_proj -call :pending "Building respository project %~1..." -call :depends %~1 -IF %ERRORLEVEL% NEQ 0 ( - call :failure "Initializing dependencies %~1 failed." - exit /b 1 -) -call cd /d "%path_base%\%~1\builds\msvc\%proj_version%" -call "%msbuild_exe%" %msbuild_args% /target:%~1:Rebuild %~1.sln /p:PreBuildEventUseInBuild=false /p:PostBuildEventUseInBuild=false -IF %ERRORLEVEL% NEQ 0 ( - call :failure "%msbuild_exe% %msbuild_args% /target:%~1:Rebuild %~1.sln" - exit /b 1 -) -call :success "Building repository project %~1 execution complete." -call cd /d "%path_base%" -exit /b 0 - -:depends -call :pending "nuget restoring dependencies for %~1..." -call nuget restore "%path_base%\%~1\builds\msvc\%proj_version%\%~1.sln" -OutputDirectory "%nuget_pkg_path%" -IF %ERRORLEVEL% NEQ 0 ( - call :failure "nuget restore failed." - exit /b 1 -) -call :success "nuget restoration for %~1 complete." -exit /b 0 - -:pending -echo %~1 -exit /b 0 - -:success -echo %~1 -exit /b 0 - -:failure -echo %~1 -exit /b 0 diff --git a/builds/cmake/CMakeLists.txt b/builds/cmake/CMakeLists.txt index c161aa4d..7bd40d10 100644 --- a/builds/cmake/CMakeLists.txt +++ b/builds/cmake/CMakeLists.txt @@ -22,7 +22,7 @@ endif() #------------------------------------------------------------------------------ # Project options. #------------------------------------------------------------------------------ -option( with-test "Build test." ON ) +option( with-tests "Build tests." ON ) #------------------------------------------------------------------------------ # Dependencies. @@ -191,15 +191,15 @@ set_target_properties( libbitcoin-node ) #------------------------------------------------------------------------------ -# libbitcoin-node-tests tests +# libbitcoin-node-test tests #------------------------------------------------------------------------------ -if ( with-test ) - add_executable( libbitcoin-node-tests ) +if ( with-tests ) + add_executable( libbitcoin-node-test ) enable_testing() - add_test( NAME libbitcoin-node-tests - COMMAND libbitcoin-node-tests + add_test( NAME libbitcoin-node-test + COMMAND libbitcoin-node-test --run_test=* --log_level=warning --show_progress=no @@ -208,12 +208,12 @@ if ( with-test ) --build_info=yes ) - target_compile_features( libbitcoin-node-tests + target_compile_features( libbitcoin-node-test PUBLIC cxx_std_20 ) - target_compile_options( libbitcoin-node-tests + target_compile_options( libbitcoin-node-test PRIVATE -Wall -Wextra @@ -229,23 +229,23 @@ if ( with-test ) -fstack-protector-all ) - file( GLOB_RECURSE libbitcoin_node_tests_SOURCES CONFIGURE_DEPENDS + file( GLOB_RECURSE libbitcoin_node_test_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/../../test/*.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../test/*.cpp" ) - target_sources( libbitcoin-node-tests + target_sources( libbitcoin-node-test PRIVATE - ${libbitcoin_node_tests_SOURCES} + ${libbitcoin_node_test_SOURCES} ) - target_link_libraries( libbitcoin-node-tests + target_link_libraries( libbitcoin-node-test PRIVATE Boost::unit_test_framework bitcoin::node ) - set_target_properties( libbitcoin-node-tests + set_target_properties( libbitcoin-node-test PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} diff --git a/builds/cmake/CMakePresets.json b/builds/cmake/CMakePresets.json index 3c949867..b5b23198 100644 --- a/builds/cmake/CMakePresets.json +++ b/builds/cmake/CMakePresets.json @@ -11,8 +11,8 @@ "type": "inList", "string": "${hostSystemName}", "list": [ - "Darwin", - "Linux" + "Darwin", + "Linux" ] }, "cacheVariables": { @@ -20,6 +20,10 @@ "type": "PATH", "value": "${sourceParentDir}/../../../prefix/${presetName}" }, + "CMAKE_INSTALL_PREFIX_PATH": { + "type": "PATH", + "value": "${sourceParentDir}/../../../prefix/${presetName}" + }, "CMAKE_LIBRARY_PATH": { "type": "PATH", "value": "${sourceParentDir}/../../../prefix/${presetName}/lib:$env{CMAKE_LIBRARY_PATH}" @@ -31,12 +35,9 @@ "description": "Factored debug settings.", "hidden": true, "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", "CMAKE_C_FLAGS": "$env{CMAKE_C_FLAGS} -Og -g --coverage", - "CMAKE_CXX_FLAGS": "$env{CMAKE_CXX_FLAGS} -Og -g --coverage", - "enable-ndebug": { - "type": "BOOL", - "value": "OFF" - } + "CMAKE_CXX_FLAGS": "$env{CMAKE_CXX_FLAGS} -Og -g --coverage" } }, { @@ -44,12 +45,9 @@ "description": "Factored release settings.", "hidden": true, "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", "CMAKE_C_FLAGS": "$env{CMAKE_C_FLAGS} -O3", - "CMAKE_CXX_FLAGS": "$env{CMAKE_CXX_FLAGS} -O3", - "enable-ndebug": { - "type": "BOOL", - "value": "ON" - } + "CMAKE_CXX_FLAGS": "$env{CMAKE_CXX_FLAGS} -O3" } }, { @@ -124,7 +122,7 @@ "name": "nix-target-list", "hidden": true, "targets": [ - "bitcoin-node", + "libbitcoin-node", "libbitcoin-node-test" ] }, diff --git a/builds/cmake/install-cmake.sh b/builds/cmake/install-cmake.sh new file mode 100755 index 00000000..34143561 --- /dev/null +++ b/builds/cmake/install-cmake.sh @@ -0,0 +1,982 @@ +#!/bin/bash +############################################################################### +# Copyright (c) 2014-2026 libbitcoin-node developers (see COPYING). +# +# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY +# +############################################################################### +# Script managing the build and installation of libbitcoin-node and its dependencies. +# +# Script options: +# --build-boost Build Boost libraries +# --build-secp256k1 Build libsecp256k1 libraries +# --build-src-dir= Location of sources. +# --build-obj-dir= Location of intermedia objects. +# --build-obj-dir-relative Use build-obj-dir as relative to project sources. +# --build-config= Specifies the build configuration. +# Valid values: { debug, release } +# Toolchain default behavior will occur if no value specified. +# --build-link= Specifies link mode. +# Valid values: { dynamic, static } +# Toolchain default behavior will occur if no value specified. +# --build-full-repositories Sync full github repositories. +# Default clones depth 1, single branch +# --build-parallel= Number of jobs to run simultaneously. +# Default: discovery +# --build-use-local-src Use existing sources in build-src-dir path. +# --prefix= Library install location. +# Default: /usr/local +# --verbose Display verbose script output. +# --help, -h Display usage, overriding script execution. +# +# All unrecognized options provided shall be passed as configuration +# options for all dependencies. + +OPTS_ENABLE="set -eo pipefail" +OPTS_DISABLE="set +e" + +eval "${OPTS_ENABLE}" +trap 'echo "FATAL ERROR: Command failed at line ${LINENO}: ${BASH_COMMAND}" >&2' ERR + +SEQUENTIAL=1 + +if [[ -z ${boost_URLBASE} ]]; then + boost_URLBASE="https://archives.boost.io/release/1.86.0/source/" +fi +if [[ -z ${boost_FILENAME} ]]; then + boost_FILENAME="boost_1_86_0.tar.bz2" +fi + +if [[ -z ${secp256k1_OWNER} ]]; then + secp256k1_OWNER="bitcoin-core" +fi +if [[ -z ${secp256k1_TAG} ]]; then + secp256k1_TAG="v0.7.0" +fi + +if [[ -z ${libbitcoin_system_OWNER} ]]; then + libbitcoin_system_OWNER="libbitcoin" +fi +if [[ -z ${libbitcoin_system_TAG} ]]; then + libbitcoin_system_TAG="master" +fi + +if [[ -z ${libbitcoin_database_OWNER} ]]; then + libbitcoin_database_OWNER="libbitcoin" +fi +if [[ -z ${libbitcoin_database_TAG} ]]; then + libbitcoin_database_TAG="master" +fi + +if [[ -z ${libbitcoin_network_OWNER} ]]; then + libbitcoin_network_OWNER="libbitcoin" +fi +if [[ -z ${libbitcoin_network_TAG} ]]; then + libbitcoin_network_TAG="master" +fi + +if [[ -z ${libbitcoin_node_OWNER} ]]; then + libbitcoin_node_OWNER="libbitcoin" +fi +if [[ -z ${libbitcoin_node_TAG} ]]; then + libbitcoin_node_TAG="master" +fi + +main() +{ + # argument consumption + + for OPTION in "$@"; do + case ${OPTION} in + (--build-boost) BUILD_boost="yes";; + (--build-secp256k1) BUILD_secp256k1="yes";; + (--build-src-dir=*) BUILD_SRC_DIR="${OPTION#*=}";; + (--build-obj-dir=*) BUILD_OBJ_DIR="${OPTION#*=}";; + (--build-obj-dir-relative) BUILD_OBJ_DIR_RELATIVE="yes";; + (--build-config=*) BUILD_CONFIG="${OPTION#*=}";; + (--build-link=*) BUILD_LINK="${OPTION#*=}";; + (--build-full-repositories) BUILD_FULL_REPOSITORIES="yes";; + (--build-use-local-src) BUILD_USE_LOCAL_SRC="yes";; + (--build-parallel=*) PARALLEL="${OPTION#*=}";; + (--prefix=*) PREFIX="${OPTION#*=}";; + (--verbose) DISPLAY_VERBOSE="yes";; + (--help|-h) DISPLAY_HELP="yes";; + (-DCMAKE_PREFIX_PATH=*) CMAKE_PREFIX_PATH="${OPTION#*=}";; + (-DCMAKE_INSTALL_PREFIX=*) CMAKE_INSTALL_PREFIX="${OPTION#*=}";; + (-DCMAKE_INCLUDE_PATH=*) CMAKE_INCLUDE_PATH="${OPTION#*=}";; + (-DCMAKE_LIBRARY_PATH=*) CMAKE_LIBRARY_PATH="${OPTION#*=}";; + esac + done + + CONFIGURE_OPTIONS_ORIGINAL=("$@") + CONFIGURE_OPTIONS=("$@") + CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--build-*/}") + CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--prefix=*/}") + CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--verbose/}") + msg_verbose "*** ARGUMENTS: ${CONFIGURE_OPTIONS_ORIGINAL[*]}" + msg_verbose "*** SANITIZED: ${CONFIGURE_OPTIONS[*]}" + + if [[ "${DISPLAY_VERBOSE}" == "yes" ]]; then + display_build_variables + fi + + + OS=$(uname -s) + + # defaults and sanitization: script static options + + # --build-src-dir + if [[ -z "${BUILD_SRC_DIR}" ]]; then + BUILD_SRC_DIR="$(pwd)" + msg_verbose "No build-src-dir specified, using default '${BUILD_SRC_DIR}'." + fi + + if [[ -d "${BUILD_SRC_DIR}" ]]; then + push_directory "${BUILD_SRC_DIR}" + BUILD_SRC_DIR="$(pwd)" + pop_directory + msg_verbose "Determined absolute path for build-src-dir '${BUILD_SRC_DIR}'." + else + create_directory "${BUILD_SRC_DIR}" + push_directory "${BUILD_SRC_DIR}" + BUILD_SRC_DIR="$(pwd)" + pop_directory + msg_verbose "Created build-src-dir '${BUILD_SRC_DIR}'." + fi + + # --build-obj-dir + if [[ -z "${BUILD_OBJ_DIR}" ]]; then + if [[ "${BUILD_OBJ_DIR_RELATIVE}" == "yes" ]]; then + BUILD_OBJ_DIR="obj" + msg_verbose "No build-obj-dir specified, using relative default '${BUILD_OBJ_DIR}'." + else + BUILD_OBJ_DIR="$(pwd)/obj" + msg_verbose "No build-obj-dir specified, using default '${BUILD_OBJ_DIR}'." + fi + fi + + if [[ "${BUILD_OBJ_DIR_RELATIVE}" == "yes" ]]; then + msg_verbose "Deferring relative path action for build-obj-dir '${BUILD_OBJ_DIR}'." + else + if [[ -d "${BUILD_OBJ_DIR}" ]]; then + push_directory "${BUILD_OBJ_DIR}" + BUILD_OBJ_DIR="$(pwd)" + pop_directory + msg_verbose "Determined absolute path for build-obj-dir '${BUILD_OBJ_DIR}'." + else + create_directory "${BUILD_OBJ_DIR}" + push_directory "${BUILD_OBJ_DIR}" + BUILD_OBJ_DIR="$(pwd)" + pop_directory + msg_verbose "Created build-obj-dir '${BUILD_OBJ_DIR}'." + fi + fi + + # --build-config + if [[ -z "${BUILD_CONFIG}" ]]; then + msg_verbose "No build-config specified." + elif [[ "${BUILD_CONFIG}" != "debug" ]] && [[ "${BUILD_CONFIG}" != "release" ]]; then + msg_error "Provided build-config '${BUILD_CONFIG}' not a valid value." + help + exit 1 + else + msg_verbose "Using provided build-config '${BUILD_CONFIG}'" + fi + + # --build-link + if [[ -z "${BUILD_LINK}" ]]; then + msg_verbose "No build-link specified." + elif [[ "${BUILD_LINK}" != "dynamic" ]] && [[ "${BUILD_LINK}" != "static" ]]; then + msg_error "Provided build-link ${BUILD_LINK}' not a valid value." + help + exit 1 + fi + + # --prefix + if [[ -z "${PREFIX}" ]]; then + # Always set a prefix (required for OSX and lib detection). + PREFIX="/usr/local" + msg_verbose "No prefix specified, defaulting to '${PREFIX}'." + else + # Incorporate the custom libdir into each object, for link time resolution + if [[ -z "${LD_RUN_PATH}" ]]; then + export LD_RUN_PATH="${PREFIX}/lib" + else + export LD_RUN_PATH="${LD_RUN_PATH}:${PREFIX}/lib" + fi + + if [[ -z "${LD_LIBRARY_PATH}" ]]; then + export LD_LIBRARY_PATH="${PREFIX}/lib" + else + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${PREFIX}/lib" + fi + fi + + if [[ -n "${PREFIX}" ]] && [[ -n "${CMAKE_INSTALL_PREFIX}" ]]; then + msg_error "Both PREFIX and CMAKE_INSTALL_PREFIX have been defined differently." + help + exit 1 + elif [[ -n "${PREFIX}" ]]; then + CMAKE_INSTALL_PREFIX="${PREFIX}" + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]/-DCMAKE_INSTALL_PREFIX=*/}" ) + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]}" "-DCMAKE_INSTALL_PREFIX=${PREFIX}" ) + fi + + if [[ -n "${PREFIX}" ]] && [[ -n "${CMAKE_PREFIX_PATH}" ]] && + [[ "${PREFIX}" != "${CMAKE_PREFIX_PATH}" ]]; then + CMAKE_PREFIX_PATH="${PREFIX}:${CMAKE_PREFIX_PATH}" + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]/-DCMAKE_PREFIX_PATH=*/}" ) + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]}" "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ) + elif [[ -n "${PREFIX}" ]]; then + CMAKE_INSTALL_PREFIX="${PREFIX}" + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]/-DCMAKE_PREFIX_PATH=*/}" ) + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]}" "-DCMAKE_PREFIX_PATH=${PREFIX}" ) + fi + + if [[ -n "${PREFIX}" ]]; then + # Set the prefix-based package config directory. + PREFIX_PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig" + + # Prioritize prefix package config in PKG_CONFIG_PATH search path. + if [[ -n "${PKG_CONFIG_PATH}" ]]; then + export PKG_CONFIG_PATH="${PREFIX_PKG_CONFIG_PATH}:${PKG_CONFIG_PATH}" + else + export PKG_CONFIG_PATH="${PREFIX_PKG_CONFIG_PATH}" + fi + + with_pkgconfigdir="--with-pkgconfigdir=${PREFIX_PKG_CONFIG_PATH}" + fi + + # --parallel + if [[ -z "${PARALLEL}" ]]; then + if [[ ${OS} == Linux ]]; then + PARALLEL=$(nproc) + elif [[ ${OS} == Darwin ]] || [[ ${OS} == OpenBSD ]]; then + PARALLEL=$(sysctl -n hw.ncpu) + else + msg_error "Unsupported system: '${OS}'" + msg_error " Unable to determine value for '--parallel='" + msg_error " Please specify explicitly to continue." + msg_error "" + help + exit 1 + fi + fi + + # state rationalization of standard build variables + + if [[ ${OS} == OpenBSD ]]; then + make() { gmake "$@"; } + fi + + if [[ -z "${STDLIB}" ]]; then + if [[ ${OS} == Darwin ]]; then + STDLIB="c++" + elif [[ ${OS} == OpenBSD ]]; then + STDLIB="estdc++" + else + STDLIB="stdc++" + fi + else + define_message_verbose "STDLIB using defined value '${STDLIB}'" + fi + + if [[ -z "${CC}" ]]; then + if [[ ${OS} == Darwin ]]; then + export CC="clang" + elif [[ ${OS} == OpenBSD ]]; then + export CC="egcc" + fi + else + msg_verbose "CC using defined value '${CC}'" + fi + + if [[ -z "${CXX}" ]]; then + if [[ ${OS} == Darwin ]]; then + export CXX="clang++" + elif [[ ${OS} == OpenBSD ]]; then + export CXX="eg++" + fi + else + msg_verbose "CXX using defined value '${CXX}'" + fi + + # translate BUILD_CONFIG to ZFLAGS + if [[ -n "${BUILD_CONFIG}" ]]; then + msg_verbose "*** Build config specified, calculating flags..." + + if [[ "${BUILD_CONFIG}" == "debug" ]]; then + BUILD_FLAGS="-Og -g" + elif [[ "${BUILD_CONFIG}" == "release" ]]; then + BUILD_FLAGS="-O3" + fi + + if [[ -z "${CFLAGS}" ]]; then + export CFLAGS="${BUILD_FLAGS}" + msg_verbose "Exporting CFLAGS '${CFLAGS}'" + else + msg_verbose "CFLAGS intitally '${CFLAGS}'" + SANITIZED_CFLAGS=$(strip_optimization "$CFLAGS") + export CFLAGS="${SANITIZED_CFLAGS} ${BUILD_FLAGS}" + msg_verbose "CFLAGS modified to '${CFLAGS}'" + fi + + if [[ -z "${CXXFLAGS}" ]]; then + export CXXFLAGS="${BUILD_FLAGS}" + msg_verbose "Exporting CXXFLAGS '${CXXFLAGS}'" + else + msg_verbose "CXXFLAGS intitally '${CXXFLAGS}'" + SANITIZED_CXXFLAGS=$(strip_optimization "$CXXFLAGS") + export CXXFLAGS="${SANITIZED_CXXFLAGS} ${BUILD_FLAGS}" + msg_verbose "CXXFLAGS modified to '${CXXFLAGS}'" + fi + fi + + # Specify cmake build + if [[ "${BUILD_CONFIG}" == "debug" ]]; then + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]}" "-DCMAKE_BUILD_TYPE=Debug" ) + elif [[ "${BUILD_CONFIG}" == "release" ]]; then + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]}" "-DCMAKE_BUILD_TYPE=Release" ) + fi + + # translate BUILD_LINK to appropriate arguments + if [[ -n "${BUILD_LINK}" ]]; then + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]/-DBUILD_SHARED_LIBS=*}" ) + + if [[ "${BUILD_LINK}" == "dynamic" ]]; then + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]}" "-DBUILD_SHARED_LIBS=ON" ) + else + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]}" "-DBUILD_SHARED_LIBS=OFF" ) + fi + fi + + if [[ ${OS} == Linux && ${CC} == clang* ]] || [[ ${OS} == OpenBSD ]]; then + export LDLIBS="-l${STDLIB} ${LDLIBS}" + msg_verbose "LDLIBS has been manipulated to encode STDLIB linkage." + fi + + # defaults and sanitization: generated options + + if [[ -n "${BUILD_boost}" ]]; then + export BOOST_ROOT="${PREFIX}" + with_boost="--with-boost=${PREFIX}" + fi + + REMAP=() + for argument in "${CONFIGURE_OPTIONS[@]}"; do + if [[ -n "${argument}" ]]; then + REMAP+=( "${argument}" ) + fi + done + CONFIGURE_OPTIONS=( "${REMAP[@]}" ) + unset REMAP + + # handle help + if [[ "${DISPLAY_HELP}" == "yes" ]]; then + help + return 0 + fi + + msg_heading "Configuration" + display_build_variables + + msg_heading "Toolchain Configuration Parameters" + display_toolchain_variables + + if [[ "${DISPLAY_VERBOSE}" == "yes" ]]; then + msg_heading "State" + display_constants + fi + + # declarations + + boost_FLAGS=( + "-Wno-enum-constexpr-conversion") + + boost_OPTIONS=( + "--with-iostreams" + "--with-locale" + "--with-program_options" + "--with-regex" + "--with-thread" + "--with-url" + "--with-test") + + secp256k1_FLAGS=( + "-w") + + secp256k1_OPTIONS=( + "-DSECP256K1_BUILD_TESTS=OFF" + "-DSECP256K1_EXPERIMENTAL=ON" + "-DSECP256K1_ENABLE_MODULE_RECOVERY=ON" + "-DSECP256K1_ENABLE_MODULE_SCHNORRSIG=ON") + + libbitcoin_system_FLAGS=() + + libbitcoin_system_OPTIONS=( + "-Dwith-tests:BOOL=OFF" + "-Dwith-examples:BOOL=OFF") + + libbitcoin_database_FLAGS=() + + libbitcoin_database_OPTIONS=( + "-Dwith-tests:BOOL=OFF" + "-Dwith-tools:BOOL=OFF") + + libbitcoin_network_FLAGS=() + + libbitcoin_network_OPTIONS=( + "-Dwith-tests:BOOL=OFF" + "-Dwith-ssl:BOOL=ON") + + libbitcoin_node_FLAGS=() + + libbitcoin_node_OPTIONS=() + + if [[ ${BUILD_boost} == "yes" ]]; then + source_archive "boost" "${boost_FILENAME}" "${boost_URLBASE}" "bzip2" + local SAVE_CPPFLAGS="${CPPFLAGS}" + export CPPFLAGS="${CPPFLAGS} ${boost_FLAGS[@]}" + build_boost "boost" "${boost_OPTIONS[@]}" + export CPPFLAGS="${SAVE_CPPFLAGS}" + fi + + if [[ ${BUILD_secp256k1} == "yes" ]]; then + source_github "${secp256k1_OWNER}" "secp256k1" "${secp256k1_TAG}" + local SAVE_CPPFLAGS="${CPPFLAGS}" + export CPPFLAGS="${CPPFLAGS} ${secp256k1_FLAGS[@]}" + build_cmake "secp256k1" "." "${PARALLEL}" "${secp256k1_OPTIONS[@]}" "${CONFIGURE_OPTIONS[@]}" + install_make "secp256k1" + export CPPFLAGS="${SAVE_CPPFLAGS}" + fi + + source_github "${libbitcoin_system_OWNER}" "libbitcoin-system" "${libbitcoin_system_TAG}" + local SAVE_CPPFLAGS="${CPPFLAGS}" + export CPPFLAGS="${CPPFLAGS} ${libbitcoin_system_FLAGS[@]}" + build_cmake "libbitcoin-system" "builds/cmake" "${PARALLEL}" "${libbitcoin_system_OPTIONS[@]}" "${CONFIGURE_OPTIONS[@]}" + install_make "libbitcoin-system" + export CPPFLAGS="${SAVE_CPPFLAGS}" + + source_github "${libbitcoin_database_OWNER}" "libbitcoin-database" "${libbitcoin_database_TAG}" + local SAVE_CPPFLAGS="${CPPFLAGS}" + export CPPFLAGS="${CPPFLAGS} ${libbitcoin_database_FLAGS[@]}" + build_cmake "libbitcoin-database" "builds/cmake" "${PARALLEL}" "${libbitcoin_database_OPTIONS[@]}" "${CONFIGURE_OPTIONS[@]}" + install_make "libbitcoin-database" + export CPPFLAGS="${SAVE_CPPFLAGS}" + + source_github "${libbitcoin_network_OWNER}" "libbitcoin-network" "${libbitcoin_network_TAG}" + local SAVE_CPPFLAGS="${CPPFLAGS}" + export CPPFLAGS="${CPPFLAGS} ${libbitcoin_network_FLAGS[@]}" + build_cmake "libbitcoin-network" "builds/cmake" "${PARALLEL}" "${libbitcoin_network_OPTIONS[@]}" "${CONFIGURE_OPTIONS[@]}" + install_make "libbitcoin-network" + export CPPFLAGS="${SAVE_CPPFLAGS}" + + source_github "${libbitcoin_node_OWNER}" "libbitcoin-node" "${libbitcoin_node_TAG}" + local SAVE_CPPFLAGS="${CPPFLAGS}" + export CPPFLAGS="${CPPFLAGS} ${libbitcoin_node_FLAGS[@]}" + build_cmake "libbitcoin-node" "builds/cmake" "${PARALLEL}" "${libbitcoin_node_OPTIONS[@]}" "${CONFIGURE_OPTIONS[@]}" + test_make "libbitcoin-node" "test" "${PARALLEL}" + install_make "libbitcoin-node" + export CPPFLAGS="${SAVE_CPPFLAGS}" + + msg_success "Completed successfully." +} + +source_archive() +{ + local PROJECT="$1" + local FILENAME="$2" + local URL_BASE="$3" + local COMPRESSION="$4" + shift 4 + + msg_heading "Preparing to acquire ${PROJECT}" + + push_directory "${BUILD_SRC_DIR}" + + if [ -d "${PROJECT}" ] && + [[ "${BUILD_USE_LOCAL_SRC}" == "yes" ]]; then + msg_warn "Reusing existing '${PROJECT}' directory..." + return 0 + fi + + if [ -d "${PROJECT}" ]; then + msg_warn "Encounted existing '${PROJECT}' directory, removing..." + remove_directory_force "${PROJECT}" + fi + + msg "Retrieving ${PROJECT}..." + + create_directory "${PROJECT}" + push_directory "${PROJECT}" + + local TAR="tar" + local WGET="wget --quiet" + + # retrieve file + ${WGET} --output-document "${FILENAME}" "${URL_BASE}${FILENAME}" + # ${WGET} --output-document "${FILENAME}" "${URL_BASE}${FILENAME}" + + # extract to expected path + ${TAR} --extract --file "${FILENAME}" --${COMPRESSION} --strip-components=1 + # ${TAR} --extract --file "${FILENAME}" "--${COMPRESSION}" --strip-components=1 + + # pop ${PROJECT} + pop_directory + + # pop ${BUILD_SRC_DIR} + pop_directory + + msg_success "Completed download and extraction successfully." +} + +source_github() +{ + local OWNER="$1" + local REPOSITORY="$2" + local TAG="$3" + shift 3 + + msg_heading "Preparing to acquire ${OWNER}/${REPOSITORY}/${TAG}" + + local GIT_CLONE="git clone" + local CLONE_OPTIONS="--depth 1 --single-branch" + + if [[ "${BUILD_FULL_REPOSITORIES}" == "yes" ]]; then + CLONE_OPTIONS="" + fi + + push_directory "${BUILD_SRC_DIR}" + + if [ -d "${REPOSITORY}" ] && + [[ "${BUILD_USE_LOCAL_SRC}" == "yes" ]]; then + msg_warn "Reusing existing '${REPOSITORY}'..." + pop_directory # BUILD_SRC_DIR + return 0 + fi + + if [ -d "${REPOSITORY}" ]; then + msg_warn "Encounted existing '${REPOSITORY}' directory, removing..." + remove_directory_force "${REPOSITORY}" + fi + + msg "Cloning ${OWNER}/${REPOSITORY}/${TAG}..." + + ${GIT_CLONE} ${CLONE_OPTIONS} --branch "${TAG}" "https://github.com/${OWNER}/${REPOSITORY}" + + # pop BUILD_SRC_DIR + pop_directory +} + +install_make() +{ + local PROJECT="$1" + shift + + msg "Preparing to install ${PROJECT}" + + push_directory "${BUILD_SRC_DIR}/${PROJECT}" + + if [[ "${BUILD_OBJ_DIR_RELATIVE}" == "yes" ]]; then + push_directory "${BUILD_OBJ_DIR}" + else + push_directory "${BUILD_OBJ_DIR}/${PROJECT}" + fi + + make install + + if [[ ${OS} == Linux ]] && [[ "${PREFIX}" == "/usr/local" ]]; then + ldconfig + fi + + pop_directory # BUILD_OBJ_DIR + pop_directory # BUILD_SRC_DIR/PROJECT + + msg_success "'${PROJECT}' installation compelete." +} + +test_make() +{ + local PROJECT="$1" + local TARGET="$2" + local JOBS="$3" + shift 3 + + msg "Preparing to test ${PROJECT}" + + push_directory "${BUILD_SRC_DIR}/${PROJECT}" + + if [[ "${BUILD_OBJ_DIR_RELATIVE}" == "yes" ]]; then + push_directory "${BUILD_OBJ_DIR}" + else + push_directory "${BUILD_OBJ_DIR}/${PROJECT}" + fi + + disable_exit_on_error + + if [[ ${JOBS} -gt ${SEQUENTIAL} ]]; then + make -j${JOBS} ${TARGET} VERBOSE=1 + else + make ${TARGET} VERBOSE=1 + fi + + local RESULT=$? + + # Test runners emit to the test.log file. + if [[ -e "test.log" ]]; then + cat "test.log" + fi + + enable_exit_on_error + + if [[ ${RESULT} -ne 0 ]]; then + exit ${RESULT} + fi + + pop_directory # BUILD_OBJ_DIR + pop_directory # BUILD_SRC_DIR/PROJECT + + msg_success "'${PROJECT}' test compelete." +} + +build_boost() +{ + local PROJECT="$1" + shift + + msg_heading "Preparing to build ${PROJECT}" + + push_directory "${BUILD_SRC_DIR}/${PROJECT}" + + local SAVE_IFS="${IFS}" + IFS=' ' + + # Compute configuration + if [[ "${BUILD_LINK}" == "dynamic" ]]; then + BOOST_LINK="shared" + elif [[ "${BUILD_LINK}" == "static" ]]; then + BOOST_LINK="static" + else + BOOST_LINK="static,shared" + fi + + if [[ -n ${CC} ]]; then + BOOST_TOOLSET="toolset=${CC}" + fi + + if [[ (${OS} == Linux && ${CC} == clang*) || (${OS} == OpenBSD) ]]; then + STDLIB_FLAG="-stdlib=lib${STDLIB}" + BOOST_CXXFLAGS="cxxflags=${STDLIB_FLAG}" + BOOST_LINKFLAGS="linkflags=${STDLIB_FLAG}" + fi + + guessed_toolset=`${BUILD_SRC_DIR}/${PROJECT}/tools/build/src/engine/build.sh --guess-toolset` + CXXFLAGS="-w" ${BUILD_SRC_DIR}/${PROJECT}/tools/build/src/engine/build.sh ${guessed_toolset} --cxxflags="-w" + cp "${BUILD_SRC_DIR}/${PROJECT}/tools/build/src/engine/b2" . + + if [[ -n "${BOOST_CXXFLAGS}" ]]; then + BOOST_CXXFLAGS="${BOOST_CXXFLAGS} ${boost_FLAGS[@]}" + else + BOOST_CXXFLAGS="cxxflags=${boost_FLAGS[@]}" + fi + + # Prebuild status report + msg "${PROJECT} configuration." + msg "--------------------------------------------------------------------" + msg "variant : release" + msg "threading : multi" + msg "toolset : ${CC}" + msg "boost cxxflags : ${BOOST_CXXFLAGS}" + msg "boost linkflags : ${BOOST_LINKFLAGS}" + msg "link : ${BOOST_LINK}" + msg "-sNO_BZIP2 : 1" + msg "-sNO_ZSTD : 1" + msg "-j : ${PARALLEL}" + msg "-d0 : [supress informational messages]" + msg "-q : [stop at the first error]" + msg "--reconfigure : [ignore cached configuration]" + msg "--prefix : ${PREFIX}" + msg "BOOST_OPTIONS : $*" + msg "cxxflags (ignored) : ${CXXFLAGS}" + msg "--------------------------------------------------------------------" + + # Begin build + ./bootstrap.sh --with-bjam=./b2 --prefix=${PREFIX} + + ./b2 install \ + "cxxstd=20" \ + "variant=release" \ + "threading=multi" \ + "${BOOST_TOOLSET}" \ + "${BOOST_CXXFLAGS}" \ + "${BOOST_LINKFLAGS}" \ + "link=${BOOST_LINK}" \ + "warnings=off" \ + "-sNO_BZIP2=1" \ + "-sNO_ZSTD=1" \ + "-j ${PARALLEL}" \ + "-d0" \ + "-q" \ + "--reconfigure" \ + "--prefix=${PREFIX}" \ + "$@" + + IFS="${SAVE_IFS}" + + pop_directory # BUILD_SRC_DIR +} + +build_cmake() +{ + local PROJECT="$1" + local RELATIVE_PATH="$2" + local JOBS="$3" + shift 3 + + local VERBOSITY_CMAKE="" + local VERBOSITY_MAKE="" + + if [[ "${DISPLAY_VERBOSE}" == "yes" ]]; then + VERBOSITY_CMAKE="-DCMAKE_VERBOSE_MAKEFILE=ON" + VERBOSITY_MAKE="VERBOSE=1" + fi + + msg_heading "Preparing to build ${PROJECT}" + + + # directory rationalization + push_directory "${BUILD_SRC_DIR}/${PROJECT}" + push_directory "${RELATIVE_PATH}" + local BUILD_PATH="$(pwd)" + pop_directory + + if [[ "${BUILD_OBJ_DIR_RELATIVE}" == "yes" ]]; then + create_directory_force "${BUILD_OBJ_DIR}" + push_directory "${BUILD_OBJ_DIR}" + else + push_directory "${BUILD_OBJ_DIR}" + create_directory_force "${PROJECT}" + pop_directory + push_directory "${BUILD_OBJ_DIR}/${PROJECT}" + fi + + display_configure_options "$@" + + cmake ${VERBOSITY_CMAKE} -LA "$@" "${BUILD_SRC_DIR}/${PROJECT}/${RELATIVE_PATH}" + + # make + if [[ ${JOBS} -gt ${SEQUENTIAL} ]]; then + make -j${JOBS} ${VERBOSITY_MAKE} + else + make + fi + + pop_directory # BUILD_OBJ_DIR + pop_directory # BUILD_SRC_DIR/PROJECT + msg_success "'${PROJECT}' built successfully." +} + +display_build_variables() +{ + msg "BUILD_boost : ${BUILD_boost}" + msg "BUILD_secp256k1 : ${BUILD_secp256k1}" + msg "BUILD_SRC_DIR : ${BUILD_SRC_DIR}" + msg "BUILD_OBJ_DIR : ${BUILD_OBJ_DIR}" + msg "BUILD_OBJ_DIR_RELATIVE : ${BUILD_OBJ_DIR_RELATIVE}" + msg "BUILD_CONFIG : ${BUILD_CONFIG}" + msg "BUILD_LINK : ${BUILD_LINK}" + msg "BUILD_FULL_REPOSITORIES : ${BUILD_FULL_REPOSITORIES}" + msg "BUILD_USE_LOCAL_SRC : ${BUILD_USE_LOCAL_SRC}" + msg "PARALLEL : ${PARALLEL}" + msg "PREFIX : ${PREFIX}" + msg "DISPLAY_VERBOSE : ${DISPLAY_VERBOSE}" + msg "CONFIGURE_OPTIONS : ${CONFIGURE_OPTIONS[*]}" +if [[ "${DISPLAY_VERBOSE}" == "yes" ]]; then + msg "CONFIGURE_OPTIONS_ORIGINAL : ${CONFIGURE_OPTIONS_ORIGINAL[*]}" +fi +} + +display_toolchain_variables() +{ + + msg "CC : ${CC}" + msg "CFLAGS : ${CFLAGS}" + msg "CXX : ${CXX}" + msg "CXXFLAGS : ${CXXFLAGS}" + msg "LD_RUN_PATH : ${LD_RUN_PATH}" + msg "LD_LIBRARY_PATH : ${LD_LIBRARY_PATH}" + msg "PKG_CONFIG_PATH : ${PKG_CONFIG_PATH}" + msg "LDLIBS : ${LDLIBS}" + msg "BOOST_ROOT : ${BOOST_ROOT}" + msg "CMAKE_PREFIX_PATH : ${CMAKE_PREFIX_PATH}" + msg "CMAKE_INSTALL_PREFIX : ${CMAKE_INSTALL_PREFIX}" + msg "CMAKE_INCLUDE_PATH : ${CMAKE_INCLUDE_PATH}" + msg "CMAKE_LIBRARY_PATH : ${CMAKE_LIBRARY_PATH}" +} + +display_constants() +{ + msg "boost_URLBASE : ${boost_URLBASE}" + msg "boost_FILENAME : ${boost_FILENAME}" + + msg "secp256k1_OWNER : ${secp256k1_OWNER}" + msg "secp256k1_TAG : ${secp256k1_TAG}" + + msg "libbitcoin_system_OWNER : ${libbitcoin_system_OWNER}" + msg "libbitcoin_system_TAG : ${libbitcoin_system_TAG}" + + msg "libbitcoin_database_OWNER : ${libbitcoin_database_OWNER}" + msg "libbitcoin_database_TAG : ${libbitcoin_database_TAG}" + + msg "libbitcoin_network_OWNER : ${libbitcoin_network_OWNER}" + msg "libbitcoin_network_TAG : ${libbitcoin_network_TAG}" + + msg "libbitcoin_node_OWNER : ${libbitcoin_node_OWNER}" + msg "libbitcoin_node_TAG : ${libbitcoin_node_TAG}" +} + +help() +{ + msg "Script managing the build and installation of libbitcoin-node and its dependencies." + msg "" + msg "Script options:" + msg "--build-boost Build Boost libraries" + msg "--build-secp256k1 Build libsecp256k1 libraries" + msg "--build-src-dir= Location of sources." + msg "--build-obj-dir= Location of intermedia objects." + msg "--build-obj-dir-relative Use build-obj-dir as relative to project sources." + msg "--build-config= Specifies the build configuration." + msg " Valid values: { debug, release }" + msg " Toolchain default behavior will occur if no value specified." + msg "--build-link= Specifies link mode." + msg " Valid values: { dynamic, static }" + msg " Toolchain default behavior will occur if no value specified." + msg "--build-full-repositories Sync full github repositories." + msg " Default clones depth 1, single branch" + msg "--build-parallel= Number of jobs to run simultaneously." + msg " Default: discovery" + msg "--build-use-local-src Use existing sources in build-src-dir path." + msg "--prefix= Library install location." + msg " Default: /usr/local" + msg "--verbose Display verbose script output." + msg "--help, -h Display usage, overriding script execution." + msg "" + msg "All unrecognized options provided shall be passed as configuration" + msg "options for all dependencies." +} + +display_configure_options() +{ + msg "configure options:" + for OPTION in "$@"; do + if [[ -n ${OPTION} ]]; then + msg "${OPTION}" + fi + done +} + + +enable_exit_on_error() +{ + eval "${OPTS_ENABLE}" +} + +disable_exit_on_error() +{ + eval "${OPTS_DISABLE}" +} + +strip_optimization() +{ + echo "$1" | sed -E ' + s/-O([0-3]|s|fast|g|z|size|speed)?b?/ /g + s/-g([0-3]|gdb|dwarf[0-9]*)?b?/ /g + s/[[:space:]]+/ /g + s/^ | $//g + ' +} + +create_directory() +{ + local DIRECTORY="$1" + local MODE="$2" + + if [[ -d "${DIRECTORY}" ]]; then + if [[ ${MODE} == "-f" ]]; then + msg_warn "Reinitializing '${DIRECTORY}'..." + rm -rf "${DIRECTORY}" + mkdir -p "${DIRECTORY}" + else + msg_warn "Reusing existing '${DIRECTORY}'..." + fi + else + msg "Initializing '${DIRECTORY}'..." + mkdir -p "${DIRECTORY}" + fi +} + +create_directory_force() +{ + create_directory "$@" -f +} + +pop_directory() +{ + msg_verbose "*** move pre: '$(pwd)'" + popd >/dev/null + msg_verbose "*** move post: '$(pwd)'" +} + +push_directory() +{ + msg_verbose "*** move pre: '$(pwd)'" + local DIRECTORY="$1" + pushd "${DIRECTORY}" >/dev/null + msg_verbose "*** move post: '$(pwd)'" +} + +remove_directory_force() +{ + msg_verbose "*** removing: '$@'" + rm -rf "$@" +} + +COLOR_CYAN='\e[0;96m' +COLOR_GREEN='\e[0;92m' +COLOR_RED='\e[0;91m' +COLOR_YELLOW='\e[0;93m' +COLOR_RESET='\e[0m' + +msg_heading() +{ + printf "\n********************** %b **********************\n" "$@" +} + +msg_verbose() +{ + if [[ "${DISPLAY_VERBOSE}" == "yes" ]]; then + printf "${COLOR_CYAN}%b${COLOR_RESET}\n" "$@" + fi +} + +msg() +{ + printf "%b\n" "$@" +} + +msg_success() +{ + printf "${COLOR_GREEN}%b${COLOR_RESET}\n" "$@" +} + +msg_warn() +{ + printf "${COLOR_YELLOW}%b${COLOR_RESET}\n" "$@" +} + +msg_error() +{ + >&2 printf "${COLOR_RED}%b${COLOR_RESET}\n" "$@" +} + +main "$@" diff --git a/builds/cmake/install-presets.sh b/builds/cmake/install-presets.sh new file mode 100755 index 00000000..a4446b33 --- /dev/null +++ b/builds/cmake/install-presets.sh @@ -0,0 +1,1045 @@ +#!/bin/bash +############################################################################### +# Copyright (c) 2014-2026 libbitcoin-node developers (see COPYING). +# +# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY +# +############################################################################### +# Script managing the build and installation of libbitcoin-node and its dependencies. +# +# Script options: +# --build-boost Build Boost libraries +# --build-secp256k1 Build libsecp256k1 libraries +# --build-preset= Preset configuration to build. +# --build-src-dir= Location of sources. +# --build-full-repositories Sync full github repositories. +# Default clones depth 1, single branch +# --build-parallel= Number of jobs to run simultaneously. +# Default: discovery +# --build-use-local-src Use existing sources in build-src-dir path. +# --verbose Display verbose script output. +# --help, -h Display usage, overriding script execution. +# +# All unrecognized options provided shall be passed as configuration +# options for all dependencies. + +OPTS_ENABLE="set -eo pipefail" +OPTS_DISABLE="set +e" + +eval "${OPTS_ENABLE}" +trap 'echo "FATAL ERROR: Command failed at line ${LINENO}: ${BASH_COMMAND}" >&2' ERR + +SEQUENTIAL=1 + +if [[ -z ${boost_URLBASE} ]]; then + boost_URLBASE="https://archives.boost.io/release/1.86.0/source/" +fi +if [[ -z ${boost_FILENAME} ]]; then + boost_FILENAME="boost_1_86_0.tar.bz2" +fi + +if [[ -z ${secp256k1_OWNER} ]]; then + secp256k1_OWNER="bitcoin-core" +fi +if [[ -z ${secp256k1_TAG} ]]; then + secp256k1_TAG="v0.7.0" +fi + +if [[ -z ${libbitcoin_system_OWNER} ]]; then + libbitcoin_system_OWNER="libbitcoin" +fi +if [[ -z ${libbitcoin_system_TAG} ]]; then + libbitcoin_system_TAG="master" +fi + +if [[ -z ${libbitcoin_database_OWNER} ]]; then + libbitcoin_database_OWNER="libbitcoin" +fi +if [[ -z ${libbitcoin_database_TAG} ]]; then + libbitcoin_database_TAG="master" +fi + +if [[ -z ${libbitcoin_network_OWNER} ]]; then + libbitcoin_network_OWNER="libbitcoin" +fi +if [[ -z ${libbitcoin_network_TAG} ]]; then + libbitcoin_network_TAG="master" +fi + +if [[ -z ${libbitcoin_node_OWNER} ]]; then + libbitcoin_node_OWNER="libbitcoin" +fi +if [[ -z ${libbitcoin_node_TAG} ]]; then + libbitcoin_node_TAG="master" +fi + +main() +{ + # argument consumption + + for OPTION in "$@"; do + case ${OPTION} in + (--build-boost) BUILD_boost="yes";; + (--build-secp256k1) BUILD_secp256k1="yes";; + (--build-preset=*) BUILD_PRESET="${OPTION#*=}";; + (--build-src-dir=*) BUILD_SRC_DIR="${OPTION#*=}";; + (--build-full-repositories) BUILD_FULL_REPOSITORIES="yes";; + (--build-use-local-src) BUILD_USE_LOCAL_SRC="yes";; + (--build-parallel=*) PARALLEL="${OPTION#*=}";; + (--verbose) DISPLAY_VERBOSE="yes";; + (--help|-h) DISPLAY_HELP="yes";; + (-DCMAKE_PREFIX_PATH=*) CMAKE_PREFIX_PATH="${OPTION#*=}";; + (-DCMAKE_INSTALL_PREFIX=*) CMAKE_INSTALL_PREFIX="${OPTION#*=}";; + (-DCMAKE_INCLUDE_PATH=*) CMAKE_INCLUDE_PATH="${OPTION#*=}";; + (-DCMAKE_LIBRARY_PATH=*) CMAKE_LIBRARY_PATH="${OPTION#*=}";; + esac + done + + CONFIGURE_OPTIONS_ORIGINAL=("$@") + CONFIGURE_OPTIONS=("$@") + CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--build-*/}") + CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--prefix=*/}") + CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--verbose/}") + msg_verbose "*** ARGUMENTS: ${CONFIGURE_OPTIONS_ORIGINAL[*]}" + msg_verbose "*** SANITIZED: ${CONFIGURE_OPTIONS[*]}" + + if [[ "${DISPLAY_VERBOSE}" == "yes" ]]; then + display_build_variables + fi + + + OS=$(uname -s) + + # defaults and sanitization: script static options + + # --build-preset + if [[ -z "${BUILD_PRESET}" ]]; then + msg_error "No build-preset specified." + help + exit 1 + fi + + if [[ "${BUILD_PRESET}" == "nix-gnu-debug-static" ]]; then + msg_verbose "BUILD_PRESET value 'nix-gnu-debug-static'." + BUILD_CONFIG="debug" + BUILD_LINK="static" + elif [[ "${BUILD_PRESET}" == "nix-gnu-debug-shared" ]]; then + msg_verbose "BUILD_PRESET value 'nix-gnu-debug-shared'." + BUILD_CONFIG="debug" + BUILD_LINK="dynamic" + elif [[ "${BUILD_PRESET}" == "nix-gnu-release-static" ]]; then + msg_verbose "BUILD_PRESET value 'nix-gnu-release-static'." + BUILD_CONFIG="release" + BUILD_LINK="static" + elif [[ "${BUILD_PRESET}" == "nix-gnu-release-shared" ]]; then + msg_verbose "BUILD_PRESET value 'nix-gnu-release-shared'." + BUILD_CONFIG="release" + BUILD_LINK="dynamic" + else + msg_error "Unrecognized build-preset value '${BUILD_PRESET}'." + help + exit 1 + fi + + # --build-src-dir + if [[ -z "${BUILD_SRC_DIR}" ]]; then + BUILD_SRC_DIR="$(pwd)" + msg_verbose "No build-src-dir specified, using default '${BUILD_SRC_DIR}'." + fi + + if [[ -d "${BUILD_SRC_DIR}" ]]; then + push_directory "${BUILD_SRC_DIR}" + BUILD_SRC_DIR="$(pwd)" + pop_directory + msg_verbose "Determined absolute path for build-src-dir '${BUILD_SRC_DIR}'." + else + create_directory "${BUILD_SRC_DIR}" + push_directory "${BUILD_SRC_DIR}" + BUILD_SRC_DIR="$(pwd)" + pop_directory + msg_verbose "Created build-src-dir '${BUILD_SRC_DIR}'." + fi + # Embedded knowlege of CMakePresets: binaryDir + + BUILD_OBJ_DIR="obj/${BUILD_PRESET}" + BUILD_OBJ_DIR_RELATIVE="yes" + PREFIX="${BUILD_SRC_DIR}/prefix/${BUILD_PRESET}" + + # --build-obj-dir + if [[ -z "${BUILD_OBJ_DIR}" ]]; then + if [[ "${BUILD_OBJ_DIR_RELATIVE}" == "yes" ]]; then + BUILD_OBJ_DIR="obj" + msg_verbose "No build-obj-dir specified, using relative default '${BUILD_OBJ_DIR}'." + else + BUILD_OBJ_DIR="$(pwd)/obj" + msg_verbose "No build-obj-dir specified, using default '${BUILD_OBJ_DIR}'." + fi + fi + + if [[ "${BUILD_OBJ_DIR_RELATIVE}" == "yes" ]]; then + msg_verbose "Deferring relative path action for build-obj-dir '${BUILD_OBJ_DIR}'." + else + if [[ -d "${BUILD_OBJ_DIR}" ]]; then + push_directory "${BUILD_OBJ_DIR}" + BUILD_OBJ_DIR="$(pwd)" + pop_directory + msg_verbose "Determined absolute path for build-obj-dir '${BUILD_OBJ_DIR}'." + else + create_directory "${BUILD_OBJ_DIR}" + push_directory "${BUILD_OBJ_DIR}" + BUILD_OBJ_DIR="$(pwd)" + pop_directory + msg_verbose "Created build-obj-dir '${BUILD_OBJ_DIR}'." + fi + fi + + # --build-config + if [[ -z "${BUILD_CONFIG}" ]]; then + msg_verbose "No build-config specified." + elif [[ "${BUILD_CONFIG}" != "debug" ]] && [[ "${BUILD_CONFIG}" != "release" ]]; then + msg_error "Provided build-config '${BUILD_CONFIG}' not a valid value." + help + exit 1 + else + msg_verbose "Using provided build-config '${BUILD_CONFIG}'" + fi + + # --build-link + if [[ -z "${BUILD_LINK}" ]]; then + msg_verbose "No build-link specified." + elif [[ "${BUILD_LINK}" != "dynamic" ]] && [[ "${BUILD_LINK}" != "static" ]]; then + msg_error "Provided build-link ${BUILD_LINK}' not a valid value." + help + exit 1 + fi + + # --prefix + if [[ -z "${PREFIX}" ]]; then + # Always set a prefix (required for OSX and lib detection). + PREFIX="/usr/local" + msg_verbose "No prefix specified, defaulting to '${PREFIX}'." + else + # Incorporate the custom libdir into each object, for link time resolution + if [[ -z "${LD_RUN_PATH}" ]]; then + export LD_RUN_PATH="${PREFIX}/lib" + else + export LD_RUN_PATH="${LD_RUN_PATH}:${PREFIX}/lib" + fi + + if [[ -z "${LD_LIBRARY_PATH}" ]]; then + export LD_LIBRARY_PATH="${PREFIX}/lib" + else + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${PREFIX}/lib" + fi + fi + + if [[ -n "${PREFIX}" ]] && [[ -n "${CMAKE_INSTALL_PREFIX}" ]]; then + msg_error "Both PREFIX and CMAKE_INSTALL_PREFIX have been defined differently." + help + exit 1 + elif [[ -n "${PREFIX}" ]]; then + CMAKE_INSTALL_PREFIX="${PREFIX}" + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]/-DCMAKE_INSTALL_PREFIX=*/}" ) + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]}" "-DCMAKE_INSTALL_PREFIX=${PREFIX}" ) + fi + + if [[ -n "${PREFIX}" ]] && [[ -n "${CMAKE_PREFIX_PATH}" ]] && + [[ "${PREFIX}" != "${CMAKE_PREFIX_PATH}" ]]; then + CMAKE_PREFIX_PATH="${PREFIX}:${CMAKE_PREFIX_PATH}" + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]/-DCMAKE_PREFIX_PATH=*/}" ) + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]}" "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ) + elif [[ -n "${PREFIX}" ]]; then + CMAKE_INSTALL_PREFIX="${PREFIX}" + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]/-DCMAKE_PREFIX_PATH=*/}" ) + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]}" "-DCMAKE_PREFIX_PATH=${PREFIX}" ) + fi + + if [[ -n "${PREFIX}" ]]; then + # Set the prefix-based package config directory. + PREFIX_PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig" + + # Prioritize prefix package config in PKG_CONFIG_PATH search path. + if [[ -n "${PKG_CONFIG_PATH}" ]]; then + export PKG_CONFIG_PATH="${PREFIX_PKG_CONFIG_PATH}:${PKG_CONFIG_PATH}" + else + export PKG_CONFIG_PATH="${PREFIX_PKG_CONFIG_PATH}" + fi + + with_pkgconfigdir="--with-pkgconfigdir=${PREFIX_PKG_CONFIG_PATH}" + fi + + # --parallel + if [[ -z "${PARALLEL}" ]]; then + if [[ ${OS} == Linux ]]; then + PARALLEL=$(nproc) + elif [[ ${OS} == Darwin ]] || [[ ${OS} == OpenBSD ]]; then + PARALLEL=$(sysctl -n hw.ncpu) + else + msg_error "Unsupported system: '${OS}'" + msg_error " Unable to determine value for '--parallel='" + msg_error " Please specify explicitly to continue." + msg_error "" + help + exit 1 + fi + fi + + # state rationalization of standard build variables + + if [[ ${OS} == OpenBSD ]]; then + make() { gmake "$@"; } + fi + + if [[ -z "${STDLIB}" ]]; then + if [[ ${OS} == Darwin ]]; then + STDLIB="c++" + elif [[ ${OS} == OpenBSD ]]; then + STDLIB="estdc++" + else + STDLIB="stdc++" + fi + else + define_message_verbose "STDLIB using defined value '${STDLIB}'" + fi + + if [[ -z "${CC}" ]]; then + if [[ ${OS} == Darwin ]]; then + export CC="clang" + elif [[ ${OS} == OpenBSD ]]; then + export CC="egcc" + fi + else + msg_verbose "CC using defined value '${CC}'" + fi + + if [[ -z "${CXX}" ]]; then + if [[ ${OS} == Darwin ]]; then + export CXX="clang++" + elif [[ ${OS} == OpenBSD ]]; then + export CXX="eg++" + fi + else + msg_verbose "CXX using defined value '${CXX}'" + fi + + # translate BUILD_CONFIG to ZFLAGS + if [[ -n "${BUILD_CONFIG}" ]]; then + msg_verbose "*** Build config specified, calculating flags..." + + if [[ "${BUILD_CONFIG}" == "debug" ]]; then + BUILD_FLAGS="-Og -g" + elif [[ "${BUILD_CONFIG}" == "release" ]]; then + BUILD_FLAGS="-O3" + fi + + if [[ -z "${CFLAGS}" ]]; then + export CFLAGS="${BUILD_FLAGS}" + msg_verbose "Exporting CFLAGS '${CFLAGS}'" + else + msg_verbose "CFLAGS intitally '${CFLAGS}'" + SANITIZED_CFLAGS=$(strip_optimization "$CFLAGS") + export CFLAGS="${SANITIZED_CFLAGS} ${BUILD_FLAGS}" + msg_verbose "CFLAGS modified to '${CFLAGS}'" + fi + + if [[ -z "${CXXFLAGS}" ]]; then + export CXXFLAGS="${BUILD_FLAGS}" + msg_verbose "Exporting CXXFLAGS '${CXXFLAGS}'" + else + msg_verbose "CXXFLAGS intitally '${CXXFLAGS}'" + SANITIZED_CXXFLAGS=$(strip_optimization "$CXXFLAGS") + export CXXFLAGS="${SANITIZED_CXXFLAGS} ${BUILD_FLAGS}" + msg_verbose "CXXFLAGS modified to '${CXXFLAGS}'" + fi + fi + + # Specify cmake build + if [[ "${BUILD_CONFIG}" == "debug" ]]; then + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]}" "-DCMAKE_BUILD_TYPE=Debug" ) + elif [[ "${BUILD_CONFIG}" == "release" ]]; then + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]}" "-DCMAKE_BUILD_TYPE=Release" ) + fi + + # translate BUILD_LINK to appropriate arguments + if [[ -n "${BUILD_LINK}" ]]; then + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]/-DBUILD_SHARED_LIBS=*}" ) + + if [[ "${BUILD_LINK}" == "dynamic" ]]; then + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]}" "-DBUILD_SHARED_LIBS=ON" ) + else + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]}" "-DBUILD_SHARED_LIBS=OFF" ) + fi + fi + + if [[ ${OS} == Linux && ${CC} == clang* ]] || [[ ${OS} == OpenBSD ]]; then + export LDLIBS="-l${STDLIB} ${LDLIBS}" + msg_verbose "LDLIBS has been manipulated to encode STDLIB linkage." + fi + + # defaults and sanitization: generated options + + if [[ -n "${BUILD_boost}" ]]; then + export BOOST_ROOT="${PREFIX}" + with_boost="--with-boost=${PREFIX}" + fi + + REMAP=() + for argument in "${CONFIGURE_OPTIONS[@]}"; do + if [[ -n "${argument}" ]]; then + REMAP+=( "${argument}" ) + fi + done + CONFIGURE_OPTIONS=( "${REMAP[@]}" ) + unset REMAP + + # handle help + if [[ "${DISPLAY_HELP}" == "yes" ]]; then + help + return 0 + fi + + msg_heading "Configuration" + display_build_variables + + msg_heading "Toolchain Configuration Parameters" + display_toolchain_variables + + if [[ "${DISPLAY_VERBOSE}" == "yes" ]]; then + msg_heading "State" + display_constants + fi + + # declarations + + boost_FLAGS=( + "-Wno-enum-constexpr-conversion") + + boost_OPTIONS=( + "--with-iostreams" + "--with-locale" + "--with-program_options" + "--with-regex" + "--with-thread" + "--with-url" + "--with-test") + + secp256k1_FLAGS=( + "-w") + + secp256k1_OPTIONS=( + "-DSECP256K1_BUILD_TESTS=OFF" + "-DSECP256K1_EXPERIMENTAL=ON" + "-DSECP256K1_ENABLE_MODULE_RECOVERY=ON" + "-DSECP256K1_ENABLE_MODULE_SCHNORRSIG=ON") + + libbitcoin_system_FLAGS=() + + libbitcoin_system_OPTIONS=( + "-Dwith-tests:BOOL=OFF" + "-Dwith-examples:BOOL=OFF") + + libbitcoin_database_FLAGS=() + + libbitcoin_database_OPTIONS=( + "-Dwith-tests:BOOL=OFF" + "-Dwith-tools:BOOL=OFF") + + libbitcoin_network_FLAGS=() + + libbitcoin_network_OPTIONS=( + "-Dwith-tests:BOOL=OFF" + "-Dwith-ssl:BOOL=ON") + + libbitcoin_node_FLAGS=() + + libbitcoin_node_OPTIONS=() + + if [[ ${BUILD_boost} == "yes" ]]; then + source_archive "boost" "${boost_FILENAME}" "${boost_URLBASE}" "bzip2" + local SAVE_CPPFLAGS="${CPPFLAGS}" + export CPPFLAGS="${CPPFLAGS} ${boost_FLAGS[@]}" + build_boost "boost" "${boost_OPTIONS[@]}" + export CPPFLAGS="${SAVE_CPPFLAGS}" + fi + + if [[ ${BUILD_secp256k1} == "yes" ]]; then + source_github "${secp256k1_OWNER}" "secp256k1" "${secp256k1_TAG}" + local SAVE_CPPFLAGS="${CPPFLAGS}" + export CPPFLAGS="${CPPFLAGS} ${secp256k1_FLAGS[@]}" + build_cmake "secp256k1" "." "${PARALLEL}" "${secp256k1_OPTIONS[@]}" "${CONFIGURE_OPTIONS[@]}" + install_make "secp256k1" + export CPPFLAGS="${SAVE_CPPFLAGS}" + fi + + source_github "${libbitcoin_system_OWNER}" "libbitcoin-system" "${libbitcoin_system_TAG}" + local SAVE_CPPFLAGS="${CPPFLAGS}" + export CPPFLAGS="${CPPFLAGS} ${libbitcoin_system_FLAGS[@]}" + build_preset "libbitcoin-system" "builds/cmake" "${PARALLEL}" "${libbitcoin_system_OPTIONS[@]}" "${CONFIGURE_OPTIONS[@]}" + install_make "libbitcoin-system" + export CPPFLAGS="${SAVE_CPPFLAGS}" + + source_github "${libbitcoin_database_OWNER}" "libbitcoin-database" "${libbitcoin_database_TAG}" + local SAVE_CPPFLAGS="${CPPFLAGS}" + export CPPFLAGS="${CPPFLAGS} ${libbitcoin_database_FLAGS[@]}" + build_preset "libbitcoin-database" "builds/cmake" "${PARALLEL}" "${libbitcoin_database_OPTIONS[@]}" "${CONFIGURE_OPTIONS[@]}" + install_make "libbitcoin-database" + export CPPFLAGS="${SAVE_CPPFLAGS}" + + source_github "${libbitcoin_network_OWNER}" "libbitcoin-network" "${libbitcoin_network_TAG}" + local SAVE_CPPFLAGS="${CPPFLAGS}" + export CPPFLAGS="${CPPFLAGS} ${libbitcoin_network_FLAGS[@]}" + build_preset "libbitcoin-network" "builds/cmake" "${PARALLEL}" "${libbitcoin_network_OPTIONS[@]}" "${CONFIGURE_OPTIONS[@]}" + install_make "libbitcoin-network" + export CPPFLAGS="${SAVE_CPPFLAGS}" + + source_github "${libbitcoin_node_OWNER}" "libbitcoin-node" "${libbitcoin_node_TAG}" + local SAVE_CPPFLAGS="${CPPFLAGS}" + export CPPFLAGS="${CPPFLAGS} ${libbitcoin_node_FLAGS[@]}" + build_preset "libbitcoin-node" "builds/cmake" "${PARALLEL}" "${libbitcoin_node_OPTIONS[@]}" "${CONFIGURE_OPTIONS[@]}" + test_make "libbitcoin-node" "test" "${PARALLEL}" + install_make "libbitcoin-node" + export CPPFLAGS="${SAVE_CPPFLAGS}" + + msg_success "Completed successfully." +} + +source_archive() +{ + local PROJECT="$1" + local FILENAME="$2" + local URL_BASE="$3" + local COMPRESSION="$4" + shift 4 + + msg_heading "Preparing to acquire ${PROJECT}" + + push_directory "${BUILD_SRC_DIR}" + + if [ -d "${PROJECT}" ] && + [[ "${BUILD_USE_LOCAL_SRC}" == "yes" ]]; then + msg_warn "Reusing existing '${PROJECT}' directory..." + return 0 + fi + + if [ -d "${PROJECT}" ]; then + msg_warn "Encounted existing '${PROJECT}' directory, removing..." + remove_directory_force "${PROJECT}" + fi + + msg "Retrieving ${PROJECT}..." + + create_directory "${PROJECT}" + push_directory "${PROJECT}" + + local TAR="tar" + local WGET="wget --quiet" + + # retrieve file + ${WGET} --output-document "${FILENAME}" "${URL_BASE}${FILENAME}" + # ${WGET} --output-document "${FILENAME}" "${URL_BASE}${FILENAME}" + + # extract to expected path + ${TAR} --extract --file "${FILENAME}" --${COMPRESSION} --strip-components=1 + # ${TAR} --extract --file "${FILENAME}" "--${COMPRESSION}" --strip-components=1 + + # pop ${PROJECT} + pop_directory + + # pop ${BUILD_SRC_DIR} + pop_directory + + msg_success "Completed download and extraction successfully." +} + +source_github() +{ + local OWNER="$1" + local REPOSITORY="$2" + local TAG="$3" + shift 3 + + msg_heading "Preparing to acquire ${OWNER}/${REPOSITORY}/${TAG}" + + local GIT_CLONE="git clone" + local CLONE_OPTIONS="--depth 1 --single-branch" + + if [[ "${BUILD_FULL_REPOSITORIES}" == "yes" ]]; then + CLONE_OPTIONS="" + fi + + push_directory "${BUILD_SRC_DIR}" + + if [ -d "${REPOSITORY}" ] && + [[ "${BUILD_USE_LOCAL_SRC}" == "yes" ]]; then + msg_warn "Reusing existing '${REPOSITORY}'..." + pop_directory # BUILD_SRC_DIR + return 0 + fi + + if [ -d "${REPOSITORY}" ]; then + msg_warn "Encounted existing '${REPOSITORY}' directory, removing..." + remove_directory_force "${REPOSITORY}" + fi + + msg "Cloning ${OWNER}/${REPOSITORY}/${TAG}..." + + ${GIT_CLONE} ${CLONE_OPTIONS} --branch "${TAG}" "https://github.com/${OWNER}/${REPOSITORY}" + + # pop BUILD_SRC_DIR + pop_directory +} + +install_make() +{ + local PROJECT="$1" + shift + + msg "Preparing to install ${PROJECT}" + + push_directory "${BUILD_SRC_DIR}/${PROJECT}" + + if [[ "${BUILD_OBJ_DIR_RELATIVE}" == "yes" ]]; then + push_directory "${BUILD_OBJ_DIR}" + else + push_directory "${BUILD_OBJ_DIR}/${PROJECT}" + fi + + make install + + if [[ ${OS} == Linux ]] && [[ "${PREFIX}" == "/usr/local" ]]; then + ldconfig + fi + + pop_directory # BUILD_OBJ_DIR + pop_directory # BUILD_SRC_DIR/PROJECT + + msg_success "'${PROJECT}' installation compelete." +} + +test_make() +{ + local PROJECT="$1" + local TARGET="$2" + local JOBS="$3" + shift 3 + + msg "Preparing to test ${PROJECT}" + + push_directory "${BUILD_SRC_DIR}/${PROJECT}" + + if [[ "${BUILD_OBJ_DIR_RELATIVE}" == "yes" ]]; then + push_directory "${BUILD_OBJ_DIR}" + else + push_directory "${BUILD_OBJ_DIR}/${PROJECT}" + fi + + disable_exit_on_error + + if [[ ${JOBS} -gt ${SEQUENTIAL} ]]; then + make -j${JOBS} ${TARGET} VERBOSE=1 + else + make ${TARGET} VERBOSE=1 + fi + + local RESULT=$? + + # Test runners emit to the test.log file. + if [[ -e "test.log" ]]; then + cat "test.log" + fi + + enable_exit_on_error + + if [[ ${RESULT} -ne 0 ]]; then + exit ${RESULT} + fi + + pop_directory # BUILD_OBJ_DIR + pop_directory # BUILD_SRC_DIR/PROJECT + + msg_success "'${PROJECT}' test compelete." +} + +build_boost() +{ + local PROJECT="$1" + shift + + msg_heading "Preparing to build ${PROJECT}" + + push_directory "${BUILD_SRC_DIR}/${PROJECT}" + + local SAVE_IFS="${IFS}" + IFS=' ' + + # Compute configuration + if [[ "${BUILD_LINK}" == "dynamic" ]]; then + BOOST_LINK="shared" + elif [[ "${BUILD_LINK}" == "static" ]]; then + BOOST_LINK="static" + else + BOOST_LINK="static,shared" + fi + + if [[ -n ${CC} ]]; then + BOOST_TOOLSET="toolset=${CC}" + fi + + if [[ (${OS} == Linux && ${CC} == clang*) || (${OS} == OpenBSD) ]]; then + STDLIB_FLAG="-stdlib=lib${STDLIB}" + BOOST_CXXFLAGS="cxxflags=${STDLIB_FLAG}" + BOOST_LINKFLAGS="linkflags=${STDLIB_FLAG}" + fi + + guessed_toolset=`${BUILD_SRC_DIR}/${PROJECT}/tools/build/src/engine/build.sh --guess-toolset` + CXXFLAGS="-w" ${BUILD_SRC_DIR}/${PROJECT}/tools/build/src/engine/build.sh ${guessed_toolset} --cxxflags="-w" + cp "${BUILD_SRC_DIR}/${PROJECT}/tools/build/src/engine/b2" . + + if [[ -n "${BOOST_CXXFLAGS}" ]]; then + BOOST_CXXFLAGS="${BOOST_CXXFLAGS} ${boost_FLAGS[@]}" + else + BOOST_CXXFLAGS="cxxflags=${boost_FLAGS[@]}" + fi + + # Prebuild status report + msg "${PROJECT} configuration." + msg "--------------------------------------------------------------------" + msg "variant : release" + msg "threading : multi" + msg "toolset : ${CC}" + msg "boost cxxflags : ${BOOST_CXXFLAGS}" + msg "boost linkflags : ${BOOST_LINKFLAGS}" + msg "link : ${BOOST_LINK}" + msg "-sNO_BZIP2 : 1" + msg "-sNO_ZSTD : 1" + msg "-j : ${PARALLEL}" + msg "-d0 : [supress informational messages]" + msg "-q : [stop at the first error]" + msg "--reconfigure : [ignore cached configuration]" + msg "--prefix : ${PREFIX}" + msg "BOOST_OPTIONS : $*" + msg "cxxflags (ignored) : ${CXXFLAGS}" + msg "--------------------------------------------------------------------" + + # Begin build + ./bootstrap.sh --with-bjam=./b2 --prefix=${PREFIX} + + ./b2 install \ + "cxxstd=20" \ + "variant=release" \ + "threading=multi" \ + "${BOOST_TOOLSET}" \ + "${BOOST_CXXFLAGS}" \ + "${BOOST_LINKFLAGS}" \ + "link=${BOOST_LINK}" \ + "warnings=off" \ + "-sNO_BZIP2=1" \ + "-sNO_ZSTD=1" \ + "-j ${PARALLEL}" \ + "-d0" \ + "-q" \ + "--reconfigure" \ + "--prefix=${PREFIX}" \ + "$@" + + IFS="${SAVE_IFS}" + + pop_directory # BUILD_SRC_DIR +} + +build_cmake() +{ + local PROJECT="$1" + local RELATIVE_PATH="$2" + local JOBS="$3" + shift 3 + + local VERBOSITY_CMAKE="" + local VERBOSITY_MAKE="" + + if [[ "${DISPLAY_VERBOSE}" == "yes" ]]; then + VERBOSITY_CMAKE="-DCMAKE_VERBOSE_MAKEFILE=ON" + VERBOSITY_MAKE="VERBOSE=1" + fi + + msg_heading "Preparing to build ${PROJECT}" + + + # directory rationalization + push_directory "${BUILD_SRC_DIR}/${PROJECT}" + push_directory "${RELATIVE_PATH}" + local BUILD_PATH="$(pwd)" + pop_directory + + if [[ "${BUILD_OBJ_DIR_RELATIVE}" == "yes" ]]; then + create_directory_force "${BUILD_OBJ_DIR}" + push_directory "${BUILD_OBJ_DIR}" + else + push_directory "${BUILD_OBJ_DIR}" + create_directory_force "${PROJECT}" + pop_directory + push_directory "${BUILD_OBJ_DIR}/${PROJECT}" + fi + + display_configure_options "$@" + + cmake ${VERBOSITY_CMAKE} -LA "$@" "${BUILD_SRC_DIR}/${PROJECT}/${RELATIVE_PATH}" + + # make + if [[ ${JOBS} -gt ${SEQUENTIAL} ]]; then + make -j${JOBS} ${VERBOSITY_MAKE} + else + make + fi + + pop_directory # BUILD_OBJ_DIR + pop_directory # BUILD_SRC_DIR/PROJECT + msg_success "'${PROJECT}' built successfully." +} + +build_preset() +{ + local PROJECT="$1" + local RELATIVE_PATH="$2" + local JOBS="$3" + shift 3 + + local VERBOSITY_CMAKE="" + local VERBOSITY_MAKE="" + + if [[ "${DISPLAY_VERBOSE}" == "yes" ]]; then + VERBOSITY_CMAKE="-DCMAKE_VERBOSE_MAKEFILE=ON" + VERBOSITY_MAKE="VERBOSE=1" + fi + + msg_heading "Preparing to build ${PROJECT}" + + + # directory rationalization + push_directory "${BUILD_SRC_DIR}/${PROJECT}" + push_directory "${RELATIVE_PATH}" + local BUILD_PATH="$(pwd)" + pop_directory + + if [[ "${BUILD_OBJ_DIR_RELATIVE}" == "yes" ]]; then + create_directory_force "${BUILD_OBJ_DIR}" + push_directory "${BUILD_OBJ_DIR}" + else + push_directory "${BUILD_OBJ_DIR}" + create_directory_force "${PROJECT}" + pop_directory + push_directory "${BUILD_OBJ_DIR}/${PROJECT}" + fi + + display_configure_options "$@" + + cmake ${VERBOSITY_CMAKE} -LA --preset="${BUILD_PRESET}" "$@" "${BUILD_SRC_DIR}/${PROJECT}/${RELATIVE_PATH}" + + # make + if [[ ${JOBS} -gt ${SEQUENTIAL} ]]; then + make -j${JOBS} ${VERBOSITY_MAKE} + else + make + fi + + pop_directory # BUILD_OBJ_DIR + pop_directory # BUILD_SRC_DIR/PROJECT + msg_success "'${PROJECT}' built successfully." +} + +display_build_variables() +{ + msg "BUILD_boost : ${BUILD_boost}" + msg "BUILD_secp256k1 : ${BUILD_secp256k1}" + msg "BUILD_PRESET : ${BUILD_PRESET}" + msg "BUILD_SRC_DIR : ${BUILD_SRC_DIR}" + msg "BUILD_OBJ_DIR : ${BUILD_OBJ_DIR}" + msg "BUILD_OBJ_DIR_RELATIVE : ${BUILD_OBJ_DIR_RELATIVE}" + msg "BUILD_CONFIG : ${BUILD_CONFIG}" + msg "BUILD_LINK : ${BUILD_LINK}" + msg "BUILD_FULL_REPOSITORIES : ${BUILD_FULL_REPOSITORIES}" + msg "BUILD_USE_LOCAL_SRC : ${BUILD_USE_LOCAL_SRC}" + msg "PARALLEL : ${PARALLEL}" + msg "PREFIX : ${PREFIX}" + msg "DISPLAY_VERBOSE : ${DISPLAY_VERBOSE}" + msg "CONFIGURE_OPTIONS : ${CONFIGURE_OPTIONS[*]}" +if [[ "${DISPLAY_VERBOSE}" == "yes" ]]; then + msg "CONFIGURE_OPTIONS_ORIGINAL : ${CONFIGURE_OPTIONS_ORIGINAL[*]}" +fi +} + +display_toolchain_variables() +{ + + msg "CC : ${CC}" + msg "CFLAGS : ${CFLAGS}" + msg "CXX : ${CXX}" + msg "CXXFLAGS : ${CXXFLAGS}" + msg "LD_RUN_PATH : ${LD_RUN_PATH}" + msg "LD_LIBRARY_PATH : ${LD_LIBRARY_PATH}" + msg "PKG_CONFIG_PATH : ${PKG_CONFIG_PATH}" + msg "LDLIBS : ${LDLIBS}" + msg "BOOST_ROOT : ${BOOST_ROOT}" + msg "CMAKE_PREFIX_PATH : ${CMAKE_PREFIX_PATH}" + msg "CMAKE_INSTALL_PREFIX : ${CMAKE_INSTALL_PREFIX}" + msg "CMAKE_INCLUDE_PATH : ${CMAKE_INCLUDE_PATH}" + msg "CMAKE_LIBRARY_PATH : ${CMAKE_LIBRARY_PATH}" +} + +display_constants() +{ + msg "boost_URLBASE : ${boost_URLBASE}" + msg "boost_FILENAME : ${boost_FILENAME}" + + msg "secp256k1_OWNER : ${secp256k1_OWNER}" + msg "secp256k1_TAG : ${secp256k1_TAG}" + + msg "libbitcoin_system_OWNER : ${libbitcoin_system_OWNER}" + msg "libbitcoin_system_TAG : ${libbitcoin_system_TAG}" + + msg "libbitcoin_database_OWNER : ${libbitcoin_database_OWNER}" + msg "libbitcoin_database_TAG : ${libbitcoin_database_TAG}" + + msg "libbitcoin_network_OWNER : ${libbitcoin_network_OWNER}" + msg "libbitcoin_network_TAG : ${libbitcoin_network_TAG}" + + msg "libbitcoin_node_OWNER : ${libbitcoin_node_OWNER}" + msg "libbitcoin_node_TAG : ${libbitcoin_node_TAG}" +} + +help() +{ + msg "Script managing the build and installation of libbitcoin-node and its dependencies." + msg "" + msg "Script options:" + msg "--build-boost Build Boost libraries" + msg "--build-secp256k1 Build libsecp256k1 libraries" + msg "--build-preset= Preset configuration to build." + msg "--build-src-dir= Location of sources." + msg "--build-full-repositories Sync full github repositories." + msg " Default clones depth 1, single branch" + msg "--build-parallel= Number of jobs to run simultaneously." + msg " Default: discovery" + msg "--build-use-local-src Use existing sources in build-src-dir path." + msg "--verbose Display verbose script output." + msg "--help, -h Display usage, overriding script execution." + msg "" + msg "All unrecognized options provided shall be passed as configuration" + msg "options for all dependencies." +} + +display_configure_options() +{ + msg "configure options:" + for OPTION in "$@"; do + if [[ -n ${OPTION} ]]; then + msg "${OPTION}" + fi + done +} + + +enable_exit_on_error() +{ + eval "${OPTS_ENABLE}" +} + +disable_exit_on_error() +{ + eval "${OPTS_DISABLE}" +} + +strip_optimization() +{ + echo "$1" | sed -E ' + s/-O([0-3]|s|fast|g|z|size|speed)?b?/ /g + s/-g([0-3]|gdb|dwarf[0-9]*)?b?/ /g + s/[[:space:]]+/ /g + s/^ | $//g + ' +} + +create_directory() +{ + local DIRECTORY="$1" + local MODE="$2" + + if [[ -d "${DIRECTORY}" ]]; then + if [[ ${MODE} == "-f" ]]; then + msg_warn "Reinitializing '${DIRECTORY}'..." + rm -rf "${DIRECTORY}" + mkdir -p "${DIRECTORY}" + else + msg_warn "Reusing existing '${DIRECTORY}'..." + fi + else + msg "Initializing '${DIRECTORY}'..." + mkdir -p "${DIRECTORY}" + fi +} + +create_directory_force() +{ + create_directory "$@" -f +} + +pop_directory() +{ + msg_verbose "*** move pre: '$(pwd)'" + popd >/dev/null + msg_verbose "*** move post: '$(pwd)'" +} + +push_directory() +{ + msg_verbose "*** move pre: '$(pwd)'" + local DIRECTORY="$1" + pushd "${DIRECTORY}" >/dev/null + msg_verbose "*** move post: '$(pwd)'" +} + +remove_directory_force() +{ + msg_verbose "*** removing: '$@'" + rm -rf "$@" +} + +COLOR_CYAN='\e[0;96m' +COLOR_GREEN='\e[0;92m' +COLOR_RED='\e[0;91m' +COLOR_YELLOW='\e[0;93m' +COLOR_RESET='\e[0m' + +msg_heading() +{ + printf "\n********************** %b **********************\n" "$@" +} + +msg_verbose() +{ + if [[ "${DISPLAY_VERBOSE}" == "yes" ]]; then + printf "${COLOR_CYAN}%b${COLOR_RESET}\n" "$@" + fi +} + +msg() +{ + printf "%b\n" "$@" +} + +msg_success() +{ + printf "${COLOR_GREEN}%b${COLOR_RESET}\n" "$@" +} + +msg_warn() +{ + printf "${COLOR_YELLOW}%b${COLOR_RESET}\n" "$@" +} + +msg_error() +{ + >&2 printf "${COLOR_RED}%b${COLOR_RESET}\n" "$@" +} + +main "$@" diff --git a/builds/gnu/install-gnu.sh b/builds/gnu/install-gnu.sh new file mode 100755 index 00000000..fed1e0af --- /dev/null +++ b/builds/gnu/install-gnu.sh @@ -0,0 +1,972 @@ +#!/bin/bash +############################################################################### +# Copyright (c) 2014-2026 libbitcoin-node developers (see COPYING). +# +# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY +# +############################################################################### +# Script managing the build and installation of libbitcoin-node and its dependencies. +# +# Script options: +# --build-boost Build Boost libraries +# --build-secp256k1 Build libsecp256k1 libraries +# --build-src-dir= Location of sources. +# --build-obj-dir= Location of intermedia objects. +# --build-obj-dir-relative Use build-obj-dir as relative to project sources. +# --build-config= Specifies the build configuration. +# Valid values: { debug, release } +# Toolchain default behavior will occur if no value specified. +# --build-link= Specifies link mode. +# Valid values: { dynamic, static } +# Toolchain default behavior will occur if no value specified. +# --build-full-repositories Sync full github repositories. +# Default clones depth 1, single branch +# --build-parallel= Number of jobs to run simultaneously. +# Default: discovery +# --build-use-local-src Use existing sources in build-src-dir path. +# --prefix= Library install location. +# Default: /usr/local +# --verbose Display verbose script output. +# --help, -h Display usage, overriding script execution. +# +# All unrecognized options provided shall be passed as configuration +# options for all dependencies. + +OPTS_ENABLE="set -eo pipefail" +OPTS_DISABLE="set +e" + +eval "${OPTS_ENABLE}" +trap 'echo "FATAL ERROR: Command failed at line ${LINENO}: ${BASH_COMMAND}" >&2' ERR + +SEQUENTIAL=1 + +if [[ -z ${boost_URLBASE} ]]; then + boost_URLBASE="https://archives.boost.io/release/1.86.0/source/" +fi +if [[ -z ${boost_FILENAME} ]]; then + boost_FILENAME="boost_1_86_0.tar.bz2" +fi + +if [[ -z ${secp256k1_OWNER} ]]; then + secp256k1_OWNER="bitcoin-core" +fi +if [[ -z ${secp256k1_TAG} ]]; then + secp256k1_TAG="v0.7.0" +fi + +if [[ -z ${libbitcoin_system_OWNER} ]]; then + libbitcoin_system_OWNER="libbitcoin" +fi +if [[ -z ${libbitcoin_system_TAG} ]]; then + libbitcoin_system_TAG="master" +fi + +if [[ -z ${libbitcoin_database_OWNER} ]]; then + libbitcoin_database_OWNER="libbitcoin" +fi +if [[ -z ${libbitcoin_database_TAG} ]]; then + libbitcoin_database_TAG="master" +fi + +if [[ -z ${libbitcoin_network_OWNER} ]]; then + libbitcoin_network_OWNER="libbitcoin" +fi +if [[ -z ${libbitcoin_network_TAG} ]]; then + libbitcoin_network_TAG="master" +fi + +if [[ -z ${libbitcoin_node_OWNER} ]]; then + libbitcoin_node_OWNER="libbitcoin" +fi +if [[ -z ${libbitcoin_node_TAG} ]]; then + libbitcoin_node_TAG="master" +fi + +main() +{ + # argument consumption + + for OPTION in "$@"; do + case ${OPTION} in + (--build-boost) BUILD_boost="yes";; + (--build-secp256k1) BUILD_secp256k1="yes";; + (--build-src-dir=*) BUILD_SRC_DIR="${OPTION#*=}";; + (--build-obj-dir=*) BUILD_OBJ_DIR="${OPTION#*=}";; + (--build-obj-dir-relative) BUILD_OBJ_DIR_RELATIVE="yes";; + (--build-config=*) BUILD_CONFIG="${OPTION#*=}";; + (--build-link=*) BUILD_LINK="${OPTION#*=}";; + (--build-full-repositories) BUILD_FULL_REPOSITORIES="yes";; + (--build-use-local-src) BUILD_USE_LOCAL_SRC="yes";; + (--build-parallel=*) PARALLEL="${OPTION#*=}";; + (--prefix=*) PREFIX="${OPTION#*=}";; + (--verbose) DISPLAY_VERBOSE="yes";; + (--help|-h) DISPLAY_HELP="yes";; + esac + done + + CONFIGURE_OPTIONS_ORIGINAL=("$@") + CONFIGURE_OPTIONS=("$@") + CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--build-*/}") + CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--prefix=*/}") + CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--verbose/}") + msg_verbose "*** ARGUMENTS: ${CONFIGURE_OPTIONS_ORIGINAL[*]}" + msg_verbose "*** SANITIZED: ${CONFIGURE_OPTIONS[*]}" + + if [[ "${DISPLAY_VERBOSE}" == "yes" ]]; then + display_build_variables + fi + + + OS=$(uname -s) + + # defaults and sanitization: script static options + + # --build-src-dir + if [[ -z "${BUILD_SRC_DIR}" ]]; then + BUILD_SRC_DIR="$(pwd)" + msg_verbose "No build-src-dir specified, using default '${BUILD_SRC_DIR}'." + fi + + if [[ -d "${BUILD_SRC_DIR}" ]]; then + push_directory "${BUILD_SRC_DIR}" + BUILD_SRC_DIR="$(pwd)" + pop_directory + msg_verbose "Determined absolute path for build-src-dir '${BUILD_SRC_DIR}'." + else + create_directory "${BUILD_SRC_DIR}" + push_directory "${BUILD_SRC_DIR}" + BUILD_SRC_DIR="$(pwd)" + pop_directory + msg_verbose "Created build-src-dir '${BUILD_SRC_DIR}'." + fi + + # --build-obj-dir + if [[ -z "${BUILD_OBJ_DIR}" ]]; then + if [[ "${BUILD_OBJ_DIR_RELATIVE}" == "yes" ]]; then + BUILD_OBJ_DIR="obj" + msg_verbose "No build-obj-dir specified, using relative default '${BUILD_OBJ_DIR}'." + else + BUILD_OBJ_DIR="$(pwd)/obj" + msg_verbose "No build-obj-dir specified, using default '${BUILD_OBJ_DIR}'." + fi + fi + + if [[ "${BUILD_OBJ_DIR_RELATIVE}" == "yes" ]]; then + msg_verbose "Deferring relative path action for build-obj-dir '${BUILD_OBJ_DIR}'." + else + if [[ -d "${BUILD_OBJ_DIR}" ]]; then + push_directory "${BUILD_OBJ_DIR}" + BUILD_OBJ_DIR="$(pwd)" + pop_directory + msg_verbose "Determined absolute path for build-obj-dir '${BUILD_OBJ_DIR}'." + else + create_directory "${BUILD_OBJ_DIR}" + push_directory "${BUILD_OBJ_DIR}" + BUILD_OBJ_DIR="$(pwd)" + pop_directory + msg_verbose "Created build-obj-dir '${BUILD_OBJ_DIR}'." + fi + fi + + # --build-config + if [[ -z "${BUILD_CONFIG}" ]]; then + msg_verbose "No build-config specified." + elif [[ "${BUILD_CONFIG}" != "debug" ]] && [[ "${BUILD_CONFIG}" != "release" ]]; then + msg_error "Provided build-config '${BUILD_CONFIG}' not a valid value." + help + exit 1 + else + msg_verbose "Using provided build-config '${BUILD_CONFIG}'" + fi + + # --build-link + if [[ -z "${BUILD_LINK}" ]]; then + msg_verbose "No build-link specified." + elif [[ "${BUILD_LINK}" != "dynamic" ]] && [[ "${BUILD_LINK}" != "static" ]]; then + msg_error "Provided build-link ${BUILD_LINK}' not a valid value." + help + exit 1 + fi + + # --prefix + if [[ -z "${PREFIX}" ]]; then + # Always set a prefix (required for OSX and lib detection). + PREFIX="/usr/local" + msg_verbose "No prefix specified, defaulting to '${PREFIX}'." + else + # Incorporate the custom libdir into each object, for link time resolution + if [[ -z "${LD_RUN_PATH}" ]]; then + export LD_RUN_PATH="${PREFIX}/lib" + else + export LD_RUN_PATH="${LD_RUN_PATH}:${PREFIX}/lib" + fi + + if [[ -z "${LD_LIBRARY_PATH}" ]]; then + export LD_LIBRARY_PATH="${PREFIX}/lib" + else + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${PREFIX}/lib" + fi + fi + + if [[ -n "${PREFIX}" ]]; then + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]}" "--prefix=${PREFIX}" ) + fi + + if [[ -n "${PREFIX}" ]]; then + # Set the prefix-based package config directory. + PREFIX_PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig" + + # Prioritize prefix package config in PKG_CONFIG_PATH search path. + if [[ -n "${PKG_CONFIG_PATH}" ]]; then + export PKG_CONFIG_PATH="${PREFIX_PKG_CONFIG_PATH}:${PKG_CONFIG_PATH}" + else + export PKG_CONFIG_PATH="${PREFIX_PKG_CONFIG_PATH}" + fi + + with_pkgconfigdir="--with-pkgconfigdir=${PREFIX_PKG_CONFIG_PATH}" + fi + + # --parallel + if [[ -z "${PARALLEL}" ]]; then + if [[ ${OS} == Linux ]]; then + PARALLEL=$(nproc) + elif [[ ${OS} == Darwin ]] || [[ ${OS} == OpenBSD ]]; then + PARALLEL=$(sysctl -n hw.ncpu) + else + msg_error "Unsupported system: '${OS}'" + msg_error " Unable to determine value for '--parallel='" + msg_error " Please specify explicitly to continue." + msg_error "" + help + exit 1 + fi + fi + + # state rationalization of standard build variables + + if [[ ${OS} == OpenBSD ]]; then + make() { gmake "$@"; } + fi + + if [[ -z "${STDLIB}" ]]; then + if [[ ${OS} == Darwin ]]; then + STDLIB="c++" + elif [[ ${OS} == OpenBSD ]]; then + STDLIB="estdc++" + else + STDLIB="stdc++" + fi + else + define_message_verbose "STDLIB using defined value '${STDLIB}'" + fi + + if [[ -z "${CC}" ]]; then + if [[ ${OS} == Darwin ]]; then + export CC="clang" + elif [[ ${OS} == OpenBSD ]]; then + export CC="egcc" + fi + else + msg_verbose "CC using defined value '${CC}'" + fi + + if [[ -z "${CXX}" ]]; then + if [[ ${OS} == Darwin ]]; then + export CXX="clang++" + elif [[ ${OS} == OpenBSD ]]; then + export CXX="eg++" + fi + else + msg_verbose "CXX using defined value '${CXX}'" + fi + + # translate BUILD_CONFIG to ZFLAGS + if [[ -n "${BUILD_CONFIG}" ]]; then + msg_verbose "*** Build config specified, calculating flags..." + + if [[ "${BUILD_CONFIG}" == "debug" ]]; then + BUILD_FLAGS="-Og -g" + elif [[ "${BUILD_CONFIG}" == "release" ]]; then + BUILD_FLAGS="-O3" + fi + + if [[ -z "${CFLAGS}" ]]; then + export CFLAGS="${BUILD_FLAGS}" + msg_verbose "Exporting CFLAGS '${CFLAGS}'" + else + msg_verbose "CFLAGS intitally '${CFLAGS}'" + SANITIZED_CFLAGS=$(strip_optimization "$CFLAGS") + export CFLAGS="${SANITIZED_CFLAGS} ${BUILD_FLAGS}" + msg_verbose "CFLAGS modified to '${CFLAGS}'" + fi + + if [[ -z "${CXXFLAGS}" ]]; then + export CXXFLAGS="${BUILD_FLAGS}" + msg_verbose "Exporting CXXFLAGS '${CXXFLAGS}'" + else + msg_verbose "CXXFLAGS intitally '${CXXFLAGS}'" + SANITIZED_CXXFLAGS=$(strip_optimization "$CXXFLAGS") + export CXXFLAGS="${SANITIZED_CXXFLAGS} ${BUILD_FLAGS}" + msg_verbose "CXXFLAGS modified to '${CXXFLAGS}'" + fi + fi + + # Specify or remove --enable-ndebug for gnu toolchain on release + if [[ "${BUILD_CONFIG}" == "debug" ]]; then + CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--enable-ndebug/}") + elif [[ "${BUILD_CONFIG}" == "release" ]]; then + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]}" "--enable-ndebug" ) + fi + + # translate BUILD_LINK to appropriate arguments + if [[ -n "${BUILD_LINK}" ]]; then + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]/--disable-shared=*}" ) + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]/--enable-shared=*}" ) + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]/--disable-static=*}" ) + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]/--enable-static=*}" ) + + if [[ "${BUILD_LINK}" == "dynamic" ]]; then + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]}" "--enable-shared" "--disable-static" ) + else + CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]}" "--disable-shared" "--enable-static" ) + fi + fi + + if [[ ${OS} == Linux && ${CC} == clang* ]] || [[ ${OS} == OpenBSD ]]; then + export LDLIBS="-l${STDLIB} ${LDLIBS}" + msg_verbose "LDLIBS has been manipulated to encode STDLIB linkage." + fi + + # defaults and sanitization: generated options + + if [[ -n "${BUILD_boost}" ]]; then + export BOOST_ROOT="${PREFIX}" + with_boost="--with-boost=${PREFIX}" + fi + + REMAP=() + for argument in "${CONFIGURE_OPTIONS[@]}"; do + if [[ -n "${argument}" ]]; then + REMAP+=( "${argument}" ) + fi + done + CONFIGURE_OPTIONS=( "${REMAP[@]}" ) + unset REMAP + + # handle help + if [[ "${DISPLAY_HELP}" == "yes" ]]; then + help + return 0 + fi + + msg_heading "Configuration" + display_build_variables + + msg_heading "Toolchain Configuration Parameters" + display_toolchain_variables + + if [[ "${DISPLAY_VERBOSE}" == "yes" ]]; then + msg_heading "State" + display_constants + fi + + # declarations + + boost_FLAGS=( + "-Wno-enum-constexpr-conversion") + + boost_OPTIONS=( + "--with-iostreams" + "--with-locale" + "--with-program_options" + "--with-regex" + "--with-thread" + "--with-url" + "--with-test") + + secp256k1_FLAGS=( + "-w") + + secp256k1_OPTIONS=( + "--disable-tests" + "--enable-experimental" + "--enable-module-recovery" + "--enable-module-schnorrsig") + + libbitcoin_system_FLAGS=() + + libbitcoin_system_OPTIONS=( + "--without-tests" + "--without-examples" + "${with_boost}" + "${with_pkgconfigdir}") + + libbitcoin_database_FLAGS=() + + libbitcoin_database_OPTIONS=( + "--without-tests" + "--without-tools" + "${with_boost}" + "${with_pkgconfigdir}") + + libbitcoin_network_FLAGS=() + + libbitcoin_network_OPTIONS=( + "--without-tests" + "${with_boost}" + "${with_pkgconfigdir}") + + libbitcoin_node_FLAGS=() + + libbitcoin_node_OPTIONS=( + "${with_boost}" + "${with_pkgconfigdir}") + + if [[ ${BUILD_boost} == "yes" ]]; then + source_archive "boost" "${boost_FILENAME}" "${boost_URLBASE}" "bzip2" + local SAVE_CPPFLAGS="${CPPFLAGS}" + export CPPFLAGS="${CPPFLAGS} ${boost_FLAGS[@]}" + build_boost "boost" "${boost_OPTIONS[@]}" + export CPPFLAGS="${SAVE_CPPFLAGS}" + fi + + if [[ ${BUILD_secp256k1} == "yes" ]]; then + source_github "${secp256k1_OWNER}" "secp256k1" "${secp256k1_TAG}" + local SAVE_CPPFLAGS="${CPPFLAGS}" + export CPPFLAGS="${CPPFLAGS} ${secp256k1_FLAGS[@]}" + build_gnu "secp256k1" "." "${PARALLEL}" "${secp256k1_OPTIONS[@]}" "${CONFIGURE_OPTIONS[@]}" + install_make "secp256k1" + export CPPFLAGS="${SAVE_CPPFLAGS}" + fi + + source_github "${libbitcoin_system_OWNER}" "libbitcoin-system" "${libbitcoin_system_TAG}" + local SAVE_CPPFLAGS="${CPPFLAGS}" + export CPPFLAGS="${CPPFLAGS} ${libbitcoin_system_FLAGS[@]}" + build_gnu "libbitcoin-system" "." "${PARALLEL}" "${libbitcoin_system_OPTIONS[@]}" "${CONFIGURE_OPTIONS[@]}" + install_make "libbitcoin-system" + export CPPFLAGS="${SAVE_CPPFLAGS}" + + source_github "${libbitcoin_database_OWNER}" "libbitcoin-database" "${libbitcoin_database_TAG}" + local SAVE_CPPFLAGS="${CPPFLAGS}" + export CPPFLAGS="${CPPFLAGS} ${libbitcoin_database_FLAGS[@]}" + build_gnu "libbitcoin-database" "." "${PARALLEL}" "${libbitcoin_database_OPTIONS[@]}" "${CONFIGURE_OPTIONS[@]}" + install_make "libbitcoin-database" + export CPPFLAGS="${SAVE_CPPFLAGS}" + + source_github "${libbitcoin_network_OWNER}" "libbitcoin-network" "${libbitcoin_network_TAG}" + local SAVE_CPPFLAGS="${CPPFLAGS}" + export CPPFLAGS="${CPPFLAGS} ${libbitcoin_network_FLAGS[@]}" + build_gnu "libbitcoin-network" "." "${PARALLEL}" "${libbitcoin_network_OPTIONS[@]}" "${CONFIGURE_OPTIONS[@]}" + install_make "libbitcoin-network" + export CPPFLAGS="${SAVE_CPPFLAGS}" + + source_github "${libbitcoin_node_OWNER}" "libbitcoin-node" "${libbitcoin_node_TAG}" + local SAVE_CPPFLAGS="${CPPFLAGS}" + export CPPFLAGS="${CPPFLAGS} ${libbitcoin_node_FLAGS[@]}" + build_gnu "libbitcoin-node" "." "${PARALLEL}" "${libbitcoin_node_OPTIONS[@]}" "${CONFIGURE_OPTIONS[@]}" + test_make "libbitcoin-node" "check" "${PARALLEL}" + install_make "libbitcoin-node" + export CPPFLAGS="${SAVE_CPPFLAGS}" + + msg_success "Completed successfully." +} + +source_archive() +{ + local PROJECT="$1" + local FILENAME="$2" + local URL_BASE="$3" + local COMPRESSION="$4" + shift 4 + + msg_heading "Preparing to acquire ${PROJECT}" + + push_directory "${BUILD_SRC_DIR}" + + if [ -d "${PROJECT}" ] && + [[ "${BUILD_USE_LOCAL_SRC}" == "yes" ]]; then + msg_warn "Reusing existing '${PROJECT}' directory..." + return 0 + fi + + if [ -d "${PROJECT}" ]; then + msg_warn "Encounted existing '${PROJECT}' directory, removing..." + remove_directory_force "${PROJECT}" + fi + + msg "Retrieving ${PROJECT}..." + + create_directory "${PROJECT}" + push_directory "${PROJECT}" + + local TAR="tar" + local WGET="wget --quiet" + + # retrieve file + ${WGET} --output-document "${FILENAME}" "${URL_BASE}${FILENAME}" + # ${WGET} --output-document "${FILENAME}" "${URL_BASE}${FILENAME}" + + # extract to expected path + ${TAR} --extract --file "${FILENAME}" --${COMPRESSION} --strip-components=1 + # ${TAR} --extract --file "${FILENAME}" "--${COMPRESSION}" --strip-components=1 + + # pop ${PROJECT} + pop_directory + + # pop ${BUILD_SRC_DIR} + pop_directory + + msg_success "Completed download and extraction successfully." +} + +source_github() +{ + local OWNER="$1" + local REPOSITORY="$2" + local TAG="$3" + shift 3 + + msg_heading "Preparing to acquire ${OWNER}/${REPOSITORY}/${TAG}" + + local GIT_CLONE="git clone" + local CLONE_OPTIONS="--depth 1 --single-branch" + + if [[ "${BUILD_FULL_REPOSITORIES}" == "yes" ]]; then + CLONE_OPTIONS="" + fi + + push_directory "${BUILD_SRC_DIR}" + + if [ -d "${REPOSITORY}" ] && + [[ "${BUILD_USE_LOCAL_SRC}" == "yes" ]]; then + msg_warn "Reusing existing '${REPOSITORY}'..." + pop_directory # BUILD_SRC_DIR + return 0 + fi + + if [ -d "${REPOSITORY}" ]; then + msg_warn "Encounted existing '${REPOSITORY}' directory, removing..." + remove_directory_force "${REPOSITORY}" + fi + + msg "Cloning ${OWNER}/${REPOSITORY}/${TAG}..." + + ${GIT_CLONE} ${CLONE_OPTIONS} --branch "${TAG}" "https://github.com/${OWNER}/${REPOSITORY}" + + # pop BUILD_SRC_DIR + pop_directory +} + +install_make() +{ + local PROJECT="$1" + shift + + msg "Preparing to install ${PROJECT}" + + push_directory "${BUILD_SRC_DIR}/${PROJECT}" + + if [[ "${BUILD_OBJ_DIR_RELATIVE}" == "yes" ]]; then + push_directory "${BUILD_OBJ_DIR}" + else + push_directory "${BUILD_OBJ_DIR}/${PROJECT}" + fi + + make install + + if [[ ${OS} == Linux ]] && [[ "${PREFIX}" == "/usr/local" ]]; then + ldconfig + fi + + pop_directory # BUILD_OBJ_DIR + pop_directory # BUILD_SRC_DIR/PROJECT + + msg_success "'${PROJECT}' installation compelete." +} + +test_make() +{ + local PROJECT="$1" + local TARGET="$2" + local JOBS="$3" + shift 3 + + msg "Preparing to test ${PROJECT}" + + push_directory "${BUILD_SRC_DIR}/${PROJECT}" + + if [[ "${BUILD_OBJ_DIR_RELATIVE}" == "yes" ]]; then + push_directory "${BUILD_OBJ_DIR}" + else + push_directory "${BUILD_OBJ_DIR}/${PROJECT}" + fi + + disable_exit_on_error + + if [[ ${JOBS} -gt ${SEQUENTIAL} ]]; then + make -j${JOBS} ${TARGET} VERBOSE=1 + else + make ${TARGET} VERBOSE=1 + fi + + local RESULT=$? + + # Test runners emit to the test.log file. + if [[ -e "test.log" ]]; then + cat "test.log" + fi + + enable_exit_on_error + + if [[ ${RESULT} -ne 0 ]]; then + exit ${RESULT} + fi + + pop_directory # BUILD_OBJ_DIR + pop_directory # BUILD_SRC_DIR/PROJECT + + msg_success "'${PROJECT}' test compelete." +} + +build_boost() +{ + local PROJECT="$1" + shift + + msg_heading "Preparing to build ${PROJECT}" + + push_directory "${BUILD_SRC_DIR}/${PROJECT}" + + local SAVE_IFS="${IFS}" + IFS=' ' + + # Compute configuration + if [[ "${BUILD_LINK}" == "dynamic" ]]; then + BOOST_LINK="shared" + elif [[ "${BUILD_LINK}" == "static" ]]; then + BOOST_LINK="static" + else + BOOST_LINK="static,shared" + fi + + if [[ -n ${CC} ]]; then + BOOST_TOOLSET="toolset=${CC}" + fi + + if [[ (${OS} == Linux && ${CC} == clang*) || (${OS} == OpenBSD) ]]; then + STDLIB_FLAG="-stdlib=lib${STDLIB}" + BOOST_CXXFLAGS="cxxflags=${STDLIB_FLAG}" + BOOST_LINKFLAGS="linkflags=${STDLIB_FLAG}" + fi + + guessed_toolset=`${BUILD_SRC_DIR}/${PROJECT}/tools/build/src/engine/build.sh --guess-toolset` + CXXFLAGS="-w" ${BUILD_SRC_DIR}/${PROJECT}/tools/build/src/engine/build.sh ${guessed_toolset} --cxxflags="-w" + cp "${BUILD_SRC_DIR}/${PROJECT}/tools/build/src/engine/b2" . + + if [[ -n "${BOOST_CXXFLAGS}" ]]; then + BOOST_CXXFLAGS="${BOOST_CXXFLAGS} ${boost_FLAGS[@]}" + else + BOOST_CXXFLAGS="cxxflags=${boost_FLAGS[@]}" + fi + + # Prebuild status report + msg "${PROJECT} configuration." + msg "--------------------------------------------------------------------" + msg "variant : release" + msg "threading : multi" + msg "toolset : ${CC}" + msg "boost cxxflags : ${BOOST_CXXFLAGS}" + msg "boost linkflags : ${BOOST_LINKFLAGS}" + msg "link : ${BOOST_LINK}" + msg "-sNO_BZIP2 : 1" + msg "-sNO_ZSTD : 1" + msg "-j : ${PARALLEL}" + msg "-d0 : [supress informational messages]" + msg "-q : [stop at the first error]" + msg "--reconfigure : [ignore cached configuration]" + msg "--prefix : ${PREFIX}" + msg "BOOST_OPTIONS : $*" + msg "cxxflags (ignored) : ${CXXFLAGS}" + msg "--------------------------------------------------------------------" + + # Begin build + ./bootstrap.sh --with-bjam=./b2 --prefix=${PREFIX} + + ./b2 install \ + "cxxstd=20" \ + "variant=release" \ + "threading=multi" \ + "${BOOST_TOOLSET}" \ + "${BOOST_CXXFLAGS}" \ + "${BOOST_LINKFLAGS}" \ + "link=${BOOST_LINK}" \ + "warnings=off" \ + "-sNO_BZIP2=1" \ + "-sNO_ZSTD=1" \ + "-j ${PARALLEL}" \ + "-d0" \ + "-q" \ + "--reconfigure" \ + "--prefix=${PREFIX}" \ + "$@" + + IFS="${SAVE_IFS}" + + pop_directory # BUILD_SRC_DIR +} + +build_gnu() +{ + local PROJECT="$1" + local RELATIVE_PATH="$2" + local JOBS="$3" + shift 3 + + local VERBOSITY_GNU="" + local VERBOSITY_MAKE="" + + if [[ "${DISPLAY_VERBOSE}" == "yes" ]]; then + VERBOSITY_GNU="--verbose" + VERBOSITY_MAKE="VERBOSE=1" + fi + + msg_heading "Preparing to build ${PROJECT}" + + + # directory rationalization + push_directory "${BUILD_SRC_DIR}/${PROJECT}" + push_directory "${RELATIVE_PATH}" + local BUILD_PATH="$(pwd)" + pop_directory + + if [[ "${BUILD_OBJ_DIR_RELATIVE}" == "yes" ]]; then + create_directory_force "${BUILD_OBJ_DIR}" + push_directory "${BUILD_OBJ_DIR}" + else + push_directory "${BUILD_OBJ_DIR}" + create_directory_force "${PROJECT}" + pop_directory + push_directory "${BUILD_OBJ_DIR}/${PROJECT}" + fi + + # configuration + push_directory "${BUILD_PATH}" + autoreconf ${VERBOSITY_GNU} -i + pop_directory # BUILD_PATH + + display_configure_options "$@" + + "${BUILD_PATH}/configure" ${VERBOSITY_GNU} "$@" + + # make + if [[ ${JOBS} -gt ${SEQUENTIAL} ]]; then + make -j${JOBS} ${VERBOSITY_MAKE} + else + make + fi + + pop_directory # BUILD_OBJ_DIR + pop_directory # BUILD_SRC_DIR/PROJECT + msg_success "'${PROJECT}' built successfully." +} + +display_build_variables() +{ + msg "BUILD_boost : ${BUILD_boost}" + msg "BUILD_secp256k1 : ${BUILD_secp256k1}" + msg "BUILD_SRC_DIR : ${BUILD_SRC_DIR}" + msg "BUILD_OBJ_DIR : ${BUILD_OBJ_DIR}" + msg "BUILD_OBJ_DIR_RELATIVE : ${BUILD_OBJ_DIR_RELATIVE}" + msg "BUILD_CONFIG : ${BUILD_CONFIG}" + msg "BUILD_LINK : ${BUILD_LINK}" + msg "BUILD_FULL_REPOSITORIES : ${BUILD_FULL_REPOSITORIES}" + msg "BUILD_USE_LOCAL_SRC : ${BUILD_USE_LOCAL_SRC}" + msg "PARALLEL : ${PARALLEL}" + msg "PREFIX : ${PREFIX}" + msg "DISPLAY_VERBOSE : ${DISPLAY_VERBOSE}" + msg "CONFIGURE_OPTIONS : ${CONFIGURE_OPTIONS[*]}" +if [[ "${DISPLAY_VERBOSE}" == "yes" ]]; then + msg "CONFIGURE_OPTIONS_ORIGINAL : ${CONFIGURE_OPTIONS_ORIGINAL[*]}" +fi +} + +display_toolchain_variables() +{ + + msg "CC : ${CC}" + msg "CFLAGS : ${CFLAGS}" + msg "CXX : ${CXX}" + msg "CXXFLAGS : ${CXXFLAGS}" + msg "LD_RUN_PATH : ${LD_RUN_PATH}" + msg "LD_LIBRARY_PATH : ${LD_LIBRARY_PATH}" + msg "PKG_CONFIG_PATH : ${PKG_CONFIG_PATH}" + msg "LDLIBS : ${LDLIBS}" + msg "BOOST_ROOT : ${BOOST_ROOT}" +} + +display_constants() +{ + msg "boost_URLBASE : ${boost_URLBASE}" + msg "boost_FILENAME : ${boost_FILENAME}" + + msg "secp256k1_OWNER : ${secp256k1_OWNER}" + msg "secp256k1_TAG : ${secp256k1_TAG}" + + msg "libbitcoin_system_OWNER : ${libbitcoin_system_OWNER}" + msg "libbitcoin_system_TAG : ${libbitcoin_system_TAG}" + + msg "libbitcoin_database_OWNER : ${libbitcoin_database_OWNER}" + msg "libbitcoin_database_TAG : ${libbitcoin_database_TAG}" + + msg "libbitcoin_network_OWNER : ${libbitcoin_network_OWNER}" + msg "libbitcoin_network_TAG : ${libbitcoin_network_TAG}" + + msg "libbitcoin_node_OWNER : ${libbitcoin_node_OWNER}" + msg "libbitcoin_node_TAG : ${libbitcoin_node_TAG}" +} + +help() +{ + msg "Script managing the build and installation of libbitcoin-node and its dependencies." + msg "" + msg "Script options:" + msg "--build-boost Build Boost libraries" + msg "--build-secp256k1 Build libsecp256k1 libraries" + msg "--build-src-dir= Location of sources." + msg "--build-obj-dir= Location of intermedia objects." + msg "--build-obj-dir-relative Use build-obj-dir as relative to project sources." + msg "--build-config= Specifies the build configuration." + msg " Valid values: { debug, release }" + msg " Toolchain default behavior will occur if no value specified." + msg "--build-link= Specifies link mode." + msg " Valid values: { dynamic, static }" + msg " Toolchain default behavior will occur if no value specified." + msg "--build-full-repositories Sync full github repositories." + msg " Default clones depth 1, single branch" + msg "--build-parallel= Number of jobs to run simultaneously." + msg " Default: discovery" + msg "--build-use-local-src Use existing sources in build-src-dir path." + msg "--prefix= Library install location." + msg " Default: /usr/local" + msg "--verbose Display verbose script output." + msg "--help, -h Display usage, overriding script execution." + msg "" + msg "All unrecognized options provided shall be passed as configuration" + msg "options for all dependencies." +} + +display_configure_options() +{ + msg "configure options:" + for OPTION in "$@"; do + if [[ -n ${OPTION} ]]; then + msg "${OPTION}" + fi + done +} + + +enable_exit_on_error() +{ + eval "${OPTS_ENABLE}" +} + +disable_exit_on_error() +{ + eval "${OPTS_DISABLE}" +} + +strip_optimization() +{ + echo "$1" | sed -E ' + s/-O([0-3]|s|fast|g|z|size|speed)?b?/ /g + s/-g([0-3]|gdb|dwarf[0-9]*)?b?/ /g + s/[[:space:]]+/ /g + s/^ | $//g + ' +} + +create_directory() +{ + local DIRECTORY="$1" + local MODE="$2" + + if [[ -d "${DIRECTORY}" ]]; then + if [[ ${MODE} == "-f" ]]; then + msg_warn "Reinitializing '${DIRECTORY}'..." + rm -rf "${DIRECTORY}" + mkdir -p "${DIRECTORY}" + else + msg_warn "Reusing existing '${DIRECTORY}'..." + fi + else + msg "Initializing '${DIRECTORY}'..." + mkdir -p "${DIRECTORY}" + fi +} + +create_directory_force() +{ + create_directory "$@" -f +} + +pop_directory() +{ + msg_verbose "*** move pre: '$(pwd)'" + popd >/dev/null + msg_verbose "*** move post: '$(pwd)'" +} + +push_directory() +{ + msg_verbose "*** move pre: '$(pwd)'" + local DIRECTORY="$1" + pushd "${DIRECTORY}" >/dev/null + msg_verbose "*** move post: '$(pwd)'" +} + +remove_directory_force() +{ + msg_verbose "*** removing: '$@'" + rm -rf "$@" +} + +COLOR_CYAN='\e[0;96m' +COLOR_GREEN='\e[0;92m' +COLOR_RED='\e[0;91m' +COLOR_YELLOW='\e[0;93m' +COLOR_RESET='\e[0m' + +msg_heading() +{ + printf "\n********************** %b **********************\n" "$@" +} + +msg_verbose() +{ + if [[ "${DISPLAY_VERBOSE}" == "yes" ]]; then + printf "${COLOR_CYAN}%b${COLOR_RESET}\n" "$@" + fi +} + +msg() +{ + printf "%b\n" "$@" +} + +msg_success() +{ + printf "${COLOR_GREEN}%b${COLOR_RESET}\n" "$@" +} + +msg_warn() +{ + printf "${COLOR_YELLOW}%b${COLOR_RESET}\n" "$@" +} + +msg_error() +{ + >&2 printf "${COLOR_RED}%b${COLOR_RESET}\n" "$@" +} + +main "$@" diff --git a/builds/msvc/build-msvc.cmd b/builds/msvc/build-msvc.cmd new file mode 100644 index 00000000..4273b0ca --- /dev/null +++ b/builds/msvc/build-msvc.cmd @@ -0,0 +1,439 @@ +@echo off +setlocal EnableDelayedExpansion +setlocal EnableExtensions +REM ########################################################################### +REM # Copyright (c) 2014-2026 libbitcoin-node developers (see COPYING). +REM # +REM # GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY +REM # +REM ########################################################################### + +REM Script managing the build of libbitcoin-node. +REM +REM Script options: +REM --build-config config Build configuration. +REM --build-platform platform Build platform. +REM --build-version version Build MSVC version. +REM --build-src-dir path Location of sources. +REM --build-full-repositories Sync full github repositories. +REM --build-use-local-src Use existing sources in build-src-dir path. +REM --verbose Display verbose script output. +REM --help, -h Display usage, overriding script execution. +REM + +if "!MSBUILD_EXE!" == "" ( + set "MSBUILD_EXE=msbuild" +) + +if "!NUGET_EXE!" == "" ( + set "NUGET_EXE=nuget" +) + +if "!libbitcoin_system_OWNER!" == "" ( + set "libbitcoin_system_OWNER=libbitcoin" +) +if "!libbitcoin_system_TAG!" == "" ( + set "libbitcoin_system_TAG=master" +) + +if "!libbitcoin_database_OWNER!" == "" ( + set "libbitcoin_database_OWNER=libbitcoin" +) +if "!libbitcoin_database_TAG!" == "" ( + set "libbitcoin_database_TAG=master" +) + +if "!libbitcoin_network_OWNER!" == "" ( + set "libbitcoin_network_OWNER=libbitcoin" +) +if "!libbitcoin_network_TAG!" == "" ( + set "libbitcoin_network_TAG=master" +) + +if "!libbitcoin_node_OWNER!" == "" ( + set "libbitcoin_node_OWNER=libbitcoin" +) +if "!libbitcoin_node_TAG!" == "" ( + set "libbitcoin_node_TAG=master" +) + +:main + call :parse_input %* + + if "!DISPLAY_VERBOSE!" == "yes" ( + call :msg_heading "Pre-sanitized state" + call :display_build_variables + call :display_toolchain_variables + call :display_constants + ) + + if "!SHOW_HELP!" == "yes" ( + call :help + exit /b 0 + ) + + if "!BUILD_SRC_DIR!" == "" ( + set "BUILD_SRC_DIR=!CD!" + call :msg_warn "No source directory specified, using '!BUILD_SRC_DIR!'." + ) else ( + call :push_directory "!BUILD_SRC_DIR!" + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + set "BUILD_SRC_DIR=!CD!" + call :msg_verbose "Resolving potential relative path '!BUILD_SRC_DIR!'." + call :pop_directory + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + ) + + if "!NUGET_PKG_PATH!" == "" ( + set "NUGET_PKG_PATH=!BUILD_SRC_DIR!\.nuget\packages" + ) + + if not exist "!NUGET_PKG_PATH!" ( + call :msg_warn "NUGET_PKG_PATH does not exist, creating..." + call :create_directory_force "!NUGET_PKG_PATH!" + call :msg_success "NUGET_PKG_PATH: '%NUGET_PKG_PATH%' created successfully." + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + ) else ( + call :msg_warn "NUGET_PKG_PATH exists, reusing..." + ) + + if "!BUILD_CONFIG!" == "" ( + call :msg_error "Build configuration required." + call :help + exit /b 1 + ) + + if "!BUILD_VERSION!" == "" ( + set "BUILD_VERSION=vs2022" + call :msg_warn "Build msvc version not provided, defaulting to '!BUILD_VERSION!'." + ) + + if "!BUILD_PLATFORM!" == "" ( + set "BUILD_PLATFORM=x64" + call :msg_warn "Build platform not provided, defaulting to '!BUILD_PLATFORM!'." + ) + + if "!MSBUILD_VERBOSE!" == "" ( + if "!DISPLAY_VERBOSE!" == "yes" ( + set "MSBUILD_VERBOSE=diagnostic" + ) else ( + set "MSBUILD_VERBOSE=minimal" + ) + ) + + call :msg_heading "Configuration" + call :display_build_variables + + call :msg_heading "Toolchain Configuration Parameters" + call :display_toolchain_variables + + if "!DISPLAY_VERBOSE!" == "yes" ( + call :msg_heading "State" + call :display_constants + ) + + call :push_directory "!BUILD_SRC_DIR!" + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + + call :source_github "!libbitcoin_system_OWNER!" "libbitcoin-system" "!libbitcoin_system_TAG!" + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + call :build_msbuild "libbitcoin-system" "builds\msvc\%proj_version%" "libbitcoin-system" + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + + call :source_github "!libbitcoin_database_OWNER!" "libbitcoin-database" "!libbitcoin_database_TAG!" + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + call :build_msbuild "libbitcoin-database" "builds\msvc\%proj_version%" "libbitcoin-database" + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + + call :source_github "!libbitcoin_network_OWNER!" "libbitcoin-network" "!libbitcoin_network_TAG!" + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + call :build_msbuild "libbitcoin-network" "builds\msvc\%proj_version%" "libbitcoin-network" + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + + call :source_github "!libbitcoin_node_OWNER!" "libbitcoin-node" "!libbitcoin_node_TAG!" + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + call :build_msbuild "libbitcoin-node" "builds\msvc\%proj_version%" + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + + call :pop_directory + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + + call :msg_success "Build process completed successfully." + if not defined CI ( + pause + ) + + exit /b 0 + +:parse_input + if "%~1" == "" ( + goto :end_parse_input + ) else if "%~1" == "--build-src-dir" ( + set "BUILD_SRC_DIR=%~2" + shift + ) else if "%~1" == "--build-config" ( + set "BUILD_CONFIG=%~2" + shift + ) else if "%~1" == "--build-platform" ( + set "BUILD_PLATFORM=%~2" + shift + ) else if "%~1" == "--build-version" ( + set "BUILD_VERSION=%~2" + shift + ) else if "%~1" == "--build-full-repositories" ( + set "BUILD_FULL_REPOSITORIES=yes" + ) else if "%~1" == "--build-use-local-src" ( + set "BUILD_USE_LOCAL_SRC=yes" + ) else if "%~1" == "--verbose" ( + set "DISPLAY_VERBOSE=yes" + ) else if "%~1" == "-v" ( + set "DISPLAY_VERBOSE=yes" + ) else if "%~1" == "--help" ( + set "SHOW_HELP=yes" + ) else if "%~1" == "-h" ( + set "SHOW_HELP=yes" + ) + + shift + goto :parse_input + +:end_parse_input + exit /b 0 + + +:source_github + set "OWNER=%~1" + set "REPOSITORY=%~2" + set "TAG=%~3" + set "CLONE_OPTIONS=--depth 1 --single-branch" + + if "!BUILD_FULL_REPOSITORIES!" == "yes" ( + set "CLONE_OPTIONS=" + ) + + call :msg_heading "Preparing to aquire %OWNER%/%REPOSITORY%/%TAG%" + call :push_directory "!BUILD_SRC_DIR!" + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + + if exist "%REPOSITORY%" ( + if "!BUILD_USE_LOCAL_SRC!" == "yes" ( + call :msg_warn "Reusing existing '%REPOSITORY%'..." + call :pop_directory + exit /b %ERRORLEVEL% + ) + + call :msg_warn "Encountered existing '%REPOSITORY%' directory, removing..." + call :remove_directory_force "%REPOSITORY%" + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + ) + + call :msg "Cloning %OWNER%/%REPOSITORY%/%TAG%..." + call git clone !CLONE_OPTIONS! --branch %TAG% "https://github.com/%OWNER%/%REPOSITORY%" + if %ERRORLEVEL% neq 0 ( + call :msg_error "Clone of '%OWNER%/%REPOSITORY%/%TAG%' failed." + call :pop_directory + exit /b 1 + ) + + call :pop_directory + exit /b %ERRORLEVEL% + +:build_msbuild + set "PROJECT=%~1" + set "RELATIVE_PATH=%~2" + set "TARGET=%~3" + + if "%TARGET%" == "" ( + set "TARGET_ARG=" + ) else ( + set "TARGET_ARG=/target:%TARGET%:Rebuild" + ) + + call :push_directory "!BUILD_SRC_DIR!\%PROJECT%\%RELATIVE_PATH%\!BUILD_VERSION!" + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + + call :nuget_restore "%PROJECT%" + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + + !MSBUILD_EXE! /verbosity:!MSBUILD_VERBOSE! /p:Platform=!BUILD_PLATFORM! /p:Configuration=!BUILD_CONFIG! /p:PreferredToolArchitecture=x64 %TARGET_ARG% %PROJECT%.sln /p:PreBuildEventUseInBuild=false /p:PostBuildEventUseInBuild=false + + if %ERRORLEVEL% neq 0 ( + call :msg_error "!MSBUILD_EXE! /verbosity:!MSBUILD_VERBOSE! /p:Platform=!BUILD_PLATFORM! /p:Configuration=!BUILD_CONFIG! /p:PreferredToolArchitecture=x64 %TARGET_ARG% %PROJECT%.sln /p:PreBuildEventUseInBuild=false /p:PostBuildEventUseInBuild=false" + call :pop_directory + exit /b 1 + ) + + call :msg_success "'%PROJECT%' built successfully." + call :pop_directory + exit /b %ERRORLEVEL% + +:nuget_restore + call :msg_verbose "nuget restore %~1.sln to !NUGET_PKG_PATH!" + !NUGET_EXE! restore "%~1.sln" -OutputDirectory !NUGET_PKG_PATH! + if %ERRORLEVEL% neq 0 ( + call :msg_error "nuget restore failed." + exit /b 1 + ) + + call :msg_success "nuget restoration for %~1 complete." + exit /b %ERRORLEVEL% + +:display_build_variables + call :msg "BUILD_CONFIG : !BUILD_CONFIG!" + call :msg "BUILD_PLATFORM : !BUILD_PLATFORM!" + call :msg "BUILD_VERSION : !BUILD_VERSION!" + call :msg "BUILD_SRC_DIR : !BUILD_SRC_DIR!" + call :msg "BUILD_FULL_REPOSITORIES : !BUILD_FULL_REPOSITORIES!" + call :msg "BUILD_USE_LOCAL_SRC : !BUILD_USE_LOCAL_SRC!" + call :msg "DISPLAY_VERBOSE : !DISPLAY_VERBOSE!" + call :msg "SHOW_HELP : !SHOW_HELP!" + exit /b %ERRORLEVEL% + + +:display_toolchain_variables + call :msg "MSBUILD_EXE : !MSBUILD_EXE!" + call :msg "NUGET_PKG_PATH : !NUGET_PKG_PATH!" + exit /b %ERRORLEVEL% + +:display_constants + call :msg "libbitcoin_system_OWNER : !libbitcoin_system_OWNER!" + call :msg "libbitcoin_system_TAG : !libbitcoin_system_TAG!" + call :msg "libbitcoin_database_OWNER : !libbitcoin_database_OWNER!" + call :msg "libbitcoin_database_TAG : !libbitcoin_database_TAG!" + call :msg "libbitcoin_network_OWNER : !libbitcoin_network_OWNER!" + call :msg "libbitcoin_network_TAG : !libbitcoin_network_TAG!" + call :msg "libbitcoin_node_OWNER : !libbitcoin_node_OWNER!" + call :msg "libbitcoin_node_TAG : !libbitcoin_node_TAG!" + exit /b %ERRORLEVEL% + +:help + call :msg "Script managing the build of libbitcoin-node." + call :msg "" + call :msg "Script options:" + call :msg "--build-config config Build configuration." + call :msg "--build-platform platform Build platform." + call :msg "--build-version version Build MSVC version." + call :msg "--build-src-dir path Location of sources." + call :msg "--build-full-repositories Sync full github repositories." + call :msg "--build-use-local-src Use existing sources in build-src-dir path." + call :msg "--verbose Display verbose script output." + call :msg "--help, -h Display usage, overriding script execution." + exit /b %ERRORLEVEL% + +:create_directory + set "CD_DIRECTORY=%~1" + set "CD_MODE=%~2" + + if exist "!CD_DIRECTORY!" ( + if "!CD_MODE!" == "-f" ( + call :msg_warn "Reinitializing '%CD_DIRECTORY%'..." + rmdir /S /Q "!CD_DIRECTORY!" + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + + mkdir "!CD_DIRECTORY!" + ) else ( + call :msg_warn "Reusing existing '!CD_DIRECTORY!'..." + ) + ) else ( + call :msg "Initializing '!CD_DIRECTORY!'..." + ) + exit /b %ERRORLEVEL% + +:create_directory_force + call :create_directory "%~1" -f + exit /b %ERRORLEVEL% + +:pop_directory + call :msg_verbose "*** move pre: '!CD!'" + popd + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + call :msg_verbose "*** move post: '!CD!'" + exit /b %ERRORLEVEL% + +:push_directory + call :msg_verbose "*** move pre: '!CD!'" + pushd %1 + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + call :msg_verbose "*** move post: '!CD!'" + exit /b %ERRORLEVEL% + +:remove_directory_force + call :msg_verbose "*** removing: '%~1'" + rmdir /S /Q "%~1" + exit /b %ERRORLEVEL% + +:msg_heading + call :msg "***************************************************************************" + call :msg "%~1" + call :msg "***************************************************************************" + exit /b %ERRORLEVEL% + +:msg + if "%~1" == "" ( + echo. + ) else ( + echo %~1 + ) + exit /b %ERRORLEVEL% + +:msg_empty + echo. + exit /b %ERRORLEVEL% + +:msg_verbose + if "!DISPLAY_VERBOSE!" == "yes" ( + echo %~1 + ) + exit /b %ERRORLEVEL% + +:msg_success + echo %~1 + exit /b %ERRORLEVEL% + +:msg_warn + echo %~1 + exit /b %ERRORLEVEL% + +:msg_error + echo %~1 + exit /b %ERRORLEVEL% diff --git a/install-cmake.sh b/install-cmake.sh deleted file mode 100755 index 25bd3df9..00000000 --- a/install-cmake.sh +++ /dev/null @@ -1,946 +0,0 @@ -#!/bin/bash -############################################################################### -# Copyright (c) 2014-2026 libbitcoin-node developers (see COPYING). -# -# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY -# -############################################################################### -# Script to build and install libbitcoin-node. -# -# Script options: -# --build-boost Builds Boost libraries. -# --build-dir= Location of downloaded and intermediate files. -# --prefix= Library install location (defaults to /usr/local). -# --disable-shared Disables shared library builds. -# --disable-static Disables static library builds. -# --verbose Display verbose output (defaults to quiet on called tooling). -# --help, -h Display usage, overriding script execution. -# -# Verified on Ubuntu 14.04, requires gcc-4.8 or newer. -# Verified on OSX 10.10, using MacPorts and Homebrew repositories, requires -# Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn) or newer. -# This script does not like spaces in the --prefix or --build-dir, sorry. -# Values (e.g. yes|no) in the '--disable-' options are not supported. -# All command line options are passed to 'configure' of each repo, with -# the exception of the --build- options, which are for the script only. -# Depending on the caller's permission to the --prefix or --build-dir -# directory, the script may need to be sudo'd. - -# Define constants. -#============================================================================== -# Branches for github dependencies. -#------------------------------------------------------------------------------ -SECP256K1_BRANCH="v0.7.0" -BITCOIN_SYSTEM_BRANCH="master" -BITCOIN_NETWORK_BRANCH="master" -BITCOIN_DATABASE_BRANCH="master" -BITCOIN_NODE_BRANCH="master" - -# Sentinel for comparison of sequential build. -#------------------------------------------------------------------------------ -SEQUENTIAL=1 - -# Git clone parameters. -#------------------------------------------------------------------------------ -if [[ $GIT_CLONE_PARAMS ]]; then - display_message "Using shell-defined GIT_CLONE_PARAMS value." -else - GIT_CLONE_PARAMS="--depth 1 --single-branch" -fi - -# The default build directory. -#------------------------------------------------------------------------------ -BUILD_SRC_DIR="build-libbitcoin-node" - -PRESUMED_CI_PROJECT_PATH=$(pwd) - -# Boost archive. -#------------------------------------------------------------------------------ -BOOST_URL="https://archives.boost.io/release/1.86.0/source/boost_1_86_0.tar.bz2" -BOOST_ARCHIVE="boost_1_86_0.tar.bz2" - - -# Define utility functions. -#============================================================================== -configure_links() -{ - # Configure dynamic linker run-time bindings when installing to system. - if [[ ($OS == Linux) && ($PREFIX == "/usr/local") ]]; then - ldconfig - fi -} - -configure_options() -{ - display_message "configure options:" - for OPTION in "$@"; do - if [[ $OPTION ]]; then - display_message "$OPTION" - fi - done - - ./configure "$@" -} - -create_directory() -{ - local DIRECTORY="$1" - - rm -rf "$DIRECTORY" - mkdir -p "$DIRECTORY" -} - -display_heading_message() -{ - printf "\n********************** %s **********************\n" "$@" -} - -display_message() -{ - printf "%s\n" "$@" -} - -display_error() -{ - >&2 printf "%s\n" "$@" -} - -initialize_git() -{ - display_heading_message "Initialize git" - - # Initialize git repository at the root of the current directory. - git init - git config user.name anonymous -} - -# make_project_directory project_name jobs [configure_options] -make_project_directory() -{ - local PROJ_NAME=$1 - local JOBS=$2 - local TEST=$3 - shift 3 - - push_directory "$PROJ_NAME" - local PROJ_CONFIG_DIR - PROJ_CONFIG_DIR=$(pwd) - - ./autogen.sh - - configure_options "$@" - make_jobs "$JOBS" - - if [[ $TEST == true ]]; then - make_tests "$JOBS" - fi - - make install - configure_links - pop_directory -} - -# make_jobs jobs [make_options] -make_jobs() -{ - local JOBS=$1 - shift 1 - - VERBOSITY="" - if [[ $DISPLAY_VERBOSE ]]; then - VERBOSITY="VERBOSE=1" - fi - - SEQUENTIAL=1 - # Avoid setting -j1 (causes problems on single threaded systems [TRAVIS]). - if [[ $JOBS -gt $SEQUENTIAL ]]; then - make -j"$JOBS" "$@" $VERBOSITY - else - make "$@" $VERBOSITY - fi -} - -# make_tests jobs -make_tests() -{ - local JOBS=$1 - - disable_exit_on_error - - # Build and run unit tests relative to the primary directory. - # VERBOSE=1 ensures test runner output sent to console (gcc). - make_jobs "$JOBS" check "VERBOSE=1" - local RESULT=$? - - # Test runners emit to the test.log file. - if [[ -e "test.log" ]]; then - cat "test.log" - fi - - if [[ $RESULT -ne 0 ]]; then - exit $RESULT - fi - - enable_exit_on_error -} - -pop_directory() -{ - popd >/dev/null -} - -push_directory() -{ - local DIRECTORY="$1" - - pushd "$DIRECTORY" >/dev/null -} - -enable_exit_on_error() -{ - set -e -} - -disable_exit_on_error() -{ - set +e -} - -display_help() -{ - display_message "Usage: ./install.sh [OPTION]..." - display_message "Manage the installation of libbitcoin-node." - display_message "Script options:" - display_message " --build-boost Build Boost libraries." - display_message " --build-secp256k1 Build libsecp256k1 libraries." - display_message " --build-dir= Location of downloaded and intermediate files." - display_message " --prefix= Library install location (defaults to /usr/local)." - display_message " --disable-shared Disables shared library builds." - display_message " --disable-static Disables static library builds." - display_message " --help, -h Display usage, overriding script execution." - display_message "" - display_message "All unrecognized options provided shall be passed as configuration options for " - display_message "all dependencies." -} - -# Define environment initialization functions -#============================================================================== -parse_command_line_options() -{ - for OPTION in "$@"; do - case $OPTION in - # Standard script options. - (--help|-h) DISPLAY_HELP="yes";; - (--verbose) DISPLAY_VERBOSE="yes";; - - # Standard build options. - (--prefix=*) PREFIX="${OPTION#*=}";; - (--disable-shared) DISABLE_SHARED="yes";; - (--disable-static) DISABLE_STATIC="yes";; - - # Common project options. - - # Custom build options. - (--build-boost) BUILD_BOOST="yes";; - (--build-secp256k1) BUILD_SECP256K1="yes";; - - # Unique script options. - (--build-dir=*) BUILD_SRC_DIR="${OPTION#*=}";; - - # Handle ndebug declarations due to disabled argument passthrough - (--enable-ndebug) ENABLE_NDEBUG="yes";; - (--disable-ndebug) DISABLE_NDEBUG="yes";; - - esac - done -} - -handle_help_line_option() -{ - if [[ $DISPLAY_HELP ]]; then - display_help - exit 0 - fi -} - -set_operating_system() -{ - OS=$(uname -s) -} - -configure_build_parallelism() -{ - if [[ $PARALLEL ]]; then - display_message "Using shell-defined PARALLEL value." - elif [[ $OS == Linux ]]; then - PARALLEL=$(nproc) - elif [[ ($OS == Darwin) || ($OS == OpenBSD) ]]; then - PARALLEL=$(sysctl -n hw.ncpu) - else - display_error "Unsupported system: $OS" - display_error " Explicit shell-definition of PARALLEL will avoid system detection." - display_error "" - display_help - exit 1 - fi -} - -set_os_specific_compiler_settings() -{ - if [[ $OS == Darwin ]]; then - export CC="clang" - export CXX="clang++" - STDLIB="c++" - elif [[ $OS == OpenBSD ]]; then - make() { gmake "$@"; } - export CC="egcc" - export CXX="eg++" - STDLIB="estdc++" - else # Linux - STDLIB="stdc++" - fi -} - -link_to_standard_library() -{ - if [[ ($OS == Linux && $CC == clang*) || ($OS == OpenBSD) ]]; then - export LDLIBS="-l$STDLIB $LDLIBS" - export CXXFLAGS="-stdlib=lib$STDLIB $CXXFLAGS" - fi -} - -normalize_static_and_shared_options() -{ - if [[ $DISABLE_SHARED ]]; then - CONFIGURE_OPTIONS=("$@" "--enable-static") - elif [[ $DISABLE_STATIC ]]; then - CONFIGURE_OPTIONS=("$@" "--enable-shared") - else - CONFIGURE_OPTIONS=("$@" "--enable-shared") - CONFIGURE_OPTIONS=("$@" "--enable-static") - fi -} - -handle_custom_options() -{ - CUMULATIVE_FILTERED_ARGS="" - CUMULATIVE_FILTERED_ARGS_CMAKE="" - - if [[ $ENABLE_NDEBUG && $DISABLE_NDEBUG ]]; then - display_error "--enable-ndebug and --disable-ndebug are mutually exclusive options." - display_error "" - exit 1 - elif [[ $DISABLE_NDEBUG ]]; then - CUMULATIVE_FILTERED_ARGS="--disable-ndebug" - CUMULATIVE_FILTERED_ARGS_CMAKE="-DCMAKE_BUILD_TYPE=Debug" - else - CUMULATIVE_FILTERED_ARGS="--enable-ndebug" - CUMULATIVE_FILTERED_ARGS_CMAKE="-DCMAKE_BUILD_TYPE=Release" - fi - - # Process link declaration - if [[ $DISABLE_SHARED ]]; then - CUMULATIVE_FILTERED_ARGS+=" --enable-static --disable-shared" - CUMULATIVE_FILTERED_ARGS_CMAKE+=" -DBUILD_SHARED_LIBS=FALSE" - elif [[ $DISABLE_STATIC ]]; then - CUMULATIVE_FILTERED_ARGS+=" --disable-static --enable-shared" - CUMULATIVE_FILTERED_ARGS_CMAKE+=" -DBUILD_SHARED_LIBS=TRUE" - fi - - # Process prefix - if [[ ($PREFIX) ]]; then - CUMULATIVE_FILTERED_ARGS+=" --prefix="${PREFIX}"" - CUMULATIVE_FILTERED_ARGS_CMAKE+=" -DCMAKE_PREFIX_PATH="${PREFIX}" -DCMAKE_INSTALL_PREFIX="${PREFIX}"" - - if [ -z $CMAKE_INCLUDE_PATH ]; then - export CMAKE_INCLUDE_PATH="${PREFIX}/include" - else - export CMAKE_INCLUDE_PATH="${PREFIX}/include:${CMAKE_INCLUDE_PATH}" - fi - - if [ -z $CMAKE_LIBRARY_PATH ]; then - export CMAKE_LIBRARY_PATH="${PREFIX}/lib" - else - export CMAKE_LIBRARY_PATH="${PREFIX}/lib:${CMAKE_LIBRARY_PATH}" - fi - fi -} - -remove_build_options() -{ - # Purge custom build options so they don't break configure. - CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--build-*/}") -} - -remove_install_options() -{ - # Purge installer handled options other than --build-. - CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--with-*/}") - CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--without-*/}") - CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--enable-*/}") - CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--disable-*/}") - CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--prefix=*/}") - CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--verbose=*/}") -} - -set_prefix() -{ - # Always set a prefix (required on OSX and for lib detection). - if [[ ! ($PREFIX) ]]; then - PREFIX="/usr/local" - CONFIGURE_OPTIONS=( "${CONFIGURE_OPTIONS[@]}" "--prefix=$PREFIX") - else - # Incorporate the custom libdir into each object, for link time resolution. - if [[ ! ($LD_RUN_PATH) ]]; then - export LD_RUN_PATH="$LD_RUN_PATH:$PREFIX/lib" - else - export LD_RUN_PATH="$PREFIX/lib" - fi - - if [[ ! ($LD_LIBRARY_PATH) ]]; then - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PREFIX/lib" - else - export LD_LIBRARY_PATH="$PREFIX/lib" - fi - fi -} - -set_pkgconfigdir() -{ - # Set the prefix-based package config directory. - PREFIX_PKG_CONFIG_DIR="$PREFIX/lib/pkgconfig" - - # Prioritize prefix package config in PKG_CONFIG_PATH search path. - export PKG_CONFIG_PATH="$PREFIX_PKG_CONFIG_DIR:$PKG_CONFIG_PATH" - - # Set a package config save path that can be passed via our builds. - with_pkgconfigdir="-Dpkgconfigdir=$PREFIX_PKG_CONFIG_DIR" -} - -set_with_boost_prefix() -{ - if [[ $BUILD_BOOST ]]; then - # Boost detection via FindBoost.cmake provides for path hint via - # $BOOT_ROOT environment variable only. - export BOOST_ROOT="$PREFIX" - fi -} - -display_configuration() -{ - display_message "libbitcoin-node installer configuration." - display_message "--------------------------------------------------------------------" - display_message "OS : $OS" - display_message "PARALLEL : $PARALLEL" - display_message "CC : $CC" - display_message "CXX : $CXX" - display_message "CPPFLAGS : $CPPFLAGS" - display_message "CFLAGS : $CFLAGS" - display_message "CXXFLAGS : $CXXFLAGS" - display_message "LDFLAGS : $LDFLAGS" - display_message "LDLIBS : $LDLIBS" - display_message "BUILD_BOOST : $BUILD_BOOST" - display_message "BUILD_SECP256K1 : $BUILD_SECP256K1" - display_message "BOOST_ROOT : $BOOST_ROOT" - display_message "BUILD_SRC_DIR : $BUILD_SRC_DIR" - display_message "CUMULATIVE_FILTERED_ARGS : $CUMULATIVE_FILTERED_ARGS" - display_message "CUMULATIVE_FILTERED_ARGS_CMAKE : $CUMULATIVE_FILTERED_ARGS_CMAKE" - display_message "PREFIX : $PREFIX" - display_message "DISABLE_SHARED : $DISABLE_SHARED" - display_message "DISABLE_STATIC : $DISABLE_STATIC" - display_message "with_boost : ${with_boost}" - display_message "with_pkgconfigdir : ${with_pkgconfigdir}" - display_message "--------------------------------------------------------------------" -} - - -# Define build functions. -#============================================================================== -extract_from_tarball() -{ - local TARGET_DIR=$1 - local URL=$2 - local ARCHIVE=$3 - local COMPRESSION=$4 - - create_directory "$TARGET_DIR" - push_directory "$TARGET_DIR" - - # Extract the source locally. - WGET="wget --quiet" - TAR="tar" - - if [[ $DISPLAY_VERBOSE ]]; then - WGET="wget --verbose" - TAR="tar --verbose" - fi - - $WGET --output-document "$ARCHIVE" "$URL" - $TAR --extract --file "$ARCHIVE" "--$COMPRESSION" --strip-components=1 - - display_message "Completed download and extraction successfully." - pop_directory -} - -unpack_from_tarball() -{ - local ARCHIVE=$1 - local URL=$2 - local COMPRESSION=$3 - local BUILD=$4 - - display_heading_message "Preparing to acquire $ARCHIVE" - - if [[ ! ($BUILD) ]]; then - display_message "Skipping unpack of $ARCHIVE..." - return - fi - - local TARGET_DIR="build-$ARCHIVE" - - if [[ -d "$TARGET_DIR" ]]; then - if [[ true ]]; then - display_message "Re-downloading $ARCHIVE..." - rm -rf "$TARGET_DIR" - extract_from_tarball "$TARGET_DIR" "$URL" "$ARCHIVE" "$COMPRESSION" - else - display_message "Reusing existing archive $ARCHIVE..." - fi - else - display_message "Downloading $ARCHIVE..." - extract_from_tarball "$TARGET_DIR" "$URL" "$ARCHIVE" "$COMPRESSION" - fi -} - -# Standard build from tarball. -build_from_tarball() -{ - local ARCHIVE=$1 - local PUSH_DIR=$2 - local JOBS=$3 - local BUILD=$4 - local OPTIONS=$5 - shift 5 - - local SAVE_LDFLAGS="$LDFLAGS" - local SAVE_CPPFLAGS="$CPPFLAGS" - - display_heading_message "Preparing to build $ARCHIVE" - - local TARGET="build-$ARCHIVE" - push_directory "$TARGET" - push_directory "$PUSH_DIR" - - # Join generated and command line options. - local CONFIGURATION=("${OPTIONS[@]}" "$@") - - if [[ $ARCHIVE == "$MBEDTLS_ARCHIVE" ]]; then - make -j "$JOBS" lib - make DESTDIR=$PREFIX install - else - configure_options "${CONFIGURATION[@]}" - make_jobs "$JOBS" --silent - make install - fi - - configure_links - - pop_directory - pop_directory - - # Restore flags to prevent side effects. - export LDFLAGS=$SAVE_LDFLAGS - export CPPFLAGS=$SAVE_CPPFLAGS -} - -clone_from_github() -{ - local FORK=$1 - local BRANCH=$2 - - # Clone the repository locally. - git clone $GIT_CLONE_PARAMS --branch "$BRANCH" "https://github.com/$FORK" -} - -create_from_github() -{ - local ACCOUNT=$1 - local REPO=$2 - local BRANCH=$3 - local BUILD=$4 - shift 4 - - if [[ ! ($BUILD) || ($BUILD == "no") ]]; then - return - fi - - FORK="$ACCOUNT/$REPO" - - display_heading_message "Preparing to acquire $FORK/$BRANCH" - - if [[ -d "$REPO" ]]; then - if [[ true ]]; then - display_message "Re-cloning $FORK/$BRANCH..." - rm -rf "$REPO" - clone_from_github "$FORK" "$BRANCH" - else - display_message "Reusing existing clone of $FORK, Branch may not match $BRANCH..." - fi - else - display_message "Cloning $FORK/$BRANCH..." - clone_from_github "$FORK" "$BRANCH" - fi -} - -# Standard build from github. -build_from_github() -{ - local REPO=$1 - local JOBS=$2 - local TEST=$3 - local BUILD=$4 - local OPTIONS=$5 - shift 5 - - if [[ ! ($BUILD) || ($BUILD == "no") ]]; then - return - fi - - # Join generated and command line options. - local CONFIGURATION=("${OPTIONS[@]}" "$@") - - display_heading_message "Preparing to build $REPO" - - # Build the local repository clone. - make_project_directory "$REPO" "$JOBS" "$TEST" "${CONFIGURATION[@]}" -} - -cmake_tests() -{ - local JOBS=$1 - - disable_exit_on_error - - # Build and run unit tests relative to the primary directory. - # VERBOSE=1 ensures test runner output sent to console (gcc). - make -j"$JOBS" test "VERBOSE=1" - local RESULT=$? - - # Test runners emit to the test.log file. - if [[ -e "test.log" ]]; then - cat "test.log" - fi - - if [[ $RESULT -ne 0 ]]; then - exit $RESULT - fi - - enable_exit_on_error -} - -cmake_project_directory() -{ - local PROJ_NAME=$1 - local CMAKE_PATH=$2 - local JOBS=$3 - local TEST=$4 - shift 4 - - push_directory "$PROJ_NAME" - local PROJ_CONFIG_DIR - PROJ_CONFIG_DIR=$(pwd) - - create_directory "build-cmake" - push_directory "build-cmake" - - VERBOSITY="" - if [[ $DISPLAY_VERBOSE ]]; then - VERBOSITY="-DCMAKE_VERBOSE_MAKEFILE=ON" - fi - - cmake ${VERBOSITY} -LA $@ "../${CMAKE_PATH}" - - make_jobs "$JOBS" - - if [[ $TEST == true ]]; then - cmake_tests "$JOBS" - fi - - make install - configure_links - pop_directory # build-cmake - pop_directory # PROJ_NAME -} - -build_from_github_cmake() -{ - local REPO=$1 - local CMAKE_PATH=$2 - local JOBS=$3 - local TEST=$4 - local BUILD=$5 - local OPTIONS=$6 - shift 6 - - if [[ ! ($BUILD) || ($BUILD == "no") ]]; then - return - fi - - # Join generated and command line options. - local CONFIGURATION=("${OPTIONS[@]}" "$@") - - display_heading_message "Preparing to build $REPO" - - # Build the local repository clone. - cmake_project_directory "$REPO" "$CMAKE_PATH" "$JOBS" "$TEST" "${CONFIGURATION[@]}" -} - - -# Because boost doesn't support autoconfig and doesn't like empty settings. -initialize_boost_configuration() -{ - if [[ $DISABLE_STATIC ]]; then - BOOST_LINK="shared" - elif [[ $DISABLE_SHARED ]]; then - BOOST_LINK="static" - else - BOOST_LINK="static,shared" - fi - - if [[ $CC ]]; then - BOOST_TOOLSET="toolset=$CC" - fi - - if [[ ($OS == Linux && $CC == clang*) || ($OS == OpenBSD) ]]; then - STDLIB_FLAG="-stdlib=lib$STDLIB" - BOOST_CXXFLAGS="cxxflags=$STDLIB_FLAG" - BOOST_LINKFLAGS="linkflags=$STDLIB_FLAG" - fi -} -# Because boost doesn't use autoconfig. -build_from_tarball_boost() -{ - local SAVE_IFS="$IFS" - IFS=' ' - - local ARCHIVE=$1 - local JOBS=$2 - local BUILD=$3 - shift 3 - - if [[ ! ($BUILD) ]]; then - return - fi - - display_heading_message "Preparing to build $ARCHIVE" - - local TARGET="build-$ARCHIVE" - - push_directory "$TARGET" - - initialize_boost_configuration - - guessed_toolset=`./tools/build/src/engine/build.sh --guess-toolset` - CXXFLAGS="-w" ./tools/build/src/engine/build.sh ${guessed_toolset} --cxxflags="-w" - cp tools/build/src/engine/b2 . - if [[ (x"$BOOST_CXXFLAGS" == "x") ]]; then - BOOST_CXXFLAGS="cxxflags=${BOOST_FLAGS[@]}" - else - BOOST_CXXFLAGS="$BOOST_CXXFLAGS ${BOOST_FLAGS[@]}" - fi - - display_message "Libbitcoin boost configuration." - display_message "--------------------------------------------------------------------" - display_message "variant : release" - display_message "threading : multi" - display_message "toolset : $CC" - display_message "boost cxxflags : $BOOST_CXXFLAGS" - display_message "boost linkflags : $BOOST_LINKFLAGS" - display_message "link : $BOOST_LINK" - display_message "-sNO_BZIP2 : 1" - display_message "-sNO_ZSTD : 1" - # display_message "-sICU_LINK : " "${ICU_LIBS[*]}" - display_message "-j : $JOBS" - display_message "-d0 : [supress informational messages]" - display_message "-q : [stop at the first error]" - display_message "--reconfigure : [ignore cached configuration]" - display_message "--prefix : $PREFIX" - display_message "BOOST_OPTIONS : $*" - display_message "cxxflags (ignored) : $CXXFLAGS" - display_message "--------------------------------------------------------------------" - - ./bootstrap.sh \ - "--with-bjam=./b2" \ - "--prefix=$PREFIX" - - # boost_regex: - # As of boost 1.72.0 the ICU_LINK symbol is no longer supported and - # produces a hard stop if WITH_ICU is also defined. Removal is sufficient. - # github.com/libbitcoin/libbitcoin-system/issues/1192 - # "-sICU_LINK=${ICU_LIBS[*]}" - - ./b2 install \ - "cxxstd=20" \ - "variant=release" \ - "threading=multi" \ - "$BOOST_TOOLSET" \ - "$BOOST_CXXFLAGS" \ - "$BOOST_LINKFLAGS" \ - "link=$BOOST_LINK" \ - "warnings=off" \ - "-sNO_BZIP2=1" \ - "-sNO_ZSTD=1" \ - "-j $JOBS" \ - "-d0" \ - "-q" \ - "--reconfigure" \ - "--prefix=$PREFIX" \ - "$@" - - pop_directory - - IFS="$SAVE_IFS" -} - - -# The master build function. -#============================================================================== -build_all() -{ - unpack_from_tarball "$BOOST_ARCHIVE" "$BOOST_URL" bzip2 "$BUILD_BOOST" - local SAVE_CPPFLAGS="$CPPFLAGS" - export CPPFLAGS="$CPPFLAGS ${BOOST_FLAGS[@]}" - build_from_tarball_boost "$BOOST_ARCHIVE" "$PARALLEL" "$BUILD_BOOST" "${BOOST_OPTIONS[@]}" - export CPPFLAGS=$SAVE_CPPFLAGS - create_from_github bitcoin-core secp256k1 ${SECP256K1_BRANCH} "$BUILD_SECP256K1" - local SAVE_CPPFLAGS="$CPPFLAGS" - export CPPFLAGS="$CPPFLAGS ${SECP256K1_FLAGS[@]}" - build_from_github_cmake secp256k1 "." "$PARALLEL" false "$BUILD_SECP256K1" "${SECP256K1_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS_CMAKE "$@" - export CPPFLAGS=$SAVE_CPPFLAGS - create_from_github libbitcoin libbitcoin-system ${BITCOIN_SYSTEM_BRANCH} "yes" - local SAVE_CPPFLAGS="$CPPFLAGS" - export CPPFLAGS="$CPPFLAGS ${BITCOIN_SYSTEM_FLAGS[@]}" - build_from_github_cmake libbitcoin-system "builds/cmake" "$PARALLEL" false "yes" "${BITCOIN_SYSTEM_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS_CMAKE "$@" - export CPPFLAGS=$SAVE_CPPFLAGS - create_from_github libbitcoin libbitcoin-network ${BITCOIN_NETWORK_BRANCH} "yes" - local SAVE_CPPFLAGS="$CPPFLAGS" - export CPPFLAGS="$CPPFLAGS ${BITCOIN_NETWORK_FLAGS[@]}" - build_from_github_cmake libbitcoin-network "builds/cmake" "$PARALLEL" false "yes" "${BITCOIN_NETWORK_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS_CMAKE "$@" - export CPPFLAGS=$SAVE_CPPFLAGS - create_from_github libbitcoin libbitcoin-database ${BITCOIN_DATABASE_BRANCH} "yes" - local SAVE_CPPFLAGS="$CPPFLAGS" - export CPPFLAGS="$CPPFLAGS ${BITCOIN_DATABASE_FLAGS[@]}" - build_from_github_cmake libbitcoin-database "builds/cmake" "$PARALLEL" false "yes" "${BITCOIN_DATABASE_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS_CMAKE "$@" - export CPPFLAGS=$SAVE_CPPFLAGS - local SAVE_CPPFLAGS="$CPPFLAGS" - export CPPFLAGS="$CPPFLAGS ${BITCOIN_NODE_FLAGS[@]}" - if [[ ! ($CI == true) ]]; then - create_from_github libbitcoin libbitcoin-node ${BITCOIN_NODE_BRANCH} "yes" - build_from_github_cmake libbitcoin-node "builds/cmake" "$PARALLEL" true "yes" "${BITCOIN_NODE_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS_CMAKE "$@" - else - push_directory "$PRESUMED_CI_PROJECT_PATH" - push_directory ".." - build_from_github_cmake libbitcoin-node "builds/cmake" "$PARALLEL" true "yes" "${BITCOIN_NODE_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS_CMAKE "$@" - pop_directory - pop_directory - fi - export CPPFLAGS=$SAVE_CPPFLAGS -} - - -# Initialize the build environment. -#============================================================================== -enable_exit_on_error -parse_command_line_options "$@" -handle_help_line_option -handle_custom_options -set_operating_system -configure_build_parallelism -set_os_specific_compiler_settings "$@" -link_to_standard_library -normalize_static_and_shared_options "$@" -remove_build_options -set_prefix -set_pkgconfigdir -set_with_boost_prefix - -remove_install_options - -# Define build flags. -#============================================================================== -# Define boost flags. -#------------------------------------------------------------------------------ -BOOST_FLAGS=( -"-Wno-enum-constexpr-conversion") - -# Define secp256k1 flags. -#------------------------------------------------------------------------------ -SECP256K1_FLAGS=( -"-w") - - -# Define build options. -#============================================================================== -# Define boost options. -#------------------------------------------------------------------------------ -BOOST_OPTIONS=( -"--with-iostreams" \ -"--with-locale" \ -"--with-program_options" \ -"--with-regex" \ -"--with-thread" \ -"--with-url" \ -"--with-test") - -# Define secp256k1 options. -#------------------------------------------------------------------------------ -SECP256K1_OPTIONS=( -"-DSECP256K1_BUILD_TESTS=OFF" \ -"-DSECP256K1_EXPERIMENTAL=ON" \ -"-DSECP256K1_ENABLE_MODULE_RECOVERY=ON" \ -"-DSECP256K1_ENABLE_MODULE_SCHNORRSIG=ON") - -# Define bitcoin-system options. -#------------------------------------------------------------------------------ -BITCOIN_SYSTEM_OPTIONS=( -"-Dwith-tests:BOOL=OFF" \ -"-Dwith-examples:BOOL=OFF" \ -"${with_boost}" \ -"${with_pkgconfigdir}") - -# Define bitcoin-network options. -#------------------------------------------------------------------------------ -BITCOIN_NETWORK_OPTIONS=( -"-Dwith-tests:BOOL=OFF" \ -"${with_boost}" \ -"${with_pkgconfigdir}") - -# Define bitcoin-database options. -#------------------------------------------------------------------------------ -BITCOIN_DATABASE_OPTIONS=( -"-Dwith-tests:BOOL=OFF" \ -"-Dwith-tools:BOOL=OFF" \ -"${with_boost}" \ -"${with_pkgconfigdir}") - -# Define bitcoin-node options. -#------------------------------------------------------------------------------ -BITCOIN_NODE_OPTIONS=( -"${with_boost}" \ -"${with_pkgconfigdir}") - - -# Build the primary library and all dependencies. -#============================================================================== -display_configuration - -if [[ ! ($CI == true) ]]; then - create_directory "$BUILD_SRC_DIR" - push_directory "$BUILD_SRC_DIR" -else - push_directory "$BUILD_SRC_DIR" -fi - -initialize_git -time build_all "${CONFIGURE_OPTIONS[@]}" -pop_directory diff --git a/install-cmakepresets.sh b/install-cmakepresets.sh deleted file mode 100755 index 8c16bdb2..00000000 --- a/install-cmakepresets.sh +++ /dev/null @@ -1,1053 +0,0 @@ -#!/bin/bash -############################################################################### -# Copyright (c) 2014-2026 libbitcoin-node developers (see COPYING). -# -# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY -# -############################################################################### -# Script to build and install libbitcoin-node. -# -# Script options: -# --build-boost Builds Boost libraries. -# --build-dir= Location of downloaded and intermediate files. -# --preset=