Skip to content

Commit

Permalink
build script improvements, add arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
mmozeiko committed Sep 7, 2024
1 parent a8a9643 commit 550bf5e
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 76 deletions.
77 changes: 52 additions & 25 deletions .github/workflows/build-dawn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
dawn
dawn.build
dawn-*
dawn.build-*
depot_tools
webgpu.dll
webgpu.h
webgpu.lib
dawn_commit.txt
*.zip
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
99 changes: 54 additions & 45 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -60,28 +63,40 @@ 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
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 ^
Expand All @@ -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=<dawn\.git\refs\heads\main
echo !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

0 comments on commit 550bf5e

Please sign in to comment.