|
| 1 | +# Copyright (c) 2026 The Bitcoin Core developers |
| 2 | +# Distributed under the MIT software license, see the accompanying |
| 3 | +# file COPYING or http://www.opensource.org/licenses/mit-license.php. |
| 4 | + |
| 5 | +name: Depends Build |
| 6 | + |
| 7 | +on: |
| 8 | + pull_request: |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - "**" |
| 12 | + tags-ignore: |
| 13 | + - "**" |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 18 | + cancel-in-progress: true |
| 19 | + |
| 20 | +permissions: |
| 21 | + contents: read |
| 22 | + |
| 23 | +jobs: |
| 24 | + build: |
| 25 | + name: ${{ matrix.name }} |
| 26 | + runs-on: ${{ matrix.os }} |
| 27 | + timeout-minutes: 360 |
| 28 | + strategy: |
| 29 | + fail-fast: false |
| 30 | + matrix: |
| 31 | + include: |
| 32 | + - name: linux-x86_64 |
| 33 | + os: ubuntu-24.04 |
| 34 | + host: x86_64-pc-linux-gnu |
| 35 | + make: make |
| 36 | + cache-id: linux-x86_64 |
| 37 | + - name: macos-native |
| 38 | + os: macos-14 |
| 39 | + host: "" |
| 40 | + make: gmake |
| 41 | + cache-id: macos-native |
| 42 | + |
| 43 | + env: |
| 44 | + BUILD_DIR: build-depends |
| 45 | + DEPENDS_PATCH: patches/depends-Add-Qt-Qml-and-Qt-Quick-modules.patch |
| 46 | + |
| 47 | + steps: |
| 48 | + - name: Checkout |
| 49 | + uses: actions/checkout@v4 |
| 50 | + with: |
| 51 | + submodules: recursive |
| 52 | + |
| 53 | + - name: Install Linux build dependencies |
| 54 | + if: runner.os == 'Linux' |
| 55 | + run: | |
| 56 | + sudo apt-get update |
| 57 | + sudo apt-get install -y \ |
| 58 | + bison \ |
| 59 | + build-essential \ |
| 60 | + cmake \ |
| 61 | + curl \ |
| 62 | + make \ |
| 63 | + ninja-build \ |
| 64 | + patch \ |
| 65 | + pkgconf \ |
| 66 | + python3 \ |
| 67 | + xz-utils |
| 68 | + echo "JOBS=$(nproc)" >> "$GITHUB_ENV" |
| 69 | +
|
| 70 | + - name: Install macOS build dependencies |
| 71 | + if: runner.os == 'macOS' |
| 72 | + run: | |
| 73 | + brew install bison cmake make ninja pkgconf python |
| 74 | + echo "$(brew --prefix bison)/bin" >> "$GITHUB_PATH" |
| 75 | + echo "JOBS=$(sysctl -n hw.logicalcpu)" >> "$GITHUB_ENV" |
| 76 | +
|
| 77 | + - name: Select depends host |
| 78 | + run: | |
| 79 | + if [ -n "${{ matrix.host }}" ]; then |
| 80 | + host="${{ matrix.host }}" |
| 81 | + else |
| 82 | + host="$(cd bitcoin/depends && ./config.guess)" |
| 83 | + fi |
| 84 | + host="$(cd bitcoin/depends && ./config.sub "$host")" |
| 85 | + echo "HOST=${host}" >> "$GITHUB_ENV" |
| 86 | + echo "Using depends host: ${host}" |
| 87 | +
|
| 88 | + - name: Apply Bitcoin depends patch |
| 89 | + run: | |
| 90 | + if [ ! -f "${DEPENDS_PATCH}" ]; then |
| 91 | + echo "::error::Missing ${DEPENDS_PATCH}" |
| 92 | + exit 1 |
| 93 | + fi |
| 94 | +
|
| 95 | + patch="../${DEPENDS_PATCH}" |
| 96 | + if git -C bitcoin apply --whitespace=nowarn --reverse --check "${patch}" >/dev/null 2>&1; then |
| 97 | + echo "${DEPENDS_PATCH} is already applied" |
| 98 | + else |
| 99 | + git -C bitcoin apply --whitespace=nowarn --check "${patch}" |
| 100 | + git -C bitcoin apply --whitespace=nowarn "${patch}" |
| 101 | + fi |
| 102 | +
|
| 103 | + - name: Restore depends sources cache |
| 104 | + uses: actions/cache/restore@v4 |
| 105 | + id: depends-sources-cache |
| 106 | + with: |
| 107 | + path: bitcoin/depends/sources |
| 108 | + key: ${{ matrix.cache-id }}-depends-sources-${{ hashFiles('bitcoin/depends/packages/*.mk', 'bitcoin/depends/patches/**', 'patches/*.patch') }} |
| 109 | + restore-keys: | |
| 110 | + ${{ matrix.cache-id }}-depends-sources- |
| 111 | +
|
| 112 | + - name: Restore depends package cache |
| 113 | + uses: actions/cache/restore@v4 |
| 114 | + id: depends-built-cache |
| 115 | + with: |
| 116 | + path: bitcoin/depends/built |
| 117 | + key: ${{ matrix.cache-id }}-depends-built-${{ hashFiles('bitcoin/depends/Makefile', 'bitcoin/depends/funcs.mk', 'bitcoin/depends/builders/**', 'bitcoin/depends/hosts/**', 'bitcoin/depends/packages/*.mk', 'bitcoin/depends/patches/**', 'patches/*.patch') }} |
| 118 | + restore-keys: | |
| 119 | + ${{ matrix.cache-id }}-depends-built- |
| 120 | +
|
| 121 | + - name: Build depends |
| 122 | + run: | |
| 123 | + cd bitcoin/depends |
| 124 | + ${{ matrix.make }} -j"${JOBS}" HOST="${HOST}" DEBUG= LOG=1 |
| 125 | +
|
| 126 | + - name: Save depends sources cache |
| 127 | + uses: actions/cache/save@v4 |
| 128 | + if: github.event_name != 'pull_request' && steps.depends-sources-cache.outputs.cache-hit != 'true' |
| 129 | + with: |
| 130 | + path: bitcoin/depends/sources |
| 131 | + key: ${{ steps.depends-sources-cache.outputs.cache-primary-key }} |
| 132 | + |
| 133 | + - name: Save depends package cache |
| 134 | + uses: actions/cache/save@v4 |
| 135 | + if: github.event_name != 'pull_request' && steps.depends-built-cache.outputs.cache-hit != 'true' |
| 136 | + with: |
| 137 | + path: bitcoin/depends/built |
| 138 | + key: ${{ steps.depends-built-cache.outputs.cache-primary-key }} |
| 139 | + |
| 140 | + - name: Configure |
| 141 | + run: | |
| 142 | + test -f "bitcoin/depends/${HOST}/toolchain.cmake" |
| 143 | + cmake -S . -B "${BUILD_DIR}" -G Ninja \ |
| 144 | + -DCMAKE_BUILD_TYPE=Release \ |
| 145 | + -DCMAKE_TOOLCHAIN_FILE="${PWD}/bitcoin/depends/${HOST}/toolchain.cmake" \ |
| 146 | + -DBUILD_APP_TESTS=OFF \ |
| 147 | + -DBUILD_GUI=ON \ |
| 148 | + -DENABLE_WALLET=ON \ |
| 149 | + -DENABLE_IPC=OFF |
| 150 | +
|
| 151 | + - name: Build bitcoin-core-app |
| 152 | + run: | |
| 153 | + cmake --build "${BUILD_DIR}" --target bitcoin-core-app --parallel "${JOBS}" |
| 154 | +
|
| 155 | + - name: Upload depends logs |
| 156 | + uses: actions/upload-artifact@v4 |
| 157 | + if: failure() |
| 158 | + with: |
| 159 | + name: depends-logs-${{ matrix.cache-id }} |
| 160 | + path: bitcoin/depends/*.log |
| 161 | + if-no-files-found: ignore |
| 162 | + |
| 163 | + - name: Upload app artifact |
| 164 | + uses: actions/upload-artifact@v4 |
| 165 | + with: |
| 166 | + name: bitcoin-core-app-${{ matrix.cache-id }} |
| 167 | + path: ${{ env.BUILD_DIR }}/bin/bitcoin-core-app |
| 168 | + if-no-files-found: error |
0 commit comments