Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c53a5ac authored by Nishith  Khanna's avatar Nishith Khanna
Browse files

Drop trichrome build variant

parent 97996874
Loading
Loading
Loading
Loading
+3 −14
Original line number Diff line number Diff line
@@ -13,7 +13,6 @@ chromium_url=https://github.com/chromium/chromium.git
clean=0
gsync=0
history=1
trichrome=0
patchonly=0
arch=""

@@ -28,15 +27,13 @@ usage() {
  echo "    -s Sync source"
  echo "    -h Sync without history"
  echo "    -p Apply patches - Only after synced"
  echo "    -t Build trichrome chromium, webview and library"
  echo
  exit 1
}

build() {
  echo ">> [$(date)] Head commit: $(git show -s --format=%s)"
  apks="TrichromeChrome TrichromeLibrary TrichromeWebView TrichromeChrome6432 \
        TrichromeLibrary6432 TrichromeWebView6432 ChromePublic SystemWebView"
  apks="ChromePublic SystemWebView"
  build_args="$(cat "${root_dir}"/build/browser.gn_args) target_cpu=\"${1}\" "

  apk_arch=${1}
@@ -59,17 +56,10 @@ build() {
  build_args+=' android_keystore_path="'$keystore_path'"'
  build_args+=' android_keystore_name="platform"'
  build_args+=' android_keystore_password="platform"'
  build_args+=' trichrome_certdigest="c8a2e9bccf597c2fb6dc66bee293fc13f2fc47ec77bc6b2b0d52c11f51192ab8"'

  echo ">> [$(date)] Building chromium $chromium_version for $1"
  gn gen "out/$1" --fail-on-unused-args --args="$build_args"
  if [[ $trichrome -eq 0 ]]; then
  build_targets="chrome_public_apk system_webview_apk"
  elif [ $1 '==' "x64" ] || [ $1 '==' "arm64" ]; then
    build_targets="trichrome_webview_64_32_apk trichrome_chrome_64_32_apk trichrome_library_64_32_apk"
  else
    build_targets="trichrome_webview_apk trichrome_chrome_apk trichrome_library_apk"
  fi

  ninja -C out/$1 $build_targets
  mkdir -p "${root_dir}/apks/${apk_arch}"
@@ -225,7 +215,7 @@ init_repo() {
  fi
}

while getopts ":a:cur:shpt" opt; do
while getopts ":a:cur:shp" opt; do
  case $opt in
  a) arch="$OPTARG" ;;
  c) clean=1 ;;
@@ -233,7 +223,6 @@ while getopts ":a:cur:shpt" opt; do
  s) gsync=1 ;;
  h) history=0 ;;
  p) patchonly=1 ;;
  t) trichrome=1 ;;
  :)
    echo "Option -$OPTARG requires an argument"
    echo
+0 −2
Original line number Diff line number Diff line
@@ -48,12 +48,10 @@ use_debug_fission=true
use_errorprone_java_compiler=false
use_official_google_api_keys=false
use_rtti=false
use_stable_package_name_for_trichrome=false
use_thin_lto=false
use_v8_context_snapshot=false
enable_glic = false
build_tflite_with_xnnpack = false

chrome_public_manifest_package = "foundation.e.browser"
trichrome_library_package = "foundation.e.trichromelibrary"
system_webview_package_name="com.android.webview"
+0 −80
Original line number Diff line number Diff line
From 491520d973dfcf09867012bcc389eb7c6081bb33 Mon Sep 17 00:00:00 2001
From: Daniel Micay <danielmicay@gmail.com>
Date: Thu, 27 May 2021 07:30:02 -0400
Subject: add trichrome browser apk targets

Signed-off-by: Saalim Quadri <danascape@gmail.com>
---
 chrome/android/BUILD.gn                   | 35 +++++++++++++++++++++++
 chrome/android/chrome_public_apk_tmpl.gni |  2 ++
 2 files changed, 37 insertions(+)

diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn
index 62886ed250b11..573f9310e5304 100644
--- a/chrome/android/BUILD.gn
+++ b/chrome/android/BUILD.gn
@@ -1938,6 +1938,10 @@ if (_is_default_toolchain) {
     is_trichrome = true
     is_bundle_module = true
   }
+  resource_packaging("trichrome_chrome_apk_pak_assets") {
+    is_monochrome = false
+    is_trichrome = true
+  }
 
   # Exists separately from chrome_public_base_module_java_for_test to allow
   # downstream to depend on test support packages without needing to depend on
@@ -2306,6 +2310,37 @@ if (_is_default_toolchain) {
       }
     }
   }
+ 
+  chrome_public_apk_or_module_tmpl("trichrome_chrome_apk") {
+    apk_name = "TrichromeChrome"
+    is_trichrome = true
+    target_type = "android_apk"
+    static_library_provider = ":trichrome_library_apk"
+    if (android_64bit_target_cpu) {
+      is_64_bit_browser = false
+      include_64_bit_webview = true
+    }
+  }
+  
+  if (android_64bit_target_cpu) {
+    chrome_public_apk_or_module_tmpl("trichrome_chrome_64_32_apk") {
+      apk_name = "TrichromeChrome6432"
+      is_trichrome = true
+      target_type = "android_apk"
+      static_library_provider = ":trichrome_library_64_32_apk"
+      is_64_bit_browser = true
+      include_32_bit_webview = true
+    }
+  
+    chrome_public_apk_or_module_tmpl("trichrome_chrome_64_apk") {
+      apk_name = "TrichromeChrome64"
+      is_trichrome = true
+      target_type = "android_apk"
+      static_library_provider = ":trichrome_library_64_apk"
+      is_64_bit_browser = true
+      include_32_bit_webview = false
+    }
+  }
 
   # As compared to chrome_public_test_apk, this target contains only unit tests
   # that require on device capabilities. These tests are smaller, more tightly
