From 2ce54f6903dcec1666a823813014bfd0f320d24e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qian=20Qian=20=22Cubik=22=E2=80=8E?= Date: Thu, 7 Nov 2024 21:26:09 -0500 Subject: [PATCH] build: Use clone to fetch Chromium Source MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Qian Qian "Cubik"‎ --- .github/scripts/github_fetch_resources.sh | 8 +++-- .gitignore | 5 +++- build.sh | 24 +++++++++++++-- retrieve_and_unpack_resource.sh | 36 +++++++++++++++++++---- 4 files changed, 61 insertions(+), 12 deletions(-) diff --git a/.github/scripts/github_fetch_resources.sh b/.github/scripts/github_fetch_resources.sh index a4727900..bd192bbb 100755 --- a/.github/scripts/github_fetch_resources.sh +++ b/.github/scripts/github_fetch_resources.sh @@ -12,15 +12,19 @@ sudo df -h sudo du -hs "$_src_dir" rm -rf "$_src_dir/out" || true -mkdir -p "$_src_dir/out/Default" mkdir -p "$_download_cache" "$_root_dir/retrieve_and_unpack_resource.sh" -g -"$_main_repo/utils/prune_binaries.py" "$_src_dir" "$_main_repo/pruning.list" --keep-contingent-paths +mkdir -p "$_src_dir/out/Default" + +"$_main_repo/utils/prune_binaries.py" "$_src_dir" "$_main_repo/pruning.list" "$_main_repo/utils/patches.py" apply "$_src_dir" "$_main_repo/patches" "$_root_dir/patches" "$_main_repo/utils/domain_substitution.py" apply -r "$_main_repo/domain_regex.list" -f "$_main_repo/domain_substitution.list" "$_src_dir" +mkdir -p "$_src_dir/third_party/llvm-build/Release+Asserts" +mkdir -p "$_src_dir/third_party/rust-toolchain/bin" + "$_root_dir/retrieve_and_unpack_resource.sh" -p rm -rvf "$_download_cache" diff --git a/.gitignore b/.gitignore index 880ac593..449e519f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ -build/ .DS_Store + +.gcs_entries + +build/ diff --git a/build.sh b/build.sh index 6c56e85b..af13b743 100755 --- a/build.sh +++ b/build.sh @@ -9,6 +9,16 @@ _download_cache="$_root_dir/build/download_cache" _src_dir="$_root_dir/build/src" _main_repo="$_root_dir/ungoogled-chromium" +# Clone to get the Chromium Source +clone=true +while getopts 'd' OPTION; do + case "$OPTION" in + d) + clone=false + ;; + esac +done + # For packaging _chromium_version=$(cat "$_root_dir"/ungoogled-chromium/chromium_version.txt) _ungoogled_revision=$(cat "$_root_dir"/ungoogled-chromium/revision.txt) @@ -18,16 +28,24 @@ _package_revision=$(cat "$_root_dir"/revision.txt) # export PATH="$PATH:$_src_dir/third_party/llvm-build/Release+Asserts/bin" rm -rf "$_src_dir/out" || true -mkdir -p "$_src_dir/out/Default" mkdir -p "$_download_cache" -"$_root_dir/retrieve_and_unpack_resource.sh" -g +if $clone; then + "$_root_dir/retrieve_and_unpack_resource.sh" -g +else + "$_root_dir/retrieve_and_unpack_resource.sh" -d -g +fi -"$_main_repo/utils/prune_binaries.py" "$_src_dir" "$_main_repo/pruning.list" --keep-contingent-paths +mkdir -p "$_src_dir/out/Default" + +"$_main_repo/utils/prune_binaries.py" "$_src_dir" "$_main_repo/pruning.list" "$_main_repo/utils/patches.py" apply "$_src_dir" "$_main_repo/patches" "$_root_dir/patches" "$_main_repo/utils/domain_substitution.py" apply -r "$_main_repo/domain_regex.list" -f "$_main_repo/domain_substitution.list" "$_src_dir" cat "$_main_repo/flags.gn" "$_root_dir/flags.macos.gn" > "$_src_dir/out/Default/args.gn" +mkdir -p "$_src_dir/third_party/llvm-build/Release+Asserts" +mkdir -p "$_src_dir/third_party/rust-toolchain/bin" + "$_root_dir/retrieve_and_unpack_resource.sh" -p cd "$_src_dir" diff --git a/retrieve_and_unpack_resource.sh b/retrieve_and_unpack_resource.sh index afa46a32..809de66b 100755 --- a/retrieve_and_unpack_resource.sh +++ b/retrieve_and_unpack_resource.sh @@ -9,16 +9,36 @@ _download_cache="$_root_dir/build/download_cache" _src_dir="$_root_dir/build/src" _main_repo="$_root_dir/ungoogled-chromium" -while getopts 'gp' OPTION; do +# Clone to get the Chromium Source +clone=true + +while getopts 'dgp' OPTION; do case "$OPTION" in + d) + clone=false + ;; g) + # Retrieve and unpack Chromium Source + if $clone; then + if [ "$(uname -m)" = "arm64" ]; then + # For arm64 (Apple Silicon) + "$_main_repo/utils/clone.py" -p mac-arm -o "$_src_dir" + else + # For amd64 (Intel) + "$_main_repo/utils/clone.py" -p mac -o "$_src_dir" + fi + else + "$_main_repo/utils/downloads.py" retrieve -i "$_main_repo/downloads.ini" -c "$_download_cache" + "$_main_repo/utils/downloads.py" unpack -i "$_main_repo/downloads.ini" -c "$_download_cache" "$_src_dir" + fi + # Retrieve and unpack general resources - "$_main_repo/utils/downloads.py" retrieve -i "$_main_repo/downloads.ini" "$_root_dir/downloads.ini" -c "$_download_cache" - "$_main_repo/utils/downloads.py" unpack -i "$_main_repo/downloads.ini" "$_root_dir/downloads.ini" -c "$_download_cache" "$_src_dir" + "$_main_repo/utils/downloads.py" retrieve -i "$_root_dir/downloads.ini" -c "$_download_cache" + "$_main_repo/utils/downloads.py" unpack -i "$_root_dir/downloads.ini" -c "$_download_cache" "$_src_dir" ;; p) rm -rf "$_src_dir/third_party/llvm-build/Release+Asserts/" - rm -rf "$_src_dir/third_party/rust-toolchain/bin" + rm -rf "$_src_dir/third_party/rust-toolchain/bin/" # Retrieve and unpack platform-specific resources if [ "$(uname -m)" = "arm64" ]; then @@ -49,7 +69,8 @@ while getopts 'gp' OPTION; do echo "rustc 1.83.0-nightly (d6c8169c1 2024-09-03)" > "$_rust_flag_file" - mkdir $_rust_bin_dir + mkdir -p "$_rust_bin_dir" + mkdir -p "$_rust_dir/lib" ln -s "$_rust_dir/rustc/bin/rustc" "$_rust_bin_dir/rustc" ln -s "$_rust_dir/cargo/bin/cargo" "$_rust_bin_dir/cargo" ln -s "$_rust_lib_dir" "$_rustc_lib_dir" @@ -60,7 +81,10 @@ while getopts 'gp' OPTION; do ln -s "$_llvm_bin_dir/llvm-install-name-tool" "$_llvm_bin_dir/install_name_tool" ;; ?) - echo "Usage: $0 [-g] [-p]" + echo "Usage: $0 [-d] [-g] [-p]" + echo " -d: Use download instead of git clone to get Chromium Source" + echo " -g: Retrieve and unpack Chromium Source and general resources" + echo " -p: Retrieve and unpack platform-specific resources" exit 1 ;; esac