Skip to content

Commit

Permalink
build: Use clone to fetch Chromium Source
Browse files Browse the repository at this point in the history
Signed-off-by: Qian Qian "Cubik"‎ <[email protected]>
  • Loading branch information
Cubik65536 committed Nov 8, 2024
1 parent 5489f53 commit 2ce54f6
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 12 deletions.
8 changes: 6 additions & 2 deletions .github/scripts/github_fetch_resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
build/
.DS_Store

.gcs_entries

build/
24 changes: 21 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"
Expand Down
36 changes: 30 additions & 6 deletions retrieve_and_unpack_resource.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit 2ce54f6

Please sign in to comment.