Skip to content

Commit

Permalink
Add process to compile Bindgen
Browse files Browse the repository at this point in the history
Signed-off-by: Qian Qian "Cubik"‎ <cubik65536@cubik65536.top>
  • Loading branch information
Cubik65536 committed Jul 27, 2024
1 parent 59ca434 commit 63bcc1c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions patches/series
Original file line number Diff line number Diff line change
@@ -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
Expand Down
47 changes: 47 additions & 0 deletions patches/ungoogled-chromium/macos/build-bindgen.patch
Original file line number Diff line number Diff line change
@@ -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'))

0 comments on commit 63bcc1c

Please sign in to comment.