Pier Angelo Vendrame pushed to branch tor-browser-128.5.0esr-14.5-1 at The Tor Project / Applications / Tor Browser
Commits: 81108ca4 by Pier Angelo Vendrame at 2024-12-03T09:45:46+01:00 fixup! Bug 41089: Add tor-browser build scripts + Makefile to tor-browser
Bug 42690: Add a Makefile target to build APKs.
Now that we use a monorepo, we can extend our existing tools to build also Fenix and to install it via adb.
Also, update the env templates.
- - - - - efd91fc3 by Pier Angelo Vendrame at 2024-12-03T09:45:52+01:00 fixup! [android] Modify build system
Bug 42690: Add a Makefile target to build APKs.
Update the paths on tba-sign-devbuilds.sh (and make them more generic when possible).
- - - - -
10 changed files:
- mobile/android/fenix/tools/tba-sign-devbuilds.sh - tools/geckoview/Makefile - tools/geckoview/android-env-linux-template.sh - tools/geckoview/android-env-macos-template.sh - + tools/geckoview/build-fenix.sh - tools/geckoview/build.sh → tools/geckoview/build-geckoview.sh - tools/geckoview/clobber.sh - tools/geckoview/config.sh - − tools/geckoview/fataar.py - − tools/geckoview/package-gradle.sh
Changes:
===================================== mobile/android/fenix/tools/tba-sign-devbuilds.sh ===================================== @@ -2,20 +2,38 @@
cd "$(dirname $(realpath "$0"))/.."
-if [ -z "$TOR_BROWSER_BUILD" ]; then - TOR_BROWSER_BUILD=../../tor-browser-build +if [ -z "$APKSIGNER_ARGS" ]; then + if [ -z "$QA_KEY" ]; then + if [ -z "$TOR_BROWSER_BUILD" ]; then + TOR_BROWSER_BUILD=../../../../tor-browser-build + fi + QA_KEY="$TOR_BROWSER_BUILD/projects/browser/android-qa.keystore" + fi + if [ ! -f "$QA_KEY" ]; then + echo "The QA key has not been found." + echo "Please define either $QA_KEY with its path, or $TOR_BROWSER_BUILD with the path to tor-browser-build" + exit 2 + fi + APKSIGNER_ARGS="--ks "$QA_KEY" --ks-key-alias androidqakey --key-pass pass:android --ks-pass pass:android" fi -key="$TOR_BROWSER_BUILD/projects/browser/android-qa.keystore" -if [ ! -f "$key" ]; then - echo "Please define TOR_BROWSER_BUILD with the path to tor-browser-build" - exit 2 + +if [ -z "$ANDROID_HOME" ]; then + ANDROID_HOME=~/Android fi
-tools="$ANDROID_HOME/build-tools/31.0.0" -apksigner="$tools/apksigner" -zipalign="$tools/zipalign" -if [ ! -x "$apksigner" ]; then - echo "apksigner not found at $apksigner. Please make sure ANDROID_HOME is defined" +function find_tool() { + tool="$(find $ANDROID_HOME -name "$1" | head -1)" + if [ -z "$tool" ]; then + tool=$(which $1) + fi + echo $tool +} + +apksigner="$(find_tool apksigner)" +zipalign="$(find_tool zipalign)" +if [ -z "$apksigner" -o ! -x "$apksigner" -o -z "$zipalign" -o ! -x "$zipalign" ]; then + echo "apksigner or zipalign not found." + echo "Please make sure they are on your $PATH, or define $ANDROID_HOME." exit 3 fi
@@ -40,8 +58,8 @@ sign () { popd > /dev/null rm -f "$aligned" "$zipalign" -p 4 "$apk" "$aligned" - "$apksigner" sign --ks "$key" --in "$aligned" --out "$out" --ks-key-alias androidqakey --key-pass pass:android --ks-pass pass:android - echo "Signed $out" + echo "Signing $out" + "$apksigner" sign --in "$aligned" --out "$out" $APKSIGNER_ARGS }
for channel in app/build/outputs/apk/fenix/*; do
===================================== tools/geckoview/Makefile ===================================== @@ -1,9 +1,15 @@ .DEFAULT_GOAL := all
# one of armv7 aarch64 x86 x86_64 -ARCH=aarch64 +ARCH := aarch64 +ANDROID_ARCH := $(ARCH) +ifeq ($(ANDROID_ARCH),aarch64) + ANDROID_ARCH := arm64-v8a +endif +ifeq ($(ANDROID_ARCH),armv7) + ANDROID_ARCH := armeabi-v7a +endif
-ARCHS=$(ARCH) OS="${shell uname}"
# https://stackoverflow.com/questions/18136918/how-to-get-current-relative-dir... @@ -17,23 +23,33 @@ clobber: env config: env ./config.sh $(DEV_ROOT) $(ARCH)
-build: env - ./build.sh $(DEV_ROOT) $(ARCH) +geckoview: env + ./build-geckoview.sh $(DEV_ROOT) $(ARCH)
-fataar: env - bash -c "source android-env.sh && ./fataar.py $(DEV_ROOT) $(ARCHS)" - -package: env - ./package-gradle.sh $(DEV_ROOT) $(ARCH) - -show: - ls -lh ~/.m2/repository/org/mozilla/geckoview/geckoview-default-omni/ - ls -lh ~/.m2/repository/org/mozilla/geckoview/geckoview-default-omni/$(shell ls ~/.m2/repository/org/mozilla/geckoview/geckoview-default-omni | tail -n 2 | head -n 1) +# These targets do not depend on GeckoView so that you can build only Fenix if +# you are not changing GV code. +fenix-release: env + ./build-fenix.sh $(DEV_ROOT) $(ARCH) Release +fenix-beta: env + ./build-fenix.sh $(DEV_ROOT) $(ARCH) Beta +fenix-nightly: env + ./build-fenix.sh $(DEV_ROOT) $(ARCH) Nightly +fenix-debug: env + ./build-fenix.sh $(DEV_ROOT) $(ARCH) Debug
env: test -e android-env.sh || { echo "copy android-env-...-template.sh to android-env.sh and edit appropriatly"; exit 1; }
-all: env build package +install-release: + adb install "$(DEV_ROOT)/mobile/android/fenix/app/build/outputs/apk/fenix/release/app-fenix-$(ANDROID_ARCH)-release-signed.apk" +install-beta: + adb install "$(DEV_ROOT)/mobile/android/fenix/app/build/outputs/apk/fenix/beta/app-fenix-$(ANDROID_ARCH)-beta-signed.apk" +install-nightly: + adb install "$(DEV_ROOT)/mobile/android/fenix/app/build/outputs/apk/fenix/nightly/app-fenix-$(ANDROID_ARCH)-nightly-signed.apk" + +all: env geckoview fenix-nightly install-nightly +all-release: env geckoview fenix-release install-release +all-beta: env geckoview fenix-beta install-beta
jslint: ./jslint.sh $(DEV_ROOT) $(JS)
===================================== tools/geckoview/android-env-linux-template.sh ===================================== @@ -1,7 +1,6 @@ -export MOZ_BUILD_DATE=20230710165010 # This should match the data in [firefox-android](https://gitlab.torproject.org/tpo/applications/firefox-android)/android-comp... ~ln 12's def of the variable *version*, the date component export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 export ANDROID_HOME=$HOME/.mozbuild/android-sdk-linux/ # or $HOME/Android/Sdk/ # Or .../android-toolchain/android-sdk-linux if you extract android-toolchain from tor-browser-build -export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/23.2.8568313/ # for 115esr -export GRADLE_HOME=/FULL/PATH/TO/tor-browser-build/out/gradle/gradle-7.5.1 # Or the version that we currently use +export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/r26c/ # for 128esr +export GRADLE_HOME=/FULL/PATH/TO/tor-browser-build/out/gradle/gradle-8.8 # Or the version that we currently use export LOCAL_DEV_BUILD=1 export PATH=/FULL/PATH/TO/tor-browser-build/out/clang/clang-16.x.y-arm/bin/:$PATH # prepend our newly built and assembled clang to the path so it gets used to build geckoview
===================================== tools/geckoview/android-env-macos-template.sh ===================================== @@ -1,4 +1,3 @@ -export MOZ_BUILD_DATE=20230710165010 # This should match the data in [firefox-android](https://gitlab.torproject.org/tpo/applications/firefox-android)/android-comp... ~ln 12's def of the variable *version*, the date component export JAVA_HOME=/opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk/Contents/Home/ # for arm64. Or JAVA_HOME=/usr/local/opt/openjdk@11/libexec/openjdk.jdk/Contents/Home/ for x86_64. export ANDROID_HOME=$HOME/Library/Android/sdk # or $HOME/.mozbuild/android-sdk-macosx/ export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/23.2.8568313 # will need to download NDK 23.2.8568313 via android studio
===================================== tools/geckoview/build-fenix.sh ===================================== @@ -0,0 +1,11 @@ +#!/bin/bash +set -e +DEV_ROOT=$1 +ARCH=$2 +VARIANT=$3 + +source android-env.sh + +cd $DEV_ROOT/mobile/android/fenix +MOZCONFIG=mozconfig-android-$ARCH $GRADLE_HOME/bin/gradle --no-daemon -Dorg.gradle.jvmargs=-Xmx20g -PdisableOptimization assemble$VARIANT +tools/tba-sign-devbuilds.sh
===================================== tools/geckoview/build.sh → tools/geckoview/build-geckoview.sh ===================================== @@ -6,4 +6,4 @@ ARCH=$2 source android-env.sh
cd $DEV_ROOT -MOZCONFIG=mozconfig-android-$ARCH ./mach build +MOZCONFIG=mozconfig-android-$ARCH ./mach build
===================================== tools/geckoview/clobber.sh ===================================== @@ -7,4 +7,3 @@ source android-env.sh
cd $DEV_ROOT MOZCONFIG=mozconfig-android-$ARCH ./mach clobber -MOZCONFIG=mozconfig-android-all ./mach clobber
===================================== tools/geckoview/config.sh ===================================== @@ -6,4 +6,4 @@ ARCH=$2 source android-env.sh
cd $DEV_ROOT -MOZCONFIG=mozconfig-android-$ARCH ./mach configure --without-wasm-sandboxed-libraries +MOZCONFIG=mozconfig-android-$ARCH ./mach configure --without-wasm-sandboxed-libraries
===================================== tools/geckoview/fataar.py deleted ===================================== @@ -1,52 +0,0 @@ -#!/usr/bin/env python3 -import os -import re -import subprocess -import sys - -dev_root = sys.argv[1] -archs_in = re.split("\s+|,", sys.argv[2]) if len(sys.argv) >= 3 else [] -archs_out = [] -env = dict(os.environ) - -env["MOZCONFIG"] = "mozconfig-android-all" -if "armv7" in archs_in: - env["MOZ_ANDROID_FAT_AAR_ARMEABI_V7A"] = ( - dev_root - + "/obj-arm-linux-androideabi/gradle/build/mobile/android/geckoview/outputs/aar/geckoview-withGeckoBinaries-debug.aar" - ) - archs_out.append("armeabi-v7a") -if "aarch64" in archs_in: - env["MOZ_ANDROID_FAT_AAR_ARM64_V8A"] = ( - dev_root - + "/obj-aarch64-linux-android/gradle/build/mobile/android/geckoview/outputs/aar/geckoview-withGeckoBinaries-debug.aar" - ) - archs_out.append("arm64-v8a") -if "x86" in archs_in or "i686" in archs_in: - env["MOZ_ANDROID_FAT_AAR_X86"] = ( - dev_root - + "/obj-i386-linux-android/gradle/build/mobile/android/geckoview/outputs/aar/geckoview-withGeckoBinaries-debug.aar" - ) - archs_out.append("x86") -if "x86_64" in archs_in or "x86-64" in archs_in: - env["MOZ_ANDROID_FAT_AAR_X86_64"] = ( - dev_root - + "/obj-x86_64-linux-android/gradle/build/mobile/android/geckoview/outputs/aar/geckoview-withGeckoBinaries-debug.aar" - ) - archs_out.append("x86_64") -env["MOZ_ANDROID_FAT_AAR_ARCHITECTURES"] = ",".join(archs_out) - -if not archs_out: - print( - "The architectures have not specified or are not valid.", - file=sys.stderr, - ) - print('Usage: make fat-aar ARCHS="$archs"', file=sys.stderr) - print( - "Valid architectures are armv7 aarch64 x86 x86_64, and must be separated with a space.", - file=sys.stderr, - ) - sys.exit(1) - -subprocess.run(["./mach", "configure"], cwd=dev_root, env=env, check=True) -subprocess.run(["./mach", "build"], cwd=dev_root, env=env, check=True)
===================================== tools/geckoview/package-gradle.sh deleted ===================================== @@ -1,15 +0,0 @@ -#!/bin/bash -set -e -DEV_ROOT=$1 -ARCH=$2 - -source android-env.sh - -env ARCHS=$ARCH make fataar - -cd $DEV_ROOT -MOZCONFIG=mozconfig-android-$ARCH ./mach build binaries -MOZCONFIG=mozconfig-android-$ARCH ./mach gradle geckoview:publishWithGeckoBinariesDebugPublicationToMavenRepository -MOZCONFIG=mozconfig-android-all ./mach gradle geckoview:publishWithGeckoBinariesDebugPublicationToMavenLocal exoplayer2:publishDebugPublicationToMavenLocal - -
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/6756b73...
tor-commits@lists.torproject.org