Skip to content

Update build script #225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions .github/workflows/build-dawn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,30 @@ jobs:
uses: actions/checkout@v2
with:
submodules: true

- name: Initialize Dawn's abseil-cpp submodule
run: |
cd externals/dawn
git submodule update --init third_party/abseil-cpp
- name: Setup Android NDK
id: setup-ndk
uses: nttld/setup-ndk@v1
with:
ndk-version: r26d

- name: Set ANDROID_NDK
run: echo "ANDROID_NDK=$ANDROID_HOME/ndk-bundle" >> $GITHUB_ENV

- name: Setup Ninja
uses: seanmiddleditch/gha-setup-ninja@master

- uses: actions/setup-node@v3
with:
cache: 'yarn'
cache-dependency-path: yarn.lock

- name: Install Package
run: yarn install --frozen-lockfile

- name: Build Dawn
working-directory: packages/webgpu
env:
ANDROID_NDK: ${{ steps.setup-ndk.outputs.ndk-path }}
run: yarn build-dawn

- name: Upload artifacts - Dawn Library Files
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
Expand Down
52 changes: 42 additions & 10 deletions packages/webgpu/scripts/build/apple.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
# WATCHOSCOMBINED = Build for armv7k arm64_32 x86_64 watchOS + watchOS Simulator. Combined into FAT STATIC lib (only supported on 3.14+ of CMake with "-G Xcode" argument in combination with the "cmake --install" CMake build step)
# SIMULATOR_WATCHOS = Build for x86_64 for watchOS Simulator.
# SIMULATORARM64_WATCHOS = Build for arm64 for watchOS Simulator.
# SIMULATOR_WATCHOSCOMBINED = Build for arm64 x86_64 for watchOS Simulator. Combined into FAT STATIC lib (supported on 3.14+ of CMakewith "-G Xcode" argument ONLY)
# MAC = Build for x86_64 macOS.
# MAC_ARM64 = Build for Apple Silicon macOS.
# MAC_UNIVERSAL = Combined build for x86_64 and Apple Silicon on macOS.
Expand Down Expand Up @@ -166,7 +167,7 @@ set(ENV{_IOS_TOOLCHAIN_HAS_RUN} true)
list(APPEND _supported_platforms
"OS" "OS64" "OS64COMBINED" "SIMULATOR" "SIMULATOR64" "SIMULATORARM64" "SIMULATOR64COMBINED"
"TVOS" "TVOSCOMBINED" "SIMULATOR_TVOS" "SIMULATORARM64_TVOS"
"WATCHOS" "WATCHOSCOMBINED" "SIMULATOR_WATCHOS" "SIMULATORARM64_WATCHOS"
"WATCHOS" "WATCHOSCOMBINED" "SIMULATOR_WATCHOS" "SIMULATORARM64_WATCHOS" "SIMULATOR_WATCHOSCOMBINED"
"MAC" "MAC_ARM64" "MAC_UNIVERSAL"
"VISIONOS" "SIMULATOR_VISIONOS" "VISIONOSCOMBINED"
"MAC_CATALYST" "MAC_CATALYST_ARM64" "MAC_CATALYST_UNIVERSAL")
Expand Down Expand Up @@ -461,12 +462,12 @@ elseif(PLATFORM_INT STREQUAL "WATCHOSCOMBINED")
if(MODERN_CMAKE)
if(NOT ARCHS)
if (XCODE_VERSION_INT VERSION_GREATER 10.0)
set(ARCHS armv7k arm64_32 i386)
set(APPLE_TARGET_TRIPLE_INT arm64_32-i386-apple-watchos${DEPLOYMENT_TARGET})
set(ARCHS armv7k arm64_32 x86_64)
set(APPLE_TARGET_TRIPLE_INT arm64_32-x86_64-apple-watchos${DEPLOYMENT_TARGET})
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchos*] "armv7k arm64_32")
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchsimulator*] "i386")
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchsimulator*] "x86_64")
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchos*] "armv7k arm64_32")
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchsimulator*] "i386")
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchsimulator*] "x86_64")
else()
set(ARCHS armv7k i386)
set(APPLE_TARGET_TRIPLE_INT arm-i386-apple-watchos${DEPLOYMENT_TARGET})
Expand All @@ -484,8 +485,13 @@ elseif(PLATFORM_INT STREQUAL "WATCHOSCOMBINED")
elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS")
set(SDK_NAME watchsimulator)
if(NOT ARCHS)
set(ARCHS i386)
set(APPLE_TARGET_TRIPLE_INT i386-apple-watchos${DEPLOYMENT_TARGET}-simulator)
if (XCODE_VERSION_INT VERSION_GREATER 10.0)
set(ARCHS x86_64)
set(APPLE_TARGET_TRIPLE_INT x86_64-apple-watchos${DEPLOYMENT_TARGET}-simulator)
else()
set(ARCHS i386)
set(APPLE_TARGET_TRIPLE_INT i386-apple-watchos${DEPLOYMENT_TARGET}-simulator)
endif()
else()
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos${DEPLOYMENT_TARGET}-simulator)
endif()
Expand All @@ -497,6 +503,31 @@ elseif(PLATFORM_INT STREQUAL "SIMULATORARM64_WATCHOS")
else()
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos${DEPLOYMENT_TARGET}-simulator)
endif()
elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOSCOMBINED")
set(SDK_NAME watchsimulator)
if(MODERN_CMAKE)
if(NOT ARCHS)
if (XCODE_VERSION_INT VERSION_GREATER 12.0)
set(ARCHS arm64 x86_64)
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchos*] "")
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchsimulator*] "arm64 x86_64")
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchos*] "")
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchsimulator*] "arm64 x86_64")
set(APPLE_TARGET_TRIPLE_INT arm64_x86_64-apple-watchos${DEPLOYMENT_TARGET}-simulator)
else()
set(ARCHS arm64 i386)
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchos*] "")
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchsimulator*] "i386")
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchos*] "")
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchsimulator*] "i386")
set(APPLE_TARGET_TRIPLE_INT arm64_i386-apple-watchos${DEPLOYMENT_TARGET}-simulator)
endif()
else()
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos${DEPLOYMENT_TARGET}-simulator)
endif()
else()
message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the SIMULATOR_WATCHOSCOMBINED setting work")
endif()
elseif(PLATFORM_INT STREQUAL "SIMULATOR_VISIONOS")
set(SDK_NAME xrsimulator)
if(NOT ARCHS)
Expand Down Expand Up @@ -554,8 +585,9 @@ elseif(PLATFORM_INT STREQUAL "MAC_UNIVERSAL")
if(NOT ARCHS)
set(ARCHS "x86_64;arm64")
endif()
string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}")
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-macosx${DEPLOYMENT_TARGET})
# For universal builds, don't set target triple - let CMake handle it
# string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}")
# set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-macosx${DEPLOYMENT_TARGET})
elseif(PLATFORM_INT STREQUAL "MAC_CATALYST_UNIVERSAL")
set(SDK_NAME macosx)
if(NOT ARCHS)
Expand Down Expand Up @@ -1142,4 +1174,4 @@ macro(find_host_package)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
endmacro(find_host_package)
endmacro(find_host_package)
4 changes: 3 additions & 1 deletion packages/webgpu/scripts/build/dawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ const apple = {
(async () => {
process.chdir("../..");
process.chdir("externals/dawn");
$("git reset --hard HEAD");
$(
"git reset --hard HEAD && cd third_party/abseil-cpp && git reset --hard HEAD && cd ../..",
);
$(`git apply ${__dirname}/static_build.patch`);
process.chdir("../..");
console.log("Copy headers");
Expand Down
27 changes: 26 additions & 1 deletion packages/webgpu/scripts/build/static_build.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/src/cmake/BundleLibraries.cmake b/src/cmake/BundleLibraries.cmake
index 046a6af10d..5a63ac3d6d 100644
index 046a6af10d..ee272710fd 100644
--- a/src/cmake/BundleLibraries.cmake
+++ b/src/cmake/BundleLibraries.cmake
@@ -66,8 +66,11 @@ function(bundle_libraries output_target)
Expand All @@ -16,3 +16,28 @@ index 046a6af10d..5a63ac3d6d 100644
add_dependencies(${output_target} ${ARGN})

endfunction()
Submodule third_party/abseil-cpp contains modified content
diff --git a/third_party/abseil-cpp/absl/copts/AbseilConfigureCopts.cmake b/third_party/abseil-cpp/absl/copts/AbseilConfigureCopts.cmake
index 3f737c8..9b8bb4b 100644
--- a/third_party/abseil-cpp/absl/copts/AbseilConfigureCopts.cmake
+++ b/third_party/abseil-cpp/absl/copts/AbseilConfigureCopts.cmake
@@ -11,6 +11,11 @@ else()
endif()

if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES [[Clang]])
+ # Fix for iOS/visionOS ARM64 builds - skip x86_64 flags when building for ARM64 only
+ if((CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "visionOS") AND CMAKE_OSX_ARCHITECTURES MATCHES "arm64" AND NOT CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
+ set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_ARM64_FLAGS}")
+ list(APPEND ABSL_RANDOM_RANDEN_COPTS "-Wno-unused-command-line-argument")
+ else()
# Some CMake targets (not known at the moment of processing) could be set to
# compile for multiple architectures as specified by the OSX_ARCHITECTURES
# property, which is target-specific. We should neither inspect nor rely on
@@ -52,6 +57,7 @@ if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES [[Clang]])
if(ABSL_RANDOM_RANDEN_COPTS AND NOT ABSL_RANDOM_RANDEN_COPTS_WARNING)
list(APPEND ABSL_RANDOM_RANDEN_COPTS "-Wno-unused-command-line-argument")
endif()
+ endif() # End iOS ARM64 fix
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")
if (MSVC)
set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_MSVC_X64_FLAGS}")