Skip to content

Commit

Permalink
first
Browse files Browse the repository at this point in the history
  • Loading branch information
mmozeiko committed May 28, 2023
0 parents commit b1be3f0
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/build-dawn.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

name: build-dawn

on:
schedule:
- cron: "0 0 * * 0"
push:
branches:
- main

jobs:
build:
runs-on: windows-2022
steps:

- name: checkout
uses: actions/checkout@v2

- name: build
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 }}
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 }}
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: "webgpu-${{ steps.build.outputs.BUILD_DATE }}.zip"
asset_name: "webgpu-${{ steps.build.outputs.BUILD_DATE }}.zip"
asset_content_type: application/zip
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
dawn
dawn.build
depot_tools
webgpu.dll
webgpu.h
webgpu.lib
dawn_commit.txt
*.zip
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Automatic weekly build of [dawn][] WebGPU implementation for 64-bit Windows.

Build produces single `webgpu.dll` file that exports all public Dawn WebGPU C functions.
To use in your code - either load the `webgpu.dll` file dynamically or link to it via `webgpu.lib` import library.

Download binary build as zip archive from [latest release][] page.

To build locally run `build.cmd` batch file, make sure you have installed all necessary dependencies (see the beginning of file).

[dawn]: https://dawn.googlesource.com/dawn/
[latest release]: https://github.com/mmozeiko/build-dawn/releases/latest
133 changes: 133 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
@echo off
setlocal enabledelayedexpansion

cd %~dp0

rem
rem dependencies
rem

where /q git.exe || (
echo ERROR: "git.exe" not found
exit /b 1
)

where /q cmake.exe || (
echo ERROR: "cmake.exe" not found
exit /b 1
)

rem
rem 7-Zip
rem

if exist "%ProgramFiles%\7-Zip\7z.exe" (
set SZIP="%ProgramFiles%\7-Zip\7z.exe"
) else (
where /q 7za.exe || (
echo ERROR: 7-Zip installation or "7za.exe" not found
exit /b 1
)
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

set PATH=%CD%\depot_tools;%PATH%
set DEPOT_TOOLS_WIN_TOOLCHAIN=0

if not exist depot_tools (
call git clone --depth=1 --no-tags --single-branch https://chromium.googlesource.com/chromium/tools/depot_tools.git || exit /b 1
)

rem
rem clone dawn
rem

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 restore src\dawn\native\CMakeLists.txt
call git pull --force --no-tags || exit /b 1
cd ..
)

cd dawn
copy /y scripts\standalone.gclient .gclient
call gclient sync || exit /b 1
cd ..

type extra.cmake >> dawn\src\dawn\native\CMakeLists.txt

rem
rem build dawn
rem

cmake ^
-S dawn ^
-B dawn.build ^
-D CMAKE_BUILD_TYPE=Release ^
-D CMAKE_POLICY_DEFAULT_CMP0091=NEW ^
-D CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ^
-D BUILD_SHARED_LIBS=OFF ^
-D BUILD_SAMPLES=OFF ^
-D DAWN_ENABLE_D3D12=ON ^
-D DAWN_ENABLE_D3D11=OFF ^
-D DAWN_ENABLE_NULL=OFF ^
-D DAWN_ENABLE_DESKTOP_GL=OFF ^
-D DAWN_ENABLE_OPENGLES=OFF ^
-D DAWN_ENABLE_VULKAN=OFF ^
-D DAWN_BUILD_SAMPLES=OFF ^
-D TINT_BUILD_SAMPLES=OFF ^
-D TINT_BUILD_DOCS=OFF ^
-D TINT_BUILD_TESTS=OFF ^
|| exit /b 1

cmake.exe --build dawn.build --config Release --target webgpu --parallel || exit /b 1

rem
rem GitHub actions stuff
rem

copy /y dawn.build\gen\include\dawn\webgpu.h .
copy /y dawn.build\Release\webgpu.dll .
copy /y dawn.build\src\dawn\native\Release\webgpu.lib .

if "%GITHUB_WORKFLOW%" neq "" (

set /p DAWN_COMMIT=<dawn\.git\refs\heads\main
echo !DAWN_COMMIT! > dawn_commit.txt

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%

%SZIP% a -y -mx=9 webgpu-%BUILD_DATE%.zip webgpu.dll webgpu.lib webgpu.h dawn_commit.txt || exit /b 1

echo ::set-output name=DAWN_COMMIT::!DAWN_COMMIT!
echo ::set-output name=BUILD_DATE::%BUILD_DATE%

)

rem
rem done!
rem

goto :eof
7 changes: 7 additions & 0 deletions extra.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

add_library(webgpu SHARED ${DAWN_PLACEHOLDER_FILE})
common_compile_options(webgpu)
target_link_libraries(webgpu PRIVATE dawn_native)
target_link_libraries(webgpu PUBLIC dawn_headers)
target_compile_definitions(webgpu PRIVATE WGPU_IMPLEMENTATION WGPU_SHARED_LIBRARY)
target_sources(webgpu PRIVATE ${WEBGPU_DAWN_NATIVE_PROC_GEN})

0 comments on commit b1be3f0

Please sign in to comment.