Skip to content

Commit

Permalink
build: New Resources Processing Procedure
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 3e475dc commit a3129e5
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 36 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ A `.dmg` should appear in `build/`

```sh
./devutils/update_patches.sh merge
bash
bash
source devutils/set_quilt_vars.sh
```

2. Setup Chromium source

```sh
mkdir -p build/{src,download_cache}
./retrieve_and_unpack_resource.sh
./retrieve_and_unpack_resource.sh -g -p
```

3. Update Rust toolchain (if necessary)
Expand Down
6 changes: 4 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bash

set -eux

Expand All @@ -21,13 +21,15 @@ rm -rf "$_src_dir/out" || true
mkdir -p "$_src_dir/out/Default"
mkdir -p "$_download_cache"

"$_root_dir/retrieve_and_unpack_resource.sh"
"$_root_dir/retrieve_and_unpack_resource.sh" -g

"$_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"

"$_root_dir/retrieve_and_unpack_resource.sh" -p

cd "$_src_dir"

./tools/gn/bootstrap/bootstrap.py -o out/Default/gn --skip-generate-buildfiles
Expand Down
82 changes: 50 additions & 32 deletions retrieve_and_unpack_resource.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bash

set -eux

Expand All @@ -9,43 +9,61 @@ _download_cache="$_root_dir/build/download_cache"
_src_dir="$_root_dir/build/src"
_main_repo="$_root_dir/ungoogled-chromium"

# Retrieve and unpack general resources
while getopts 'gp' OPTION; do
case "$OPTION" in
g)
# 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"
;;
p)
rm -rf "$_src_dir/third_party/llvm-build/Release+Asserts/"
rm -rf "$_src_dir/third_party/rust-toolchain/bin"

"$_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"
# Retrieve and unpack platform-specific resources
if [ "$(uname -m)" = "arm64" ]; then
# For arm64 (Apple Silicon)
"$_main_repo/utils/downloads.py" retrieve -i "$_root_dir/downloads-arm64.ini" -c "$_download_cache"
mkdir -p "$_src_dir/third_party/node/mac_arm64/node-darwin-arm64/"
"$_main_repo/utils/downloads.py" unpack -i "$_root_dir/downloads-arm64.ini" -c "$_download_cache" "$_src_dir"
else
# For x86-64 (Intel)
"$_main_repo/utils/downloads.py" retrieve -i "$_root_dir/downloads-x86-64.ini" -c "$_download_cache"
mkdir -p "$_src_dir/third_party/node/mac_x64/node-darwin-x64/"
"$_main_repo/utils/downloads.py" unpack -i "$_root_dir/downloads-x86-64.ini" -c "$_download_cache" "$_src_dir"
fi

# Retrieve and unpack architecture-specific resources
if [ "$(uname -m)" = "arm64" ]; then
# For arm64 (Apple Silicon)
"$_main_repo/utils/downloads.py" retrieve -i "$_root_dir/downloads-arm64.ini" -c "$_download_cache"
"$_main_repo/utils/downloads.py" unpack -i "$_root_dir/downloads-arm64.ini" -c "$_download_cache" "$_src_dir"
else
# For x86-64 (Intel)
"$_main_repo/utils/downloads.py" retrieve -i "$_root_dir/downloads-x86-64.ini" -c "$_download_cache"
"$_main_repo/utils/downloads.py" unpack -i "$_root_dir/downloads-x86-64.ini" -c "$_download_cache" "$_src_dir"
fi
## Rust Resource
_rust_name="x86_64-apple-darwin"
if [ "$(uname -m)" = "arm64" ]; then
_rust_name="aarch64-apple-darwin"
fi

## Rust Resource
_rust_name="x86_64-apple-darwin"
if [ "$(uname -m)" = "arm64" ]; then
_rust_name="aarch64-apple-darwin"
fi
_rust_dir="$_src_dir/third_party/rust-toolchain"
_rust_bin_dir="$_rust_dir/bin"
_rust_flag_file="$_rust_dir/INSTALLED_VERSION"

_rust_dir="$_src_dir/third_party/rust-toolchain"
_rust_bin_dir="$_rust_dir/bin"
_rust_flag_file="$_rust_dir/INSTALLED_VERSION"
_rust_lib_dir="$_rust_dir/rust-std-$_rust_name/lib/rustlib/$_rust_name/lib"
_rustc_dir="$_rust_dir/rustc"
_rustc_lib_dir="$_rust_dir/rustc/lib/rustlib/$_rust_name/lib"

_rust_lib_dir="$_rust_dir/rust-std-$_rust_name/lib/rustlib/$_rust_name/lib"
_rustc_dir="$_rust_dir/rustc"
_rustc_lib_dir="$_rust_dir/rustc/lib/rustlib/$_rust_name/lib"
echo "rustc 1.80.0-nightly (7d83a4c13 2024-05-06)" > "$_rust_flag_file"

echo "rustc 1.79.0-nightly (ef8b9dcf2 2024-04-24)" > "$_rust_flag_file"
mkdir $_rust_bin_dir
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"

mkdir $_rust_bin_dir
ln -s "$_rust_dir/rustc/bin/rustc" "$_rust_bin_dir/rustc"
ln -s "$_rust_lib_dir" "$_rustc_lib_dir"
_llvm_dir="$_src_dir/third_party/llvm-build/Release+Asserts"
_llvm_bin_dir="$_llvm_dir/bin"

_llvm_dir="$_src_dir/third_party/llvm-build/Release+Asserts"
_llvm_bin_dir="$_llvm_dir/bin"
ln -s "$_llvm_bin_dir/llvm-install-name-tool" "$_llvm_bin_dir/install_name_tool"
;;
?)
echo "Usage: $0 [-g] [-p]"
exit 1
;;
esac
done

ln -s "$_llvm_bin_dir/llvm-install-name-tool" "$_llvm_bin_dir/install_name_tool"
shift "$(($OPTIND -1))"

0 comments on commit a3129e5

Please sign in to comment.