diff --git a/chrome/android/chrome_public_apk_tmpl.gni b/chrome/android/chrome_public_apk_tmpl.gni
index 11a2027765ab5..d3d091b8d929d 100644
--- a/chrome/android/chrome_public_apk_tmpl.gni
+++ b/chrome/android/chrome_public_apk_tmpl.gni
@@ -494,6 +494,8 @@ template("chrome_common_apk_or_module_tmpl") {
       asset_deps += [ "//chrome/android:chrome_bundle_module_pak_assets" ]
     } else if (_is_monochrome) {
       asset_deps += [ "//chrome/android:monochrome_apk_pak_assets" ]
+    } else if (_is_trichrome) {
+      asset_deps += [ "//chrome/android:trichrome_chrome_apk_pak_assets" ]
     } else {
       assert(!_is_trichrome)
       asset_deps += [ "//chrome/android:chrome_apk_pak_assets" ]
-- 
2.52.0
+0 −1
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@ fixup-Disable-fetching-of-all-field-trials.patch
fixup-eyeo-Browser-Ad-filtering-Solution.patch
fixup-Move-navigation-bar-to-bottom.patch
fixup-Disable-all-predictors-code.patch
add-trichrome-browser-apk-targets.patch
Browser-disable-price-shopping-commerce-integration.patch
Remove-bromite-auto-updater-option.patch
Browser-Change-app-and-package-name-to-browser.patch

trichrome_patch.py

deleted100755 → 0
+0 −81
Original line number Diff line number Diff line
#!/usr/bin/env python3

import os
import sys
import subprocess
import zipfile

def main():
    if len(sys.argv) != 5:
        print("Usage: {} <input_apk_file> <ks_file> <ks_pass> <ks_alias>".format(sys.argv[0]))
        sys.exit(1)

    input_apk = sys.argv[1]
    cert = sys.argv[2]
    ks_pass = sys.argv[3]
    ks_alias = sys.argv[4]

    root_dir = os.path.dirname(os.path.realpath(__file__))

    if not cert.endswith(".jks"):
        print(">> [{}] Error: Certificate file must have the extension .jks.".format(get_current_time()))
        sys.exit(1)
    else:
        print(">> [{}] Patching apk.".format(get_current_time()))
        certdigest = get_certificate_fingerprint(cert, ks_pass)
        fingerprint = certdigest.replace(':', '').lower()
        patch_apk(root_dir, fingerprint, input_apk)

    output_apk = "{}_signed.apk".format(os.path.splitext(input_apk)[0])

    if os.path.exists("{}_patched".format(input_apk)):
        print(">> [{}] Zipaligning apk.".format(get_current_time()))
        zipalign_apk("{}_patched".format(input_apk), output_apk)
        os.remove("{}_patched".format(input_apk))
    else:
        subprocess.run(["cp", input_apk, output_apk])

    if os.path.exists(output_apk):
        print(">> [{}] Signing apk.".format(get_current_time()))
        sign_apk(cert, ks_pass, ks_alias, output_apk)

def get_current_time():
    return subprocess.check_output("date", shell=True).decode().strip()

def get_certificate_fingerprint(cert, ks_pass):
    certdigest = subprocess.check_output("openssl x509 -sha256 -fingerprint -noout -in {} -passin pass:{}".format(cert, ks_pass), shell=True).decode().strip()
    return certdigest.split('=')[1].replace(':', '').lower()

def patch_apk(root_dir, new_certdigest, input_apk):
    orig_certdigest = "32a2fc74d731105859e5a85df16d95f102d85b22099b8064c5d8915c61dad1e0"

    if orig_certdigest == new_certdigest:
        return

    delete_apk = False

    with zipfile.ZipFile(input_apk, 'r') as zin:
        outfilename = "{}_patched".format(input_apk)
        with zipfile.ZipFile(outfilename, 'w') as zout:
            for info in zin.infolist():
                data = zin.read(info.filename)
                if info.filename == 'AndroidManifest.xml':
                    if new_certdigest.encode('utf-16-le') in data:
                        delete_apk = True
                    elif orig_certdigest.encode('utf-16-le') in data:
                        data = data.replace(orig_certdigest.encode('utf-16-le'), new_certdigest.encode('utf-16-le'))
                    else:
                        delete_apk = True
                zout.writestr(info, data)

    if delete_apk and os.path.exists(outfilename):
        os.remove(outfilename)

def zipalign_apk(input_apk, output_apk):
    subprocess.run(["zipalign", "-f", "-p", "4",  input_apk, output_apk])

def sign_apk(cert, ks_pass, ks_alias, output_apk):
    subprocess.run(["apksigner", "sign", "--ks", cert, "--ks-pass", "pass:{}".format(ks_pass), "--ks-key-alias", ks_alias, output_apk])

if __name__ == "__main__":
    main()