LeOSium_webview/4_build.sh

238 lines
6.8 KiB
Bash
Raw Normal View History

2023-11-18 11:46:19 +01:00
#!/bin/bash
set -e
chromium_version="119.0.6045.172"
chromium_code="6045172"
chromium_rebrand_name="LeOSium"
chromium_rebrand_color="#7B3F00"
chromium_packageid_webview="com.leos.ium_wv"
chromium_packageid_standalone="com.leos.ium"
chromium_packageid_libtrichrome="com.leos.ium_tcl"
clean=0
gsync=0
supported_archs=(arm arm64 x86 x64)
usage() {
echo "Usage:"
echo " build_webview [ options ]"
echo
echo " Options:"
echo " -a <arch> Build specified arch"
echo " -c Clean"
echo " -h Show this message"
echo " -r <release> Specify chromium release"
echo " -s Sync"
echo
echo " Example:"
echo " bash 4_build.sh -r 119.0.6045.172:6045172"
echo
exit 1
}
build() {
build_args=$args' target_cpu="'$1'"'
code=$chromium_code
if [ $1 '==' "arm" ]; then
code+=00
elif [ $1 '==' "arm64" ]; then
code+=50
#build_args+=' arm_control_flow_integrity="standard"'
elif [ $1 '==' "x86" ]; then
code+=10
elif [ $1 '==' "x64" ]; then
code+=60
fi
build_args+=' android_default_version_code="'$code'"'
gn gen "out/$1" --args="$build_args"
ninja -C out/$1 system_webview_apk chrome_public_apk
if [ "$?" -eq 0 ]; then
[ "$1" '==' "x64" ] && android_arch="x86_64" || android_arch=$1
cp out/$1/apks/SystemWebView.apk ../prebuilt/$android_arch/webview.apk
fi
}
while getopts ":a:chr:s" opt; do
case $opt in
a) for arch in ${supported_archs[@]}; do
[ "$OPTARG" '==' "$arch" ] && build_arch="$OPTARG"
done
if [ -z "$build_arch" ]; then
echo "Unsupported ARCH: $OPTARG"
echo "Supported ARCHs: ${supported_archs[@]}"
exit 1
fi
;;
c) clean=1 ;;
h) usage ;;
r) version=(${OPTARG//:/ })
chromium_version=${version[0]}
chromium_code=${version[1]}
;;
s) gsync=1 ;;
:)
echo "Option -$OPTARG requires an argument"
echo
usage
;;
\?)
echo "Invalid option:-$OPTARG"
echo
usage
;;
esac
done
shift $((OPTIND-1))
# Add depot_tools to PATH
if [ ! -d depot_tools ]; then
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
fi
export PATH="$(pwd -P)/depot_tools:$PATH"
if [ ! -d src ]; then
echo "Initial source download"
fetch android
yes | gclient sync -D -R -r $chromium_version
fi
if [ $gsync -eq 1 ]; then
echo "Syncing"
find src -name index.lock -delete
yes | gclient sync -D -R -f -r $chromium_version
fi
cd src
applyPatchReal() {
currentWorkingPatch=$1;
firstLine=$(head -n1 "$currentWorkingPatch");
if [[ "$firstLine" = *"Mon Sep 17 00:00:00 2001"* ]] || [[ "$firstLine" = *"Thu Jan 1 00:00:00 1970"* ]]; then
if git am "$@"; then
git format-patch -1 HEAD --zero-commit --no-signature --output="$currentWorkingPatch";
fi;
else
git apply "$@";
echo "Applying: $currentWorkingPatch";
fi;
}
export -f applyPatchReal;
applyPatch() {
currentWorkingPatch=$1;
if [ -f "$currentWorkingPatch" ]; then
if git apply --check "$@" &> /dev/null; then
applyPatchReal "$@";
else
if git apply --reverse --check "$@" &> /dev/null; then
echo "Already applied: $currentWorkingPatch";
else
if git apply --check "$@" --3way &> /dev/null; then
applyPatchReal "$@" --3way;
echo "Applied: $currentWorkingPatch";
else
echo -e "\e[0;31mERROR: Cannot apply: $currentWorkingPatch\e[0m";
fi;
fi;
fi;
else
echo -e "\e[0;31mERROR: Patch doesn't exist: $currentWorkingPatch\e[0m";
fi;
}
# Build args
args='target_os="android"'
args+=' android_channel="stable"' #Release build
args+=' android_default_version_name="'$chromium_version'"'
args+=' disable_fieldtrial_testing_config=true'
args+=' is_chrome_branded=false'
args+=' is_component_build=false'
args+=' is_official_build=true'
args+=' use_official_google_api_keys=false'
args+=' webview_devui_show_icon=false'
args+=' blink_symbol_level=0' #Release optimizations
args+=' v8_symbol_level=0'
args+=' is_debug=false'
args+=' symbol_level=0'
args+=' dfmify_dev_ui=false' #Don't build as module
args+=' ffmpeg_branding="Chrome"' #Codec support
args+=' proprietary_codecs=true'
args+=' enable_resource_allowlist_generation=false'
args+=' enable_gvr_services=false' #Unncessary
args+=' enable_nacl=false'
args+=' enable_remoting=false'
args+=' enable_arcore=false'
args+=' enable_openxr=false'
args+=' enable_cardboard=false'
args+=' enable_vr=false'
args+=' use_official_google_api_keys=false'
args+=' system_webview_package_name="'$chromium_packageid_webview'"' #Package IDs
args+=' chrome_public_manifest_package="'$chromium_packageid_standalone'"'
args+=' trichrome_library_package="'$chromium_packageid_libtrichrome'"'
args+=' is_cfi=true' #Security
args+=' use_cfi_cast=true'
args+=' use_relative_vtables_abi=false'
args+=' enable_reporting=false' #Privacy
args+=' build_contextual_search=false'
args+=' chrome_pgo_phase=0'
args+=' dcheck_always_on=false'
args+=' debuggable_apks=false'
args+=' enable_av1_decoder=true'
args+=' enable_dav1d_decoder=true'
args+=' enable_hangout_services_extension=false'
args+=' enable_iterator_debugging=false'
args+=' enable_mdns=false'
args+=' enable_mse_mpeg2ts_stream_parser=true'
args+=' enable_platform_dolby_vision=true'
args+=' enable_platform_hevc=true'
args+=' exclude_unwind_tables=false'
args+=' icu_use_data_file=true'
args+=' rtc_build_examples=false'
args+=' safe_browsing_mode=2'
args+=' treat_warnings_as_errors=true'
args+=' use_debug_fission=false'
args+=' is_clang=true'
args+=' use_errorprone_java_compiler=false'
args+=' use_rtti=false'
args+=' use_stable_package_name_for_trichrome=false'
args+=' disable_android_lint=true'
args+=' disable_fieldtrial_testing_config=true'
args+=' enable_av1_decoder=true'
args+=' enable_dav1d_decoder=true'
args+=' enable_gvr_services=false'
args+=' enable_hangout_services_extension=false'
args+=' enable_iterator_debugging=false'
args+=' enable_mdns=false'
args+=' enable_mse_mpeg2ts_stream_parser=true'
args+=' enable_nacl=false'
args+=' enable_platform_dolby_vision=true'
args+=' enable_platform_hevc=true'
args+=' enable_remoting=false'
args+=' enable_reporting=false'
args+=' use_cfi_cast=true'
args+=' use_debug_fission=true'
args+=' use_errorprone_java_compiler=false'
args+=' use_official_google_api_keys=false'
args+=' use_rtti=false'
args+=' enable_arcore=false'
args+=' enable_openxr=false'
args+=' enable_gvr_services=false'
args+=' treat_warnings_as_errors=false'
# Setup environment
[ $clean -eq 1 ] && rm -rf out && echo "Cleaned out"
. build/android/envsetup.sh
# Check target and build
if [ -n "$build_arch" ]; then
build $build_arch
else
echo "Building all"
build arm64
build arm
#build x86
# build x64
fi