diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 6f19959..3da3139 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -25,7 +25,6 @@ RUN apt-get update && apt-get install -y \ ninja-build \ pkg-config \ python3 \ - python3-lldb-13 \ python3-pip \ python3-venv \ tzdata \ diff --git a/.github/workflows/dawn-check.yaml b/.github/workflows/dawn-check.yaml new file mode 100644 index 0000000..88bbce0 --- /dev/null +++ b/.github/workflows/dawn-check.yaml @@ -0,0 +1,93 @@ +# Copyright 2025 Adobe +# All Rights Reserved. +# +# NOTICE: Adobe permits you to use, modify, and distribute this file in +# accordance with the terms of the Adobe license agreement accompanying +# it. + +name: Check if Dawn is up to date + +on: + workflow_dispatch: + inputs: + channel: + description: "Chromium channel for Dawn" + required: false + default: "canary" + type: choice + options: + - stable + - beta + - canary + config: + description: "Configuration" + required: false + default: "release" + type: choice + options: + - release + - debug + +jobs: + check-dawn: + runs-on: ubuntu-latest + outputs: + needs_build: ${{ steps.release_check.outputs.needs_build }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + cd Dawn + pip install -r requirements.txt + + - name: Get Dawn version + run: | + cd Dawn + python ci_build_dawn.py get-dawn-version --channel ${{ github.event.inputs.channel }} + + - name: Read Dawn version + id: read-version + run: | + cd Dawn + value=$(jq -r '.chromium_channel' dawn_version.json) + echo "chromium_channel=$value" >> $GITHUB_OUTPUT + value=$(jq -r '.chromium_dawn_version' dawn_version.json) + echo "chromium_dawn_version=$value" >> $GITHUB_OUTPUT + value=$(jq -r '.chromium_dawn_hash' dawn_version.json) + echo "chromium_dawn_hash=$value" >> $GITHUB_OUTPUT + value=$(jq -r '.chromium_dawn_suffix' dawn_version.json) + echo "chromium_dawn_suffix=$value" >> $GITHUB_OUTPUT + + - name: Tag name + id: tag + run: | + TAG="dawn-chromium-${{github.event.inputs.channel}}-${{steps.read-version.outputs.chromium_dawn_version}}-${{github.event.inputs.config}}" + echo "tag=$TAG" >> $GITHUB_OUTPUT + + - name: Run Dawn build if necessary + id: release_check + run: | + TAG="${{ steps.tag.outputs.tag }}" + if gh release view "$TAG" >/dev/null 2>&1; then + echo "Release '$TAG' already exists. Skipping upload." + echo "needs_build=false" >> $GITHUB_OUTPUT + else + echo "Uploading to release: $TAG" + echo "needs_build=true" >> $GITHUB_OUTPUT + fi + + build-dawn: + if: ${{ needs.check-dawn.outputs.needs_build == 'true' }} + needs: check-dawn + uses: ./.github/workflows/dawn.yaml + with: + channel: ${{ github.event.inputs.channel }} + config: ${{ github.event.inputs.config }} diff --git a/.github/workflows/dawn.yaml b/.github/workflows/dawn.yaml index d0dfd6d..8409914 100644 --- a/.github/workflows/dawn.yaml +++ b/.github/workflows/dawn.yaml @@ -1,3 +1,9 @@ +# Copyright 2025 Adobe +# All Rights Reserved. +# +# NOTICE: Adobe permits you to use, modify, and distribute this file in +# accordance with the terms of the Adobe license agreement accompanying +# it. name: Build Dawn WebGPU on: @@ -12,14 +18,46 @@ on: - stable - beta - canary + config: + description: "Configuration" + required: false + default: "release" + type: choice + options: + - release + - debug -env: - DAWN_CHANNEL: ${{ github.event.inputs.channel || 'canary' }} + workflow_call: + inputs: + channel: + description: "Chromium channel for Dawn" + required: false + default: "canary" + type: choice + options: + - stable + - beta + - canary + config: + description: "Configuration" + required: false + default: "release" + type: choice + options: + - release + - debug + secrets: + GITHUB_TOKEN: + required: true jobs: - get-dawn-source: + get-dawn-version: runs-on: ubuntu-latest - + outputs: + chromium_channel: ${{ steps.read-version.outputs.chromium_channel }} + chromium_dawn_version: ${{ steps.read-version.outputs.chromium_dawn_version }} + chromium_dawn_hash: ${{ steps.read-version.outputs.chromium_dawn_hash }} + chromium_dawn_suffix: ${{ steps.read-version.outputs.chromium_dawn_suffix }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -35,18 +73,16 @@ jobs: cd Dawn pip install -r requirements.txt - - name: Get Dawn source + - name: Get Dawn version run: | cd Dawn - python ci_build_dawn.py get-dawn --channel ${{ env.DAWN_CHANNEL }} + python ci_build_dawn.py get-dawn-version --channel ${{ github.event.inputs.channel }} - - name: Upload Dawn source + - name: Upload Dawn Version uses: actions/upload-artifact@v4 with: - name: dawn-source - path: | - Dawn/dawn_source/ - !Dawn/dawn_source/.git + name: dawn-version + path: Dawn/dawn_version.json retention-days: 1 - name: Read Dawn version @@ -63,7 +99,7 @@ jobs: echo "chromium_dawn_suffix=$value" >> $GITHUB_OUTPUT build-dawn: - needs: get-dawn-source + needs: get-dawn-version strategy: matrix: include: @@ -89,6 +125,12 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Install prerequisites on Linux + if: matrix.platform == 'ubuntu-latest' + run: | + sudo apt-get update + sudo apt-get install -y build-essential clang cmake curl git gnupg2 libcurl4-openssl-dev libpython3-dev libssl-dev libx11-xcb-dev libxcursor-dev libxi-dev libxinerama-dev libxml2-dev libxrandr-dev libz-dev libz3-dev mesa-common-dev ninja-build pkg-config python3 python3-pip python3-venv tzdata unzip wget + - name: Set up Python uses: actions/setup-python@v5 with: @@ -101,27 +143,37 @@ jobs: pip install -r requirements.txt - name: Download Dawn source - uses: actions/download-artifact@v5 - with: - name: dawn-source - path: Dawn/dawn_source/ + run: | + cd Dawn + python ci_build_dawn.py get-source --hash ${{ needs.get-dawn-version.outputs.chromium_dawn_hash }} - name: Build Dawn for ${{ matrix.target }} run: | cd Dawn - python ci_build_dawn.py build-target --target ${{ matrix.target }} + python ci_build_dawn.py build-target --target ${{ matrix.target }} --config ${{ env.DAWN_CONFIG }} - name: Upload build artifacts uses: actions/upload-artifact@v4 with: name: dawn-build-${{ matrix.target }} - path: Dawn/builds/ + path: | + Dawn/builds/ + !Dawn/builds/*/out + retention-days: 1 + + - name: Upload dawn.json + if: matrix.platform == 'ubuntu-latest' + uses: actions/upload-artifact@v4 + with: + name: dawn-json + path: Dawn/dawn_source/src/dawn/dawn.json retention-days: 1 create-bundle: - needs: [build-dawn, get-dawn-source] + needs: [build-dawn, get-dawn-version] runs-on: ubuntu-latest - + outputs: + bundle_name: ${{ steps.set-bundle-name.outputs.bundle_name }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -137,47 +189,82 @@ jobs: cd Dawn pip install -r requirements.txt + - name: Download dawn.json + uses: actions/download-artifact@v5 + with: + name: dawn-json + path: Dawn/dawn_source/src/dawn + - name: Download all build artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v5 with: + pattern: dawn-build-* path: Dawn/builds/ + merge-multiple: true + + - name: Download Dawn version + uses: actions/download-artifact@v5 + with: + name: dawn-version + path: Dawn/ + merge-multiple: true - name: Create artifact bundle run: | cd Dawn python ci_build_dawn.py bundle + - name: Set bundle name + id: set-bundle-name + run: | + BUNDLE_NAME="dawn_webgpu_${{needs.get-dawn-version.outputs.chromium_dawn_suffix}}.zip" + echo "bundle_name=$BUNDLE_NAME" >> $GITHUB_OUTPUT + - name: Upload bundle artifact uses: actions/upload-artifact@v4 with: name: dawn-webgpu-bundle - path: Dawn/dawn_webgpu_${{needs.get-dawn-source.outputs.chromium_dawn_suffix}}.zip + path: Dawn/dist/${{steps.set-bundle-name.outputs.bundle_name}} retention-days: 30 create-release: - needs: [create-bundle, get-dawn-source] + needs: [create-bundle, get-dawn-version] runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - steps: - name: Checkout code uses: actions/checkout@v4 - name: Download bundle artifact - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v5 with: name: dawn-webgpu-bundle path: dawn-bundle/ + merge-multiple: true + + - name: Compute SHA256 + id: compute-sha256 + run: | + cd dawn-bundle + sha256sum ${{needs.create-bundle.outputs.bundle_name}} > sha256sum.txt + echo "sha256sum=$(cat sha256sum.txt)" >> $GITHUB_OUTPUT + + - name: Tag name + id: tag + run: | + TAG="dawn-chromium-${{github.event.inputs.channel}}-${{needs.get-dawn-version.outputs.chromium_dawn_version}}" + echo "tag=$TAG" >> $GITHUB_OUTPUT - name: Create Release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - release_name: Dawn WebGPU from Chromium ${{ needs.get-dawn-source.outputs.chromium_dawn_version }} + release_name: Dawn WebGPU from Chromium ${{ needs.get-dawn-version.outputs.chromium_dawn_version }} + tag_name: ${{ steps.tag.outputs.tag }} body: | - Dawn WebGPU build matching Chromium ${{ needs.get-dawn-source.outputs.chromium_dawn_version }}. - Built from Dawn hash: ${{ needs.get-dawn-source.outputs.chromium_dawn_hash }} + Dawn WebGPU build matching Chromium ${{ needs.get-dawn-version.outputs.chromium_dawn_version }}. + Built from Dawn hash: ${{ needs.get-dawn-version.outputs.chromium_dawn_hash }} + SHA256: ${{ steps.compute-sha256.outputs.sha256sum }} This release contains pre-built Dawn WebGPU libraries for multiple platforms: - linux (x86_64) @@ -185,19 +272,17 @@ jobs: - iphoneos (ARM64) - iphonesimulator (x86_64) - Built from Chromium channel: ${{ env.DAWN_CHANNEL }} + These are just the raw Dawn libraries and do not include the Swift API layer. + + Built from Chromium channel: ${{ github.event.inputs.channel }} draft: false prerelease: false - name: Upload Release Assets run: | - TAG="dawn-chromium-${{env.DAWN_CHANNEL}}-${{needs.get-dawn-source.outputs.chromium_dawn_version}}" - if gh release view "$TAG" >/dev/null 2>&1; then - echo "Release '$TAG' already exists. Skipping upload." - else - echo "Uploading to release: $TAG" - cd dawn-bundle - gh release upload $TAG dawn_webgpu_${{needs.get-dawn-source.outputs.chromium_dawn_suffix}}.zip --clobber - fi + TAG="${{ steps.tag.outputs.tag }}" + echo "Uploading to release: $TAG" + cd dawn-bundle + gh release upload $TAG ${{needs.create-bundle.outputs.bundle_name}} --clobber env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/linux-docker-image.yaml b/.github/workflows/linux-docker-image.yaml deleted file mode 100644 index d3fc575..0000000 --- a/.github/workflows/linux-docker-image.yaml +++ /dev/null @@ -1,58 +0,0 @@ -name: Build and Push Docker Image - -on: - push: - branches: [main] - paths: - - ".devcontainer/Dockerfile" - pull_request: - paths: - - ".devcontainer/Dockerfile" - workflow_dispatch: - -env: - REGISTRY: ghcr.io - IMAGE_NAME: adobe/swan-dawn-builder - -jobs: - build-and-push: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to Container Registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=ref,event=branch - type=ref,event=pr - type=sha,prefix={{branch}}- - type=raw,value=latest,enable={{is_default_branch}} - - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: . - file: .devcontainer/Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max diff --git a/Dawn/README.md b/Dawn/README.md index 0ef1070..c928cb2 100644 --- a/Dawn/README.md +++ b/Dawn/README.md @@ -21,8 +21,12 @@ If you wish to build a version of Dawn yourself, you can use these CI scripts as python3 -m venv .venv pip3 install -r requirements.txt -# Download the Dawn source matching the latest release of Chromium Canary -./ci_build_dawn.py get-dawn +# Determine the latest release of Chromium Canary and get the Dawn hash +# Write the data to dawn_version.json +./ci_build_dawn.py get-dawn-version + +# Download the Dawn source matching the given hash +./ci_build_dawn.py get-source --hash ABC1234ABC # Build Dawn, running these commands on the appropriate platform # Note that macosx builds both Intel and Arm diff --git a/Dawn/archive_builder.py b/Dawn/archive_builder.py index 0add2ad..b3b885c 100644 --- a/Dawn/archive_builder.py +++ b/Dawn/archive_builder.py @@ -24,13 +24,16 @@ def write_target_manifest( manifest_file: Path to the manifest file to write target_config: Target configuration containing build settings """ - build_dir = pathlib.Path("builds").resolve() + build_dir = pathlib.Path("builds") target_dir = build_dir / str(target_config) / "install" manifest = { "targetName": str(target_config), "libraryPath": str(target_dir / "lib"), "includePath": str(target_dir / "include"), "supportedTriples": target_config.triples(), + "libraryName": "libwebgpu_dawn.lib" + if target_config.os.is_windows() + else "libwebgpu_dawn.a", } manifest_file.write_text(json.dumps(manifest, indent=2)) @@ -56,13 +59,15 @@ def write_bundle_manifest(version: str) -> None: Args: version: Version string for the bundle """ - archive_dir = pathlib.Path("dist").resolve() / "dawn_webgpu.artifactbundle" + archive_dir = pathlib.Path("dist") / "dawn_webgpu.artifactbundle" archive_dir.mkdir(exist_ok=True, parents=True) archive_manifest_file = archive_dir / "info.json" target_manifests = [ { - "path": str(pathlib.Path(manifest["targetName"]) / "libwebgpu_dawn.a"), + "path": ( + pathlib.Path(manifest["targetName"]) / manifest["libraryName"] + ).as_posix(), "staticLibraryMetadata": {"headerPaths": ["include"]}, "supportedTriples": manifest["supportedTriples"], } @@ -90,15 +95,15 @@ def build_bundle_target(target_config: TargetConfig) -> None: target_config: Target configuration for the build """ dawn_path = dawn_source.get_dawn_path() - build_dir = pathlib.Path("builds").resolve() + build_dir = pathlib.Path("builds") target_name = str(target_config) target_dir = build_dir / target_name / "install" target_dir.mkdir(exist_ok=True, parents=True) - manifset_dir = build_dir / "manifest" - manifset_dir.mkdir(exist_ok=True, parents=True) - manifest_file = manifset_dir / f"{target_name}.json" + manifest_dir = build_dir / "manifest" + manifest_dir.mkdir(exist_ok=True, parents=True) + manifest_file = manifest_dir / f"{target_name}.json" dawn_builder.build_dawn(dawn_path, target_dir, target_config) write_target_manifest(manifest_file, target_config) @@ -153,7 +158,7 @@ def create_artifact_bundle(version: str, archive_name: str) -> pathlib.Path: dawn_version_file.write_text(json.dumps(version_data, indent=2)) # Create the archive - archive_path = pathlib.Path("dist").resolve() / f"{archive_name}" + archive_path = pathlib.Path("dist") / f"{archive_name}" # Remove the archive if it exists (from shutil.make_archive) if archive_path.exists(): @@ -173,7 +178,7 @@ def dist_directory() -> pathlib.Path: Returns: Path to the dist directory """ - return pathlib.Path("dist").resolve() + return pathlib.Path("dist") def artifact_bundle_directory() -> pathlib.Path: @@ -190,7 +195,7 @@ def remove_build_directory() -> None: """ Remove the build directory and all its contents. """ - build_dir = pathlib.Path("builds").resolve() + build_dir = pathlib.Path("builds") if build_dir.exists(): shutil.rmtree(build_dir) @@ -211,4 +216,4 @@ def manifests_dir() -> pathlib.Path: Returns: Path to the manifests directory """ - return pathlib.Path("builds").resolve() / "manifest" + return pathlib.Path("builds") / "manifest" diff --git a/Dawn/ci_build_dawn.py b/Dawn/ci_build_dawn.py index dd4ade2..a67b5dd 100755 --- a/Dawn/ci_build_dawn.py +++ b/Dawn/ci_build_dawn.py @@ -16,15 +16,15 @@ _EXIT_SUCCESS = 0 -def build_target(target: str, debug: bool) -> None: +def build_target(target: str, config: str = "release") -> None: """ Build a target using the specified configuration. Args: target: The target platform to build for - debug: Whether to build in debug mode + config: The configuration to build for """ - target_config = ci_target(target, debug) + target_config = ci_target(target, config) archive_builder.build_bundle_target(target_config) @@ -77,7 +77,9 @@ def parse_args() -> argparse.Namespace: parser = argparse.ArgumentParser(description="CI build tools for Dawn") subparsers = parser.add_subparsers(dest="command") - get_parser = subparsers.add_parser("get-dawn", help="Get the latest Dawn source") + get_parser = subparsers.add_parser( + "get-dawn-version", help="Get the latest Dawn version" + ) get_parser.add_argument( "--channel", choices=["stable", "beta", "canary"], @@ -85,6 +87,13 @@ def parse_args() -> argparse.Namespace: help="Chromium channel to use for Dawn", ) + get_parser = subparsers.add_parser("get-source", help="Get the Dawn source") + get_parser.add_argument( + "--hash", + required=True, + help="Dawn hash to get the source for", + ) + build_parser = subparsers.add_parser("build-target", help="Build a target") build_parser.add_argument( "--target", @@ -93,13 +102,14 @@ def parse_args() -> argparse.Namespace: help="Target platform to build for", ) build_parser.add_argument( - "--debug", action="store_true", default=False, help="Enable debug mode" + "--config", + choices=["release", "debug"], + default="release", + help="Configuration to build for", ) subparsers.add_parser("bundle", help="Bundle a target") - upload_parser = subparsers.add_parser("upload", help="Upload a target") - subparsers.add_parser("clean", help="Clean the build environment") return parser.parse_args() @@ -113,8 +123,11 @@ def main() -> int: Exit code (0 for success, 1 for failure) """ args = parse_args() - if args.command == "get-dawn": + if args.command == "get-dawn-version": dawn_source.get_matching_dawn_for_chromium(args.channel) + print(dawn_source.get_version()) + elif args.command == "get-source": + dawn_source.fetch_dawn_source(args.hash) elif args.command == "build-target": if args.target not in [ "windows", @@ -126,7 +139,7 @@ def main() -> int: print(f"Invalid target: {args.target}") return _EXIT_FAILURE - build_target(args.target, args.debug) + build_target(args.target, args.config) elif args.command == "bundle": bundle() elif args.command == "upload": diff --git a/Dawn/ci_targets.py b/Dawn/ci_targets.py index eb50329..32520a4 100644 --- a/Dawn/ci_targets.py +++ b/Dawn/ci_targets.py @@ -8,13 +8,13 @@ from dawn_builder import TargetConfig, Arch, OS -def ci_target(name: str, debug: bool) -> TargetConfig: +def ci_target(name: str, config: str = "release") -> TargetConfig: """ Create a TargetConfig for the specified target name and debug mode. Args: name: The target platform name (macosx, iphoneos, iphonesimulator, ipados, linux, windows) - debug: Whether to build in debug mode + config: The configuration to build for Returns: TargetConfig object configured for the specified target @@ -29,7 +29,7 @@ def ci_target(name: str, debug: bool) -> TargetConfig: arch=[Arch.X86_64, Arch.ARM64], sdk="macosx15.5", deployment_target="15.0", - debug=debug, + config=config, ) case "iphoneos": return TargetConfig( @@ -37,7 +37,7 @@ def ci_target(name: str, debug: bool) -> TargetConfig: arch=[Arch.ARM64], sdk="iphoneos18.5", deployment_target="18.0", - debug=debug, + config=config, ) case "iphonesimulator": return TargetConfig( @@ -45,7 +45,7 @@ def ci_target(name: str, debug: bool) -> TargetConfig: arch=[Arch.X86_64], sdk="iphonesimulator18.5", deployment_target="18.0", - debug=debug, + config=config, ) case "ipados": return TargetConfig( @@ -53,11 +53,16 @@ def ci_target(name: str, debug: bool) -> TargetConfig: arch=[Arch.ARM64], sdk="ipados18.5", deployment_target="18.0", - debug=debug, + config=config, ) case "linux": - return TargetConfig(os=OS.LINUX, arch=[Arch.X86_64], debug=debug) + return TargetConfig(os=OS.LINUX, arch=[Arch.X86_64], config=config) case "windows": - return TargetConfig(os=OS.WINDOWS, arch=[Arch.X86_64], debug=debug) + return TargetConfig( + os=OS.WINDOWS, + arch=[Arch.X86_64], + config=config, + build_tool="Visual Studio 17 2022", + ) case _: raise ValueError(f"Invalid target name: {name}") diff --git a/Dawn/dawn_builder.py b/Dawn/dawn_builder.py index 9ac86e1..98a6771 100755 --- a/Dawn/dawn_builder.py +++ b/Dawn/dawn_builder.py @@ -27,6 +27,7 @@ class BuildDawnError(Exception): pass class SDKPathNotFoundError(BuildDawnError): pass class CMakeError(BuildDawnError): pass +class CMakeBuildError(BuildDawnError): pass class UploadArchiverError(BuildDawnError): pass # fmt: on @@ -59,6 +60,15 @@ def is_apple(self) -> bool: """ return self in [OS.MACOS, OS.IPHONE, OS.IPADOS] + def is_windows(self) -> bool: + """ + Check if this OS is Windows. + + Returns: + True if this is a Windows OS + """ + return self == OS.WINDOWS + def get_current_os() -> OS: """ @@ -89,7 +99,8 @@ class TargetConfig: arch: List[Arch] sdk: Optional[str] = None deployment_target: Optional[str] = None - debug: bool = False + config: str = "release" + build_tool: str = "Ninja" def __str__(self) -> str: """ @@ -103,10 +114,7 @@ def __str__(self) -> str: parts.append(arch.value) if self.sdk: parts.append(self.sdk) - if self.debug: - parts.append("debug") - else: - parts.append("release") + parts.append(self.config) return "_".join(parts) def triples(self) -> List[str]: @@ -156,7 +164,7 @@ def cmake_flags(target_config: TargetConfig) -> List[str]: flags.append("-DDAWN_USE_GLFW=OFF") flags.append("-DCMAKE_SYSTEM_NAME=iOS") - if target_config.debug: + if target_config.config == "debug": flags.append("-DCMAKE_BUILD_TYPE=Debug") else: flags.append("-DCMAKE_BUILD_TYPE=Release") @@ -259,10 +267,10 @@ def build_dawn( cmake_exec = shutil.which("cmake", path=os.environ.get("PATH")) - # Run cmake command + # Run cmake command to create the build files try: subprocess.run( - [cmake_exec, "-GNinja", *flags, str(dawn_path)], + [cmake_exec, f"-G{target_config.build_tool}", *flags, str(dawn_path)], env=os.environ, cwd=build_dir, capture_output=True, @@ -273,9 +281,22 @@ def build_dawn( _subprocess_exception_message(e) raise CMakeError - # Run ninja command - ninja_exec = shutil.which("ninja", path=os.environ.get("PATH")) - subprocess.run([ninja_exec], cwd=build_dir, check=True) + # Run the cmake build command + try: + subprocess.run( + [ + cmake_exec, + "--build", + ".", + "--config", + "Debug" if target_config.config == "debug" else "Release", + ], + cwd=build_dir, + check=True, + ) + except subprocess.CalledProcessError as e: + _subprocess_exception_message(e) + raise CMakeBuildError # Install the library and headers try: diff --git a/Dawn/dawn_source.patch b/Dawn/dawn_source.patch new file mode 100644 index 0000000..ea17ec7 --- /dev/null +++ b/Dawn/dawn_source.patch @@ -0,0 +1,13 @@ +diff --git a/src/cmake/DawnLibrary.cmake b/src/cmake/DawnLibrary.cmake +index a5352433f0..fbdcb260db 100644 +--- a/src/cmake/DawnLibrary.cmake ++++ b/src/cmake/DawnLibrary.cmake +@@ -182,7 +182,7 @@ function(dawn_install_target name) + # When building in debug mode with MSVC, install PDB files together with binaries + if (MSVC) + get_target_property(target_type "${name}" TYPE) +- if ((target_type STREQUAL "STATIC_LIBRARY") OR (target_type STREQUAL "SHARED_LIBRARY") OR (target_type STREQUAL "EXECUTABLE")) ++ if ((target_type STREQUAL "SHARED_LIBRARY") OR (target_type STREQUAL "EXECUTABLE")) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL) + endif() + endif (MSVC) diff --git a/Dawn/dawn_source.py b/Dawn/dawn_source.py index 50b6d58..089c85a 100644 --- a/Dawn/dawn_source.py +++ b/Dawn/dawn_source.py @@ -34,12 +34,10 @@ class DawnSourceToolsDirectoryNotFoundError(DawnSourceDirectoryConfigurationErro def get_matching_dawn_for_chromium(channel: str = "canary") -> None: """ Get the Dawn version that matches the latest Chromium release for the given channel + and write the version data to the dawn_version.json file. Args: channel: The Chromium channel to use for fetching the latest version - - Returns: - A tuple containing the Dawn hash, version, and suffix """ chromium_dawn_hash, chromium_dawn_version, chromium_dawn_suffix = ( @@ -48,7 +46,6 @@ def get_matching_dawn_for_chromium(channel: str = "canary") -> None: print( f"Downloading Dawn matching Chromium version {chromium_dawn_version} ({chromium_dawn_hash})..." ) - fetch_dawn_source(chromium_dawn_hash) version_data = { "chromium_dawn_hash": chromium_dawn_hash, @@ -155,6 +152,25 @@ def fetch_dawn_source(hash: str) -> None: except subprocess.CalledProcessError as e: raise GitOperationError(f"Failed to checkout Dawn repository: {e.stderr}") + # Apply the patch to the Dawn source + print("Applying patch to Dawn source...") + try: + subprocess.run( + [ + "git", + "apply", + "--ignore-space-change", + "--ignore-whitespace", + "../dawn_source.patch", + ], + cwd=str(get_dawn_path()), + check=True, + capture_output=True, + text=True, + ) + except subprocess.CalledProcessError as e: + raise GitOperationError(f"Failed to apply patch to Dawn repository: {e.stderr}") + # Verify Dawn tools directory and fetch dawn dependencies dawn_source_tools = dest_dir / "tools" / "fetch_dawn_dependencies.py" if not dawn_source_tools.exists():