From 63bcc1ca6429b4a76f86431ac9c580ea7eaca65c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qian=20Qian=20=22Cubik=22=E2=80=8E?= Date: Mon, 22 Jul 2024 22:37:11 -0400 Subject: [PATCH] Add process to compile Bindgen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Qian Qian "Cubik"‎ --- build.sh | 2 + patches/series | 1 + .../macos/build-bindgen.patch | 47 +++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 patches/ungoogled-chromium/macos/build-bindgen.patch diff --git a/build.sh b/build.sh index 66ccd94..61968fc 100755 --- a/build.sh +++ b/build.sh @@ -33,6 +33,8 @@ cat "$_main_repo/flags.gn" "$_root_dir/flags.macos.gn" > "$_src_dir/out/Default/ cd "$_src_dir" ./tools/gn/bootstrap/bootstrap.py -o out/Default/gn --skip-generate-buildfiles +./tools/rust/build_bindgen.py + ./out/Default/gn gen out/Default --fail-on-unused-args ninja -C out/Default chrome chromedriver diff --git a/patches/series b/patches/series index 8e82561..08e6488 100644 --- a/patches/series +++ b/patches/series @@ -1,3 +1,4 @@ +ungoogled-chromium/macos/build-bindgen.patch ungoogled-chromium/macos/disable-clang-version-check.patch ungoogled-chromium/macos/disable-crashpad-handler.patch ungoogled-chromium/macos/disable-symbol-order-verification.patch diff --git a/patches/ungoogled-chromium/macos/build-bindgen.patch b/patches/ungoogled-chromium/macos/build-bindgen.patch new file mode 100644 index 0000000..5ea1d24 --- /dev/null +++ b/patches/ungoogled-chromium/macos/build-bindgen.patch @@ -0,0 +1,47 @@ +--- a/tools/rust/build_bindgen.py ++++ b/tools/rust/build_bindgen.py +@@ -28,8 +28,7 @@ from update import (RmTree) + + # The git hash to use. + BINDGEN_GIT_VERSION = 'f93d5dfa6d5d7409bea584f3eab38e1fc52b8360' +-BINDGEN_GIT_REPO = ('https://chromium.googlesource.com/external/' + +- 'github.com/rust-lang/rust-bindgen') ++BINDGEN_GIT_REPO = ('https://github.com/rust-lang/rust-bindgen') + + BINDGEN_SRC_DIR = os.path.join(THIRD_PARTY_DIR, 'rust-toolchain-intermediate', + 'bindgen-src') +@@ -102,15 +101,8 @@ def RunCargo(cargo_args): + f'the build_rust.py script builds rustc that is needed here.') + sys.exit(1) + +- clang_bins_dir = os.path.join(RUST_HOST_LLVM_INSTALL_DIR, 'bin') +- llvm_dir = RUST_HOST_LLVM_INSTALL_DIR +- +- if not os.path.exists(os.path.join(llvm_dir, 'bin', f'llvm-config{EXE}')): +- print(f'Missing llvm-config in {llvm_dir}. This ' +- f'script expects to be run after build_rust.py is run as ' +- f'the build_rust.py script produces the LLVM libraries that ' +- f'are needed here.') +- sys.exit(1) ++ clang_bins_dir = os.path.join(THIRD_PARTY_DIR, 'llvm-build', 'Release+Asserts', 'bin') ++ llvm_dir = os.path.join(THIRD_PARTY_DIR, 'llvm-build', 'Release+Asserts') + + env = collections.defaultdict(str, os.environ) + # Cargo normally stores files in $HOME. Override this. +@@ -120,7 +112,6 @@ def RunCargo(cargo_args): + env['RUSTC'] = rustc_bin + + # Use the LLVM libs and clang compiler from the rustc build. +- env['LLVM_CONFIG_PATH'] = os.path.join(llvm_dir, 'bin', 'llvm-config') + if sys.platform == 'win32': + env['LIBCLANG_PATH'] = os.path.join(llvm_dir, 'bin') + else: +@@ -207,7 +198,7 @@ def main(): + install_dir = os.path.join(RUST_TOOLCHAIN_OUT_DIR) + print(f'Installing bindgen to {install_dir} ...') + +- llvm_dir = RUST_HOST_LLVM_INSTALL_DIR ++ llvm_dir = os.path.join(THIRD_PARTY_DIR, 'llvm-build', 'Release+Asserts') + shutil.copy( + os.path.join(build_dir, RustTargetTriple(), 'release', + f'bindgen{EXE}'), os.path.join(install_dir, 'bin'))