|
| 1 | +name: Build Dawn |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main" ] |
| 6 | + pull_request: |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +env: |
| 14 | + DAWN_BRANCH: main # Configure the Dawn branch to checkout |
| 15 | + |
| 16 | +jobs: |
| 17 | + mobile-android: |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + # Android builds |
| 23 | + - arch: arm64-v8a |
| 24 | + toolchain_file: $ANDROID_NDK/build/cmake/android.toolchain.cmake |
| 25 | + cmake_args: -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-26 |
| 26 | + output_dir: externals/dawn/out/android_arm64-v8a |
| 27 | + library_path: src/dawn/native/libwebgpu_dawn.so |
| 28 | + strip_tool: $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip |
| 29 | + - arch: armeabi-v7a |
| 30 | + toolchain_file: $ANDROID_NDK/build/cmake/android.toolchain.cmake |
| 31 | + cmake_args: -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-26 |
| 32 | + output_dir: externals/dawn/out/android_armeabi-v7a |
| 33 | + library_path: src/dawn/native/libwebgpu_dawn.so |
| 34 | + strip_tool: $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip |
| 35 | + - arch: x86 |
| 36 | + toolchain_file: $ANDROID_NDK/build/cmake/android.toolchain.cmake |
| 37 | + cmake_args: -DANDROID_ABI=x86 -DANDROID_PLATFORM=android-26 |
| 38 | + output_dir: externals/dawn/out/android_x86 |
| 39 | + library_path: src/dawn/native/libwebgpu_dawn.so |
| 40 | + strip_tool: $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip |
| 41 | + - arch: x86_64 |
| 42 | + toolchain_file: $ANDROID_NDK/build/cmake/android.toolchain.cmake |
| 43 | + cmake_args: -DANDROID_ABI=x86_64 -DANDROID_PLATFORM=android-26 |
| 44 | + output_dir: externals/dawn/out/android_x86_64 |
| 45 | + library_path: src/dawn/native/libwebgpu_dawn.so |
| 46 | + strip_tool: $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip |
| 47 | + |
| 48 | + name: Build-android-${{ matrix.arch }} |
| 49 | + runs-on: ubuntu-latest |
| 50 | + steps: |
| 51 | + - name: Checkout main repository |
| 52 | + uses: actions/checkout@v4 |
| 53 | + |
| 54 | + - name: Checkout Dawn repository |
| 55 | + uses: actions/checkout@v4 |
| 56 | + with: |
| 57 | + repository: google/dawn |
| 58 | + ref: ${{ env.DAWN_BRANCH }} |
| 59 | + path: externals/dawn |
| 60 | + |
| 61 | + - name: Setup Android NDK |
| 62 | + id: setup-ndk |
| 63 | + uses: nttld/setup-ndk@v1 |
| 64 | + with: |
| 65 | + ndk-version: r27d |
| 66 | + |
| 67 | + - name: Set ANDROID_NDK |
| 68 | + run: echo "ANDROID_NDK=${{ steps.setup-ndk.outputs.ndk-path }}" >> $GITHUB_ENV |
| 69 | + |
| 70 | + - name: Build android ${{ matrix.arch }} |
| 71 | + run: | |
| 72 | + cmake -S externals/dawn -B ${{ matrix.output_dir }} -G Ninja \ |
| 73 | + -DDAWN_MOBILE_BUILD=android \ |
| 74 | + -C externals/dawn/.github/workflows/dawn-ci.cmake \ |
| 75 | + -DCMAKE_TOOLCHAIN_FILE=${{ matrix.toolchain_file }} \ |
| 76 | + ${{ matrix.cmake_args }} \ |
| 77 | + -DCMAKE_BUILD_TYPE=Release \ |
| 78 | + -DBUILD_SHARED_LIBS=OFF \ |
| 79 | + -DDAWN_BUILD_MONOLITHIC_LIBRARY=SHARED \ |
| 80 | + -DCMAKE_EXE_LINKER_FLAGS="-llog" \ |
| 81 | + -DCMAKE_SHARED_LINKER_FLAGS="-llog" |
| 82 | + ninja -C ${{ matrix.output_dir }} |
| 83 | + - name: Strip Android binaries |
| 84 | + run: | |
| 85 | + ${{ matrix.strip_tool }} ${{ matrix.output_dir }}/${{ matrix.library_path }} |
| 86 | + - name: Upload build artifacts |
| 87 | + uses: actions/upload-artifact@v4 |
| 88 | + with: |
| 89 | + name: build-android-${{ matrix.arch }} |
| 90 | + path: ${{ matrix.output_dir }}/${{ matrix.library_path }} |
| 91 | + |
| 92 | + - name: Install headers (from arm64-v8a build only) |
| 93 | + if: matrix.arch == 'arm64-v8a' |
| 94 | + run: | |
| 95 | + cmake --install ${{ matrix.output_dir }} --prefix dawn-headers |
| 96 | + - name: Upload headers (from arm64-v8a build only) |
| 97 | + if: matrix.arch == 'arm64-v8a' |
| 98 | + uses: actions/upload-artifact@v4 |
| 99 | + with: |
| 100 | + name: dawn-headers-${{ github.sha }} |
| 101 | + path: dawn-headers/ |
| 102 | + |
| 103 | + mobile-apple: |
| 104 | + strategy: |
| 105 | + fail-fast: false |
| 106 | + matrix: |
| 107 | + include: |
| 108 | + # Apple builds |
| 109 | + - platform: ios |
| 110 | + arch: arm64 |
| 111 | + cmake_args: -DPLATFORM=OS64 -DDEPLOYMENT_TARGET=13.0 -DENABLE_BITCODE=OFF -DENABLE_ARC=OFF -DENABLE_VISIBILITY=OFF |
| 112 | + output_dir: externals/dawn/out/ios_arm64 |
| 113 | + library_path: src/dawn/native/libwebgpu_dawn.a |
| 114 | + - platform: ios |
| 115 | + arch: sim_arm64 |
| 116 | + cmake_args: -DPLATFORM=SIMULATORARM64 -DDEPLOYMENT_TARGET=13.0 -DENABLE_BITCODE=OFF -DENABLE_ARC=OFF -DENABLE_VISIBILITY=OFF |
| 117 | + output_dir: externals/dawn/out/ios_sim_arm64 |
| 118 | + library_path: src/dawn/native/libwebgpu_dawn.a |
| 119 | + - platform: ios |
| 120 | + arch: sim_x86_64 |
| 121 | + cmake_args: -DPLATFORM=SIMULATOR64 -DDEPLOYMENT_TARGET=13.0 -DENABLE_BITCODE=OFF -DENABLE_ARC=OFF -DENABLE_VISIBILITY=OFF |
| 122 | + output_dir: externals/dawn/out/ios_sim_x86_64 |
| 123 | + library_path: src/dawn/native/libwebgpu_dawn.a |
| 124 | + - platform: macos |
| 125 | + arch: universal |
| 126 | + cmake_args: -DPLATFORM=MAC_UNIVERSAL -DDEPLOYMENT_TARGET=11.0 -DENABLE_BITCODE=OFF -DENABLE_ARC=OFF -DENABLE_VISIBILITY=OFF |
| 127 | + output_dir: externals/dawn/out/macos_universal |
| 128 | + library_path: src/dawn/native/libwebgpu_dawn.a |
| 129 | + |
| 130 | + name: Build-${{ matrix.platform }}-${{ matrix.arch }} |
| 131 | + runs-on: macos-latest-large |
| 132 | + steps: |
| 133 | + - name: Checkout main repository |
| 134 | + uses: actions/checkout@v4 |
| 135 | + |
| 136 | + - name: Checkout Dawn repository |
| 137 | + uses: actions/checkout@v4 |
| 138 | + with: |
| 139 | + repository: google/dawn |
| 140 | + ref: ${{ env.DAWN_BRANCH }} |
| 141 | + path: externals/dawn |
| 142 | +# submodules: true |
| 143 | + |
| 144 | + - name: Setup Xcode |
| 145 | + uses: maxim-lobanov/setup-xcode@v1 |
| 146 | + with: |
| 147 | + xcode-version: latest-stable |
| 148 | + |
| 149 | + - name: Download Apple toolchain |
| 150 | + run: | |
| 151 | + mkdir -p externals/dawn/build-tools |
| 152 | + # Download the ios-cmake toolchain file |
| 153 | + curl -L https://raw.githubusercontent.com/leetal/ios-cmake/6fa909e133b92343db2d099e0478448c05ffec1a/ios.toolchain.cmake -o externals/dawn/build-tools/apple.toolchain.cmake |
| 154 | +
|
| 155 | + - name: Build ${{ matrix.platform }} ${{ matrix.arch }} |
| 156 | + run: | |
| 157 | + cmake -S externals/dawn -B ${{ matrix.output_dir }} -G Ninja \ |
| 158 | + -DDAWN_MOBILE_BUILD=apple \ |
| 159 | + -C externals/dawn/.github/workflows/dawn-ci.cmake \ |
| 160 | + -DCMAKE_TOOLCHAIN_FILE=build-tools/apple.toolchain.cmake \ |
| 161 | + ${{ matrix.cmake_args }} \ |
| 162 | + -DCMAKE_BUILD_TYPE=Release |
| 163 | + ninja -C ${{ matrix.output_dir }} |
| 164 | + - name: Upload build artifacts |
| 165 | + uses: actions/upload-artifact@v4 |
| 166 | + with: |
| 167 | + name: build-${{ matrix.platform }}-${{ matrix.arch }} |
| 168 | + path: ${{ matrix.output_dir }}/${{ matrix.library_path }} |
| 169 | + |
| 170 | + package-mobile: |
| 171 | + name: Package Mobile Artifacts |
| 172 | + runs-on: macos-latest |
| 173 | + needs: [mobile-android, mobile-apple] |
| 174 | + steps: |
| 175 | + - name: Checkout main repository |
| 176 | + uses: actions/checkout@v4 |
| 177 | + |
| 178 | + - name: Download all build artifacts |
| 179 | + uses: actions/download-artifact@v4 |
| 180 | + with: |
| 181 | + pattern: build-* |
| 182 | + path: artifacts |
| 183 | + |
| 184 | + - name: Create iOS Simulator fat binary |
| 185 | + run: | |
| 186 | + mkdir -p libs/apple/iphonesimulator |
| 187 | + lipo -create \ |
| 188 | + artifacts/build-ios-sim_x86_64/libwebgpu_dawn.a \ |
| 189 | + artifacts/build-ios-sim_arm64/libwebgpu_dawn.a \ |
| 190 | + -output libs/apple/iphonesimulator/libwebgpu_dawn.a |
| 191 | + - name: Create XCFramework |
| 192 | + run: | |
| 193 | + xcodebuild -create-xcframework \ |
| 194 | + -library libs/apple/iphonesimulator/libwebgpu_dawn.a \ |
| 195 | + -library artifacts/build-ios-arm64/libwebgpu_dawn.a \ |
| 196 | + -library artifacts/build-macos-universal/libwebgpu_dawn.a \ |
| 197 | + -output dawn-apple-${{ github.sha }}.xcframework |
| 198 | + - name: Package Android libraries |
| 199 | + run: | |
| 200 | + mkdir -p dawn-android-${{ github.sha }}/arm64-v8a |
| 201 | + mkdir -p dawn-android-${{ github.sha }}/armeabi-v7a |
| 202 | + mkdir -p dawn-android-${{ github.sha }}/x86 |
| 203 | + mkdir -p dawn-android-${{ github.sha }}/x86_64 |
| 204 | + cp artifacts/build-android-arm64-v8a/libwebgpu_dawn.so dawn-android-${{ github.sha }}/arm64-v8a/ |
| 205 | + cp artifacts/build-android-armeabi-v7a/libwebgpu_dawn.so dawn-android-${{ github.sha }}/armeabi-v7a/ |
| 206 | + cp artifacts/build-android-x86/libwebgpu_dawn.so dawn-android-${{ github.sha }}/x86/ |
| 207 | + cp artifacts/build-android-x86_64/libwebgpu_dawn.so dawn-android-${{ github.sha }}/x86_64/ |
| 208 | + - name: Create archives |
| 209 | + run: | |
| 210 | + tar -czf dawn-android-${{ github.sha }}.tar.gz dawn-android-${{ github.sha }} |
| 211 | + tar -czf dawn-apple-${{ github.sha }}.xcframework.tar.gz dawn-apple-${{ github.sha }}.xcframework |
| 212 | + - name: Upload Android artifacts |
| 213 | + uses: actions/upload-artifact@v4 |
| 214 | + with: |
| 215 | + name: dawn-android-${{ github.sha }} |
| 216 | + path: dawn-android-${{ github.sha }}.tar.gz |
| 217 | + |
| 218 | + - name: Upload Apple artifacts |
| 219 | + uses: actions/upload-artifact@v4 |
| 220 | + with: |
| 221 | + name: dawn-apple-${{ github.sha }} |
| 222 | + path: dawn-apple-${{ github.sha }}.xcframework.tar.gz |
0 commit comments