From 550bf5e4bc73c6460f843a4aa66b6821a7af244b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C4=81rti=C5=86=C5=A1=20Mo=C5=BEeiko?= Date: Sat, 7 Sep 2024 11:13:29 -0700 Subject: [PATCH] build script improvements, add arm64 --- .github/workflows/build-dawn.yml | 77 +++++++++++++++++-------- .gitignore | 7 +-- README.md | 2 +- build.cmd | 99 +++++++++++++++++--------------- 4 files changed, 109 insertions(+), 76 deletions(-) diff --git a/.github/workflows/build-dawn.yml b/.github/workflows/build-dawn.yml index ad6178b..f261f6d 100644 --- a/.github/workflows/build-dawn.yml +++ b/.github/workflows/build-dawn.yml @@ -9,37 +9,64 @@ on: - main jobs: + info: + runs-on: ubuntu-24.04 + outputs: + DAWN_COMMIT: ${{ steps.info.outputs.DAWN_COMMIT }} + BUILD_DATE: ${{ steps.info.outputs.BUILD_DATE }} + steps: + - name: Get Latest Commit Id + id: info + run: | + echo DAWN_COMMIT=`git ls-remote https://dawn.googlesource.com/dawn HEAD | awk '{ print $1 }'` >> ${GITHUB_OUTPUT} + echo BUILD_DATE=`date +'%Y-%m-%d'` >> ${GITHUB_OUTPUT} + build: runs-on: windows-2022 + needs: info + strategy: + matrix: + arch: [x64, arm64] + env: + DAWN_COMMIT: ${{ needs.info.outputs.DAWN_COMMIT }} + BUILD_DATE: ${{ needs.info.outputs.BUILD_DATE }} steps: - - name: checkout - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v4 - - name: build + - name: Run Build Script id: build shell: cmd - run: call build.cmd - - - name: release - id: release - if: steps.build.outputs.DAWN_COMMIT != '' - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: call build.cmd ${{ matrix.arch }} + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 with: - tag_name: ${{ steps.build.outputs.BUILD_DATE }} - release_name: ${{ steps.build.outputs.BUILD_DATE }} - body: | - [dawn commit](https://dawn.googlesource.com/dawn/+/${{ steps.build.outputs.DAWN_COMMIT }}) - - - name: upload - id: upload - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + name: dawn-${{ matrix.arch }}-${{ needs.info.outputs.BUILD_DATE }} + path: dawn-${{ matrix.arch }}-${{ needs.info.outputs.BUILD_DATE }}.zip + if-no-files-found: error + compression-level: 0 + + release: + runs-on: ubuntu-24.04 + needs: [info, build] + permissions: + contents: write + env: + GH_TOKEN: ${{ github.token }} + steps: + + - name: Create GitHub Release + run: | + echo '[dawn commit](https://dawn.googlesource.com/dawn/+/${{ needs.info.outputs.DAWN_COMMIT }})' >>notes.txt + gh release create ${{ needs.info.outputs.BUILD_DATE }} -R "${GITHUB_REPOSITORY}" -t '${{ needs.info.outputs.BUILD_DATE }}' -F notes.txt + + - name: Get Artifacts From Build Steps + uses: actions/download-artifact@v4 with: - upload_url: ${{ steps.release.outputs.upload_url }} - asset_path: "webgpu-dawn-${{ steps.build.outputs.BUILD_DATE }}.zip" - asset_name: "webgpu-dawn-${{ steps.build.outputs.BUILD_DATE }}.zip" - asset_content_type: application/zip + pattern: dawn-*-${{ needs.info.outputs.BUILD_DATE }} + merge-multiple: true + + - name: Upload Artifacts to GitHub Release + run: gh release upload '${{ needs.info.outputs.BUILD_DATE }}' dawn-*-${{ needs.info.outputs.BUILD_DATE }}.zip -R "${GITHUB_REPOSITORY}" diff --git a/.gitignore b/.gitignore index 33c9f99..f071bad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,5 @@ dawn -dawn.build +dawn-* +dawn.build-* depot_tools -webgpu.dll -webgpu.h -webgpu.lib -dawn_commit.txt *.zip diff --git a/README.md b/README.md index 4762f4d..324155f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Automatic weekly build of [dawn][] WebGPU implementation for 64-bit Windows. +Automatic weekly build of [dawn][] WebGPU implementation for 64-bit Windows (x64 and arm64). Build produces single `webgpu_dawn.dll` file that exports all public Dawn WebGPU C functions. To use in your code - either load the `webgpu_dawn.dll` file dynamically or link to it via `webgpu_dawn.lib` import library. diff --git a/build.cmd b/build.cmd index 7f1b8d1..73eac69 100644 --- a/build.cmd +++ b/build.cmd @@ -3,6 +3,23 @@ setlocal enabledelayedexpansion cd %~dp0 +rem +rem build architecture +rem + +if "%1" equ "x64" ( + set ARCH=x64 +) else if "%1" equ "arm64" ( + set ARCH=arm64 +) else if "%1" neq "" ( + echo Unknown target "%1" architecture! + exit /b 1 +) else if "%PROCESSOR_ARCHITECTURE%" equ "AMD64" ( + set ARCH=x64 +) else if "%PROCESSOR_ARCHITECTURE%" equ "ARM64" ( + set ARCH=arm64 +) + rem rem dependencies rem @@ -31,20 +48,6 @@ if exist "%ProgramFiles%\7-Zip\7z.exe" ( set SZIP=7za.exe ) -rem -rem MSVC environment -rem - -where /Q cl.exe || ( - set __VSCMD_ARG_NO_LOGO=1 - for /f "tokens=*" %%i in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.VisualStudio.Workload.NativeDesktop -property installationPath') do set VS=%%i - if "!VS!" equ "" ( - echo ERROR: Visual Studio installation not found - exit /b 1 - ) - call "!VS!\VC\Auxiliary\Build\vcvarsall.bat" amd64 || exit /b 1 -) - rem rem get depot tools rem @@ -60,18 +63,28 @@ rem rem clone dawn rem +if "%DAWN_COMMIT%" equ "" ( + for /f "tokens=1 usebackq" %%F IN (`git ls-remote https://dawn.googlesource.com/dawn HEAD`) do set DAWN_COMMIT=%%F +) + if not exist dawn ( - call git clone --depth=1 --no-tags --single-branch https://dawn.googlesource.com/dawn || exit /b 1 -) else ( - cd dawn - call git pull --force --no-tags || exit /b 1 - cd .. + mkdir dawn + pushd dawn + call git init . || exit /b 1 + call git remote add origin https://dawn.googlesource.com/dawn || exit /b 1 + popd ) -cd dawn +pushd dawn + +call git fetch origin %DAWN_COMMIT% || exit /b 1 +call git checkout --force FETCH_HEAD || exit /b 1 + copy /y scripts\standalone.gclient .gclient -call gclient sync || exit /b 1 -cd .. +"C:\Program Files\Git\usr\bin\sed.exe" -i.bak -e "/'third_party\/catapult'\: /,+3d" -e "/'third_party\/swiftshader'\: /,+3d" -e "/'third_party\/angle'\: /,+3d" -e "/'third_party\/webgpu-cts'\: /,+3d" -e "/'third_party\/vulkan-validation-layers\/src'\: /,+3d" -e "/'third_party\/khronos\/OpenGL-Registry'\: /,+3d" DEPS || exit /b 1 +call gclient sync -f -D -R || exit /b 1 + +popd rem rem build dawn @@ -79,9 +92,11 @@ rem cmake ^ -S dawn ^ - -B dawn.build ^ + -B dawn.build-%ARCH% ^ + -A %ARCH% ^ -D CMAKE_BUILD_TYPE=Release ^ -D CMAKE_POLICY_DEFAULT_CMP0091=NEW ^ + -D CMAKE_POLICY_DEFAULT_CMP0092=NEW ^ -D CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ^ -D BUILD_SHARED_LIBS=OFF ^ -D BUILD_SAMPLES=OFF ^ @@ -91,41 +106,35 @@ cmake ^ -D DAWN_ENABLE_DESKTOP_GL=OFF ^ -D DAWN_ENABLE_OPENGLES=OFF ^ -D DAWN_ENABLE_VULKAN=OFF ^ + -D DAWN_USE_GLFW=OFF ^ -D DAWN_BUILD_SAMPLES=OFF ^ - -D TINT_BUILD_SAMPLES=OFF ^ - -D TINT_BUILD_DOCS=OFF ^ -D TINT_BUILD_TESTS=OFF ^ || exit /b 1 set CL=/Wv:18 -cmake.exe --build dawn.build --config Release --target webgpu_dawn --parallel || exit /b 1 +cmake.exe --build dawn.build-%ARCH% --config Release --target webgpu_dawn --parallel || exit /b 1 rem -rem GitHub actions stuff +rem prepare output folder rem -copy /y dawn.build\gen\include\dawn\webgpu.h . -copy /y dawn.build\Release\webgpu_dawn.dll . -copy /y dawn.build\src\dawn\native\Release\webgpu_dawn.lib . +mkdir dawn-%ARCH% -if "%GITHUB_WORKFLOW%" neq "" ( +echo %DAWN_COMMIT% > dawn-%ARCH%\commit.txt - set /p DAWN_COMMIT= webgpu_dawn_commit.txt +copy /y dawn.build-%ARCH%\gen\include\dawn\webgpu.h dawn-%ARCH% +copy /y dawn.build-%ARCH%\Release\webgpu_dawn.dll dawn-%ARCH% +copy /y dawn.build-%ARCH%\src\dawn\native\Release\webgpu_dawn.lib dawn-%ARCH% - for /F "skip=1" %%D in ('WMIC OS GET LocalDateTime') do (set LDATE=%%D & goto :dateok) - :dateok - set BUILD_DATE=%LDATE:~0,4%-%LDATE:~4,2%-%LDATE:~6,2% +rem +rem Done! +rem - %SZIP% a -y -mx=9 webgpu-dawn-%BUILD_DATE%.zip webgpu_dawn.dll webgpu_dawn.lib webgpu.h webgpu_dawn_commit.txt || exit /b 1 +if "%GITHUB_WORKFLOW%" neq "" ( - echo ::set-output name=DAWN_COMMIT::!DAWN_COMMIT! - echo ::set-output name=BUILD_DATE::%BUILD_DATE% + rem + rem GitHub actions stuff + rem + %SZIP% a -y -mx=9 dawn-%ARCH%-%BUILD_DATE%.zip dawn-%ARCH% || exit /b 1 ) - -rem -rem done! -rem - -goto :eof