2021-10-26 07:18:13 -03:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-04-13 07:36:05 -04:00
|
|
|
# Copyright (c) 2023 Alex313031.
|
2022-04-11 11:47:10 -04:00
|
|
|
|
2022-04-09 04:11:10 -04:00
|
|
|
YEL='\033[1;33m' # Yellow
|
2022-08-02 18:28:38 -04:00
|
|
|
CYA='\033[1;96m' # Cyan
|
2022-06-06 19:32:22 -04:00
|
|
|
RED='\033[1;31m' # Red
|
|
|
|
GRE='\033[1;32m' # Green
|
2022-08-03 07:15:35 -04:00
|
|
|
c0='\033[0m' # Reset Text
|
|
|
|
bold='\033[1m' # Bold Text
|
|
|
|
underline='\033[4m' # Underline Text
|
2022-06-06 19:32:22 -04:00
|
|
|
|
|
|
|
# Error handling
|
|
|
|
yell() { echo "$0: $*" >&2; }
|
|
|
|
die() { yell "$*"; exit 111; }
|
|
|
|
try() { "$@" || die "${RED}Failed $*"; }
|
2022-04-09 04:11:10 -04:00
|
|
|
|
2022-06-25 12:38:59 -04:00
|
|
|
# --help
|
|
|
|
displayHelp () {
|
|
|
|
printf "\n" &&
|
|
|
|
printf "${bold}${GRE}Script to copy Thorium source files over the Chromium source tree.${c0}\n" &&
|
2022-07-30 23:12:58 -04:00
|
|
|
printf "${bold}${YEL}Use the --mac flag for MacOS builds.${c0}\n" &&
|
2022-08-07 18:10:20 -04:00
|
|
|
printf "${bold}${YEL}Use the --raspi flag for Raspberry Pi builds.${c0}\n" &&
|
2022-09-04 11:46:19 -04:00
|
|
|
printf "${bold}${YEL}Use the --woa flag for Windows on ARM builds.${c0}\n" &&
|
2022-10-15 01:39:51 -03:00
|
|
|
printf "${bold}${YEL}Use the --avx2 flag for AVX2 Builds.${c0}\n" &&
|
|
|
|
printf "${bold}${YEL}Use the --sse3 flag for SSE3 Builds.${c0}\n" &&
|
2023-04-23 05:14:22 -04:00
|
|
|
printf "${bold}${YEL}Use the --sse2 flag for 32 bit SSE2 Builds.${c0}\n" &&
|
2023-03-07 11:04:01 -03:00
|
|
|
printf "${bold}${YEL}Use the --android flag for Android Builds.${c0}\n" &&
|
2022-10-15 01:39:51 -03:00
|
|
|
printf "${bold}${YEL}IMPORTANT: For Polly builds, first run build_polly.sh in Thorium/infra, then use the setup_polly.sh${c0}\n" &&
|
|
|
|
printf "${bold}${YEL}script in Thorium/other/Polly. Both of these actions should be taken AFTER running this script!${c0}\n" &&
|
2022-06-25 12:38:59 -04:00
|
|
|
printf "\n"
|
|
|
|
}
|
|
|
|
case $1 in
|
|
|
|
--help) displayHelp; exit 0;;
|
|
|
|
esac
|
|
|
|
|
2023-06-23 00:55:43 -04:00
|
|
|
# chromium/src dir env variable
|
|
|
|
if [ -z "${CR_DIR}" ]; then
|
2023-06-23 01:29:21 -04:00
|
|
|
CR_SRC_DIR="$HOME/chromium/src"
|
2023-06-23 00:55:43 -04:00
|
|
|
export CR_SRC_DIR
|
|
|
|
else
|
|
|
|
CR_SRC_DIR="${CR_DIR}"
|
|
|
|
export CR_SRC_DIR
|
|
|
|
fi
|
|
|
|
|
2022-04-09 04:11:10 -04:00
|
|
|
printf "\n" &&
|
|
|
|
printf "${YEL}Creating build output directory...\n" &&
|
|
|
|
tput sgr0 &&
|
|
|
|
|
2023-06-23 00:55:43 -04:00
|
|
|
mkdir -v -p ${CR_SRC_DIR}/out/thorium/ &&
|
2022-04-09 04:11:10 -04:00
|
|
|
printf "\n" &&
|
|
|
|
|
2022-08-03 06:56:43 -04:00
|
|
|
printf "\n" &&
|
2022-05-18 17:25:10 -04:00
|
|
|
printf "${YEL}Copying Thorium source files over the Chromium tree...\n" &&
|
2022-04-09 04:11:10 -04:00
|
|
|
tput sgr0 &&
|
2021-10-28 13:53:43 -03:00
|
|
|
|
2023-03-01 01:13:31 -03:00
|
|
|
# Copy libjxl src
|
2023-03-02 10:16:07 -03:00
|
|
|
cd ~/thorium &&
|
2023-06-23 00:55:43 -04:00
|
|
|
cp -r -v thorium-libjxl/src/. ${CR_SRC_DIR}/ &&
|
2023-03-01 01:13:31 -03:00
|
|
|
|
|
|
|
# Copy Thorium sources
|
2023-06-23 00:55:43 -04:00
|
|
|
cp -r -v src/BUILD.gn ${CR_SRC_DIR}/ &&
|
|
|
|
cp -r -v src/ash/. ${CR_SRC_DIR}/ash/ &&
|
|
|
|
cp -r -v src/build/. ${CR_SRC_DIR}/build/ &&
|
|
|
|
cp -r -v src/chrome/. ${CR_SRC_DIR}/chrome/ &&
|
|
|
|
cp -r -v src/chromeos/. ${CR_SRC_DIR}/chromeos/ &&
|
|
|
|
cp -r -v src/components/. ${CR_SRC_DIR}/components/ &&
|
|
|
|
cp -r -v src/extensions/. ${CR_SRC_DIR}/extensions/ &&
|
|
|
|
cp -r -v src/content/. ${CR_SRC_DIR}/content/ &&
|
|
|
|
cp -r -v src/media/. ${CR_SRC_DIR}/media/ &&
|
|
|
|
cp -r -v src/net/. ${CR_SRC_DIR}/net/ &&
|
|
|
|
cp -r -v src/sandbox/. ${CR_SRC_DIR}/sandbox/ &&
|
|
|
|
cp -r -v src/services/. ${CR_SRC_DIR}/services/ &&
|
|
|
|
cp -r -v src/third_party/. ${CR_SRC_DIR}/third_party/ &&
|
|
|
|
cp -r -v src/tools/. ${CR_SRC_DIR}/tools/ &&
|
|
|
|
cp -r -v src/ui/. ${CR_SRC_DIR}/ui/ &&
|
|
|
|
cp -r -v src/v8/. ${CR_SRC_DIR}/v8/ &&
|
|
|
|
cp -r -v thorium_shell/. ${CR_SRC_DIR}/out/thorium/ &&
|
2023-06-27 17:19:49 -04:00
|
|
|
cp -r -v pak_src/binaries/pak ${CR_SRC_DIR}/out/thorium/ &&
|
|
|
|
cp -r -v pak_src/binaries/pak-win/. ${CR_SRC_DIR}/out/thorium/ &&
|
2021-10-26 07:18:13 -03:00
|
|
|
|
2023-01-25 10:01:09 -03:00
|
|
|
# Add default_apps dir for Google Docs Offline extension.
|
2023-06-23 00:55:43 -04:00
|
|
|
mkdir -v -p ${CR_SRC_DIR}/out/thorium/default_apps &&
|
|
|
|
cp -r -v infra/default_apps/. ${CR_SRC_DIR}/out/thorium/default_apps/ &&
|
2023-01-25 10:01:09 -03:00
|
|
|
|
2023-04-28 19:17:47 -04:00
|
|
|
# Add initial preferences file to open Thorium welcome page on first run.
|
2023-06-23 00:55:43 -04:00
|
|
|
cp -v infra/initial_preferences ${CR_SRC_DIR}/out/thorium/ &&
|
2023-04-28 19:17:47 -04:00
|
|
|
|
2022-08-03 06:56:43 -04:00
|
|
|
echo " # Workaround for DevTools" &&
|
2023-06-23 00:55:43 -04:00
|
|
|
mkdir -v -p ${CR_SRC_DIR}/out/thorium/gen/third_party/devtools-frontend/src/front_end/Images/ &&
|
|
|
|
cp -r -v src/third_party/devtools-frontend/src/front_end/Images/src/chromeSelectDark.svg ${CR_SRC_DIR}/out/thorium/gen/third_party/devtools-frontend/src/front_end/Images/ &&
|
2022-07-06 23:45:32 -04:00
|
|
|
|
2022-07-30 23:12:58 -04:00
|
|
|
# MacOS Widevine Workaround
|
|
|
|
copyMacOS () {
|
|
|
|
printf "\n" &&
|
2022-08-25 00:52:06 -04:00
|
|
|
printf "${YEL}Copying files for MacOS...${c0}\n" &&
|
2023-06-23 00:55:43 -04:00
|
|
|
cp -r -v other/Mac/cdm_registration.cc ${CR_SRC_DIR}/chrome/common/media/ &&
|
|
|
|
cp -r -v arm/mac_arm.gni ${CR_SRC_DIR}/build/config/arm.gni &&
|
2022-07-30 23:12:58 -04:00
|
|
|
printf "\n"
|
|
|
|
}
|
|
|
|
case $1 in
|
|
|
|
--mac) copyMacOS;
|
|
|
|
esac
|
|
|
|
|
2022-08-07 18:10:20 -04:00
|
|
|
# Raspberry Pi Source Files
|
|
|
|
copyRaspi () {
|
|
|
|
printf "\n" &&
|
|
|
|
printf "${YEL}Copying Raspberry Pi build files...${c0}\n" &&
|
2023-06-23 00:55:43 -04:00
|
|
|
cp -r -v arm/raspi/* ${CR_SRC_DIR}/ &&
|
2023-06-27 17:19:49 -04:00
|
|
|
rm -v ${CR_SRC_DIR}/out/thorium/pak &&
|
|
|
|
cp -v pak_src/binaries/pak_arm64 ${CR_SRC_DIR}/out/thorium/pak &&
|
2022-08-07 18:10:20 -04:00
|
|
|
printf "\n"
|
|
|
|
}
|
2023-04-13 07:36:05 -04:00
|
|
|
# Display raspi ascii art
|
|
|
|
displayRaspi () {
|
|
|
|
cat logos/raspi_ascii_art.txt
|
|
|
|
}
|
2022-08-07 18:10:20 -04:00
|
|
|
case $1 in
|
2023-04-13 07:36:05 -04:00
|
|
|
--raspi) copyRaspi; displayRaspi;
|
2022-08-07 18:10:20 -04:00
|
|
|
esac
|
|
|
|
|
2023-03-30 16:37:45 -03:00
|
|
|
# Windows on ARM files
|
2022-09-04 11:46:19 -04:00
|
|
|
copyWOA () {
|
|
|
|
printf "\n" &&
|
|
|
|
printf "${YEL}Copying Windows on ARM build files...${c0}\n" &&
|
2023-06-23 00:55:43 -04:00
|
|
|
cp -r -v arm/build/config/* ${CR_SRC_DIR}/build/config/ &&
|
2022-09-04 11:46:19 -04:00
|
|
|
printf "\n"
|
|
|
|
}
|
|
|
|
case $1 in
|
|
|
|
--woa) copyWOA;
|
|
|
|
esac
|
|
|
|
|
2022-10-15 01:39:51 -03:00
|
|
|
# Copy AVX2 files
|
|
|
|
copyAVX2 () {
|
|
|
|
printf "\n" &&
|
|
|
|
printf "${YEL}Copying AVX2 build files...${c0}\n" &&
|
2023-06-23 00:55:43 -04:00
|
|
|
cp -r -v other/AVX2/build/config/* ${CR_SRC_DIR}/build/config/ &&
|
|
|
|
cp -r -v other/AVX2/v8/* ${CR_SRC_DIR}/v8/ &&
|
|
|
|
cp -r -v other/AVX2/third_party/* ${CR_SRC_DIR}/third_party/ &&
|
2022-10-15 01:39:51 -03:00
|
|
|
printf "\n"
|
|
|
|
}
|
|
|
|
case $1 in
|
|
|
|
--avx2) copyAVX2;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Copy SSE3 files
|
|
|
|
copySSE3 () {
|
|
|
|
printf "\n" &&
|
|
|
|
printf "${YEL}Copying SSE3 build files...${c0}\n" &&
|
2023-06-23 00:55:43 -04:00
|
|
|
cp -r -v other/SSE3/build/config/* ${CR_SRC_DIR}/build/config/ &&
|
|
|
|
cp -r -v other/SSE3/v8/* ${CR_SRC_DIR}/v8/ &&
|
|
|
|
cp -r -v other/SSE3/third_party/* ${CR_SRC_DIR}/third_party/ &&
|
2022-10-15 01:39:51 -03:00
|
|
|
printf "\n"
|
|
|
|
}
|
|
|
|
case $1 in
|
|
|
|
--sse3) copySSE3;
|
|
|
|
esac
|
|
|
|
|
2023-04-23 05:14:22 -04:00
|
|
|
# Copy SSE2 files
|
|
|
|
copySSE2 () {
|
|
|
|
printf "\n" &&
|
|
|
|
printf "${YEL}Copying SSE2 (32-bit) build files...${c0}\n" &&
|
2023-06-23 00:55:43 -04:00
|
|
|
cp -r -v other/SSE2/build/config/* ${CR_SRC_DIR}/build/config/ &&
|
|
|
|
cp -r -v other/SSE2/third_party/* ${CR_SRC_DIR}/third_party/ &&
|
2023-04-23 05:14:22 -04:00
|
|
|
printf "\n"
|
|
|
|
}
|
|
|
|
case $1 in
|
|
|
|
--sse2) copySSE2;
|
|
|
|
esac
|
|
|
|
|
2023-03-07 11:04:01 -03:00
|
|
|
# Copy Android files
|
|
|
|
copyAndroid () {
|
|
|
|
printf "\n" &&
|
|
|
|
printf "${YEL}Copying Android (ARM64 and ARM32) build files...${c0}\n" &&
|
2023-06-23 00:55:43 -04:00
|
|
|
cp -r -v arm/build/config/* ${CR_SRC_DIR}/build/config/ &&
|
|
|
|
cp -r -v arm/android/* ${CR_SRC_DIR}/ &&
|
|
|
|
cp -r -v arm/android/third_party/* ${CR_SRC_DIR}/third_party/ &&
|
2023-06-25 15:17:29 -04:00
|
|
|
rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_base/drawable-v26/ic_launcher.xml &&
|
|
|
|
rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_base/drawable-v26/ic_launcher_round.xml &&
|
|
|
|
rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-mdpi/layered_app_icon_background.png &&
|
|
|
|
rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-mdpi/layered_app_icon.png &&
|
|
|
|
rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-xhdpi/layered_app_icon_background.png &&
|
|
|
|
rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-xhdpi/layered_app_icon.png &&
|
|
|
|
rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-xxxhdpi/layered_app_icon_background.png &&
|
|
|
|
rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-xxxhdpi/layered_app_icon.png &&
|
|
|
|
rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-nodpi/layered_app_icon_foreground.xml &&
|
|
|
|
rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-hdpi/layered_app_icon_background.png &&
|
|
|
|
rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-hdpi/layered_app_icon.png &&
|
|
|
|
rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-xxhdpi/layered_app_icon_background.png &&
|
|
|
|
rm -v -r -f ${CR_SRC_DIR}/chrome/android/java/res_chromium_base/mipmap-xxhdpi/layered_app_icon.png &&
|
2023-03-07 11:04:01 -03:00
|
|
|
printf "\n"
|
|
|
|
}
|
|
|
|
case $1 in
|
|
|
|
--android) copyAndroid;
|
|
|
|
esac
|
|
|
|
|
2022-06-06 19:32:22 -04:00
|
|
|
printf "${GRE}Done!\n" &&
|
2022-04-09 04:11:10 -04:00
|
|
|
printf "\n" &&
|
|
|
|
|
2022-10-15 01:54:20 -03:00
|
|
|
printf "${YEL}Exporting variables and setting handy aliases...\n" &&
|
2022-04-20 17:07:06 -04:00
|
|
|
|
|
|
|
export NINJA_SUMMARIZE_BUILD=1 &&
|
2023-06-27 21:50:47 -04:00
|
|
|
export NINJA_STATUS="[%r processes, %f/%t @ %o/s | %e sec. ] " &&
|
2022-04-20 17:07:06 -04:00
|
|
|
|
2022-04-22 15:37:47 -04:00
|
|
|
export EDITOR=nano &&
|
|
|
|
|
|
|
|
export VISUAL=nano &&
|
|
|
|
|
2022-05-09 04:06:08 -04:00
|
|
|
alias origin='git checkout -f origin/main' &&
|
|
|
|
|
2022-08-03 06:56:43 -04:00
|
|
|
alias gfetch='git fetch --tags' &&
|
|
|
|
|
2022-05-09 04:06:08 -04:00
|
|
|
alias rebase='git rebase-update' &&
|
|
|
|
|
2022-08-03 06:56:43 -04:00
|
|
|
alias gsync='gclient sync --with_branch_heads --with_tags -f -R -D' &&
|
|
|
|
|
2022-06-06 19:32:22 -04:00
|
|
|
alias args='gn args out/thorium' &&
|
2022-05-09 04:06:08 -04:00
|
|
|
|
|
|
|
alias gnls='gn ls out/thorium' &&
|
|
|
|
|
2022-08-03 06:56:43 -04:00
|
|
|
alias show='git show-ref' &&
|
2022-04-20 17:07:06 -04:00
|
|
|
|
2022-05-09 04:06:08 -04:00
|
|
|
alias runhooks='gclient runhooks' &&
|
|
|
|
|
2022-04-20 17:07:06 -04:00
|
|
|
alias pgo='python3 tools/update_pgo_profiles.py --target=linux update --gs-url-base=chromium-optimization-profiles/pgo_profiles' &&
|
|
|
|
|
|
|
|
alias pgow='python3 tools/update_pgo_profiles.py --target=win64 update --gs-url-base=chromium-optimization-profiles/pgo_profiles' &&
|
|
|
|
|
|
|
|
alias pgom='python3 tools/update_pgo_profiles.py --target=mac update --gs-url-base=chromium-optimization-profiles/pgo_profiles' &&
|
2023-06-13 08:13:45 -04:00
|
|
|
|
|
|
|
alias pgomac-arm='python3 tools/update_pgo_profiles.py --target=mac-arm update --gs-url-base=chromium-optimization-profiles/pgo_profiles' &&
|
2022-04-09 04:11:10 -04:00
|
|
|
printf "\n" &&
|
2022-08-03 06:56:43 -04:00
|
|
|
tput sgr0 &&
|
|
|
|
|
|
|
|
printf "export ${CYA}NINJA_SUMMARIZE_BUILD=1${c0}\n" &&
|
|
|
|
|
|
|
|
printf "export ${CYA}EDITOR=nano${c0}\n" &&
|
2022-04-09 04:11:10 -04:00
|
|
|
|
2022-08-03 06:56:43 -04:00
|
|
|
printf "export ${CYA}VISUAL=nano${c0}\n" &&
|
2022-04-09 04:11:10 -04:00
|
|
|
printf "\n" &&
|
|
|
|
|
2022-08-03 06:56:43 -04:00
|
|
|
printf "alias ${YEL}origin${c0} = ${CYA}git checkout -f origin/main${c0}\n" &&
|
|
|
|
|
|
|
|
printf "alias ${YEL}gfetch${c0} = ${CYA}git fetch --tags${c0}\n" &&
|
|
|
|
|
|
|
|
printf "alias ${YEL}rebase${c0} = ${CYA}git rebase-update${c0}\n" &&
|
|
|
|
|
|
|
|
printf "alias ${YEL}gsync${c0} = ${CYA}gclient sync --with_branch_heads --with_tags -f -R -D${c0}\n" &&
|
|
|
|
|
|
|
|
printf "alias ${YEL}args${c0} = ${CYA}gn args out/thorium${c0}\n" &&
|
|
|
|
|
|
|
|
printf "alias ${YEL}gnls${c0} = ${CYA}gn ls out/thorium${c0}\n" &&
|
|
|
|
|
|
|
|
printf "alias ${YEL}show${c0} = ${CYA}git show-ref${c0}\n" &&
|
|
|
|
|
|
|
|
printf "alias ${YEL}runhooks${c0} = ${CYA}gclient runhooks${c0}\n" &&
|
|
|
|
|
|
|
|
printf "alias ${YEL}pgo${c0} = ${CYA}python3 tools/update_pgo_profiles.py --target=linux update --gs-url-base=chromium-optimization-profiles/pgo_profiles${c0}\n" &&
|
|
|
|
|
|
|
|
printf "alias ${YEL}pgow${c0} = ${CYA}python3 tools/update_pgo_profiles.py --target=win64 update --gs-url-base=chromium-optimization-profiles/pgo_profiles${c0}\n" &&
|
|
|
|
|
|
|
|
printf "alias ${YEL}pgom${c0} = ${CYA}python3 tools/update_pgo_profiles.py --target=mac update --gs-url-base=chromium-optimization-profiles/pgo_profiles${c0}\n" &&
|
|
|
|
|
2023-06-13 08:13:45 -04:00
|
|
|
printf "alias ${YEL}pgomac-arm${c0} = ${CYA}python3 tools/update_pgo_profiles.py --target=mac-arm update --gs-url-base=chromium-optimization-profiles/pgo_profiles${c0}\n" &&
|
|
|
|
|
2022-08-08 07:46:16 -04:00
|
|
|
printf "${CYA}\n" &&
|
2022-04-09 04:11:10 -04:00
|
|
|
|
2022-10-15 06:00:56 -03:00
|
|
|
cat logos/thorium_ascii_art.txt &&
|
2022-08-07 17:37:40 -04:00
|
|
|
|
2022-06-06 19:32:22 -04:00
|
|
|
printf "${GRE}Enjoy Thorium!\n" &&
|
2022-04-09 04:11:10 -04:00
|
|
|
printf "\n" &&
|
2022-08-03 06:56:43 -04:00
|
|
|
tput sgr0
|
2021-10-26 07:18:13 -03:00
|
|
|
|
|
|
|
exit 0
|