diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 924348a..8132d6c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,4 +76,17 @@ jobs: steps: - uses: actions/checkout@v3 - name: REUSE Compliance Check - uses: fsfe/reuse-action@v1 \ No newline at end of file + uses: fsfe/reuse-action@v1 + + # Test to ensure we don't accidentally break the Chromium build. + chromium: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Install WSI dependencies + run: sudo apt-get -qq update && sudo apt-get install -y libwayland-dev xorg-dev + - name: Test chromium build + run: python scripts/gn/gn.py diff --git a/.gitignore b/.gitignore index 400987e..d61e226 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,17 @@ __pycache__ build .vscode/ **/.*.swp -external \ No newline at end of file +external + +# Chromium build artifacts +.cipd/ +.gn +.gclient +.gclient_entries +.gclient_previous_sync_commits +out/ +third_party/ +buildtools/ +depot_tools/ +testing/ +tools/ diff --git a/scripts/gn/DEPS b/scripts/gn/DEPS new file mode 100644 index 0000000..9cd23a0 --- /dev/null +++ b/scripts/gn/DEPS @@ -0,0 +1,70 @@ +# Copyright 2023 The Khronos Group Inc. +# Copyright 2023 Valve Corporation +# Copyright 2023 LunarG, Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +# This file is subset of DEPS file from https://chromium.googlesource.com/angle/angle + +gclient_gn_args_file = 'build/config/gclient_args.gni' + +vars = { + 'chromium_git': 'https://chromium.googlesource.com', + 'ninja_version': 'version:2@1.11.1.chromium.6', +} + +deps = { + + 'build': { + 'url': '{chromium_git}/chromium/src/build.git@1015724d82945f9ef7e51c6f804034ccf5f79951', + }, + + 'buildtools': { + 'url': '{chromium_git}/chromium/src/buildtools.git@3c7e3f1b8b1e4c0b6ec693430379cea682de78d6', + }, + + 'buildtools/linux64': { + 'packages': [ + { + 'package': 'gn/gn/linux-${{arch}}', + 'version': 'git_revision:5e19d2fb166fbd4f6f32147fbb2f497091a54ad8', + } + ], + 'dep_type': 'cipd', + 'condition': 'host_os == "linux"', + }, + + 'testing': { + 'url': '{chromium_git}/chromium/src/testing@949b2864b6bd27656753b917c9aa7731dc7a06f6', + }, + + 'tools/clang': { + 'url': '{chromium_git}/chromium/src/tools/clang.git@566877f1ff1a5fa6beaca3ab4b47bd0b92eb614f', + }, + + 'third_party/ninja': { + 'packages': [ + { + 'package': 'infra/3pp/tools/ninja/${{platform}}', + 'version': Var('ninja_version'), + } + ], + 'dep_type': 'cipd', + }, + +} + +hooks = [ + { + 'name': 'sysroot_x64', + 'pattern': '.', + 'condition': 'checkout_linux and checkout_x64', + 'action': ['python3', 'build/linux/sysroot_scripts/install-sysroot.py', + '--arch=x64'], + }, + { + 'name': 'clang', + 'pattern': '.', + 'action': ['python3', 'tools/clang/scripts/update.py'], + }, +] diff --git a/scripts/gn/gn.py b/scripts/gn/gn.py new file mode 100644 index 0000000..52b20c5 --- /dev/null +++ b/scripts/gn/gn.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +# Copyright 2023 The Khronos Group Inc. +# Copyright 2023 Valve Corporation +# Copyright 2023 LunarG, Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +import os +import subprocess +import sys + +# helper to define paths relative to the repo root +def RepoRelative(path): + return os.path.abspath(os.path.join(os.path.dirname(__file__), '../../', path)) + +def BuildGn(): + if not os.path.exists(RepoRelative("depot_tools")): + print("Cloning Chromium depot_tools\n", flush=True) + clone_cmd = 'git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git depot_tools'.split(" ") + subprocess.call(clone_cmd) + + os.environ['PATH'] = os.environ.get('PATH') + ":" + RepoRelative("depot_tools") + + print("Updating Repo Dependencies and GN Toolchain\n", flush=True) + update_cmd = './scripts/gn/update_deps.sh' + subprocess.call(update_cmd) + + print("Checking Header Dependencies\n", flush=True) + gn_check_cmd = 'gn gen --check out/Debug'.split(" ") + subprocess.call(gn_check_cmd) + + print("Generating Ninja Files\n", flush=True) + gn_gen_cmd = 'gn gen out/Debug'.split(" ") + subprocess.call(gn_gen_cmd) + + print("Running Ninja Build\n", flush=True) + ninja_build_cmd = 'ninja -C out/Debug'.split(" ") + subprocess.call(ninja_build_cmd) + +# +# Module Entrypoint +def main(): + try: + BuildGn() + + except subprocess.CalledProcessError as proc_error: + print('Command "%s" failed with return code %s' % (' '.join(proc_error.cmd), proc_error.returncode)) + sys.exit(proc_error.returncode) + except Exception as unknown_error: + print('An unkown error occured: %s', unknown_error) + sys.exit(1) + + sys.exit(0) + +if __name__ == '__main__': + main() diff --git a/scripts/gn/secondary/build_overrides/build.gni b/scripts/gn/secondary/build_overrides/build.gni new file mode 100644 index 0000000..db2aba3 --- /dev/null +++ b/scripts/gn/secondary/build_overrides/build.gni @@ -0,0 +1,10 @@ +# Copyright 2023 The Khronos Group Inc. +# Copyright 2023 Valve Corporation +# Copyright 2023 LunarG, Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +build_with_chromium = false +ignore_elf32_limitations = true +linux_use_bundled_binutils_override = false +use_system_xcode = true diff --git a/scripts/gn/secondary/build_overrides/vulkan_headers.gni b/scripts/gn/secondary/build_overrides/vulkan_headers.gni new file mode 100644 index 0000000..85ae9f5 --- /dev/null +++ b/scripts/gn/secondary/build_overrides/vulkan_headers.gni @@ -0,0 +1,7 @@ +# Copyright 2023 The Khronos Group Inc. +# Copyright 2023 Valve Corporation +# Copyright 2023 LunarG, Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +vulkan_use_x11 = true diff --git a/scripts/gn/secondary/build_overrides/vulkan_utility_libraries.gni b/scripts/gn/secondary/build_overrides/vulkan_utility_libraries.gni new file mode 100644 index 0000000..5a4b788 --- /dev/null +++ b/scripts/gn/secondary/build_overrides/vulkan_utility_libraries.gni @@ -0,0 +1,7 @@ +# Copyright 2023 The Khronos Group Inc. +# Copyright 2023 Valve Corporation +# Copyright 2023 LunarG, Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +vulkan_headers_dir = "//external/Vulkan-Headers" diff --git a/scripts/gn/update_deps.sh b/scripts/gn/update_deps.sh new file mode 100755 index 0000000..9b67989 --- /dev/null +++ b/scripts/gn/update_deps.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# Copyright 2023 The Khronos Group Inc. +# Copyright 2023 Valve Corporation +# Copyright 2023 LunarG, Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +# Execute at repo root +cd "$(dirname $0)/../../" + +# Use update_deps.py to update source dependencies from /scripts/known_good.json +scripts/update_deps.py --dir="external" --no-build + +cat << EOF > .gn +buildconfig = "//build/config/BUILDCONFIG.gn" +secondary_source = "//scripts/gn/secondary/" + +default_args = { + clang_use_chrome_plugins = false + use_custom_libcxx = false +} +EOF + +# Use gclient to update toolchain dependencies from /scripts/gn/DEPS (from chromium) +cat << EOF > .gclient +solutions = [ + { "name" : ".", + "url" : "https://github.com/KhronosGroup/Vulkan-Utility-Libraries", + "deps_file" : "scripts/gn/DEPS", + "managed" : False, + "custom_deps" : { + }, + "custom_vars": {}, + }, +] +EOF +gclient sync + diff --git a/scripts/update_deps.py b/scripts/update_deps.py old mode 100644 new mode 100755