[tor-commits] [Git][tpo/applications/tor-browser-build][main] 2 commits: Bug 41232: Implement single-arch testbuilds on the monorepo.

Pier Angelo Vendrame (@pierov) git at gitlab.torproject.org
Tue Sep 10 07:55:25 UTC 2024



Pier Angelo Vendrame pushed to branch main at The Tor Project / Applications / tor-browser-build


Commits:
fe08aea2 by Pier Angelo Vendrame at 2024-09-10T09:54:59+02:00
Bug 41232: Implement single-arch testbuilds on the monorepo.

The trick of the fake fat AAR does not work anymore, as the fat AAR is
consumed in the same script where it is created.
However, running an Android build from a single-arch tree seems not to
involve different commands, so we can create a shared script and
include it in both the build steps.

- - - - -
d057d3b5 by Pier Angelo Vendrame at 2024-09-10T09:55:04+02:00
Bug 41234: Add some dependencies needed for Android/release.

Building Android as release fails because we do not provide some
additional dependencies to our offline builds.

- - - - -


9 changed files:

- projects/browser/config
- projects/geckoview/build
- + projects/geckoview/build_ac_fenix
- projects/geckoview/build_apk
- projects/geckoview/build_common
- projects/geckoview/config
- projects/geckoview/gradle-dependencies-list.txt
- projects/tor-expert-bundle-aar/build
- projects/tor-expert-bundle-aar/config


Changes:

=====================================
projects/browser/config
=====================================
@@ -90,7 +90,11 @@ input_files:
   - project: geckoview
     name: fenix
     pkg_type: build_apk
-    enable: '[% c("var/android") %]'
+    enable: '[% c("var/android") && !c("var/android_single_arch") %]'
+  - project: geckoview
+    name: fenix
+    pkg_type: build
+    enable: '[% c("var/android") && c("var/android_single_arch") %]'
   - project: tor-expert-bundle
     name: tor-expert-bundle
     enable: '[% c("var/tor-browser") %]'


=====================================
projects/geckoview/build
=====================================
@@ -43,29 +43,14 @@ echo "Starting ./mach configure $(date)"
 echo "Starting ./mach build $(date)"
 ./mach build --verbose
 
+echo "Build finished, copying the AAR to the to the destination directory $(date)"
+
 [% IF !c("var/android_single_arch") -%]
   mkdir "$distdir/[% project %]"
   # We don't want the debug or "exoplayer" .aars, but the .aar that has `omni` in its name.
   find obj-* -type f -name geckoview*omni*.aar -exec cp {} $distdir/[% project %] \;
 [% ELSE -%]
-  # For single-arch builds, we want to fake a fat aar anyway, to avoid having
-  # arch suffixes in filenames, or having to rename files.
-  cat >> mozconfig-android-all << 'MOZCONFIG_EOF'
-ac_add_options --enable-update-channel=[% c("var/variant") %]
-ac_add_options --with-base-browser-version=[% c("var/torbrowser_version") %]
-export MOZ_INCLUDE_SOURCE_INFO=1
-export MOZ_SOURCE_REPO="[% c('var/gitlab_project') %]"
-export MOZ_SOURCE_CHANGESET=[% c("var/git_commit") %]
-MOZCONFIG_EOF
-
-  echo "Starting the creation of the fake fat AAR $(date)"
-  pushd tools/geckoview
-  touch android-env.sh
-  make fataar ARCHS="[% c('arch') %]"
-  popd
-  MOZCONFIG=mozconfig-android-all ./mach gradle \
-    geckoview:publishWithGeckoBinariesDebugPublicationToMavenLocal \
-    exoplayer2:publishDebugPublicationToMavenLocal
+[% INCLUDE 'build_ac_fenix' %]
 [% END -%]
 
 echo "Starting to package artifacts $(date)"


=====================================
projects/geckoview/build_ac_fenix
=====================================
@@ -0,0 +1,56 @@
+[% IF c('var/has_l10n') -%]
+  echo "Injecting the Firefox's localization to GV $(date)"
+  supported_locales="[% tmpl(c('var/locales_mobile').join(' ')).replace('-r', '-').replace('in', 'id').replace('iw', 'he') %]"
+  l10ncentral="$HOME/.mozbuild/l10n-central"
+  mkdir "$l10ncentral"
+  for tarball in $rootdir/[% c('input_files_by_name/firefox-l10n') %]/*; do
+    tar -C "$l10ncentral" -xf "$tarball"
+  done
+
+  # Do not setup our localization files, as we do not provide any frontend
+  # through GeckoView.
+
+  # No quotes on purpose, to pass each locale as an additional argument.
+  ./mach package-multi-locale --locales en-US $supported_locales
+[% END -%]
+
+echo "Building Android Components $(date)"
+pushd mobile/android/android-components
+gradle $GRADLE_FLAGS assembleGecko -x lint
+popd
+
+# The build might fail with "file exists" otherwise.
+rm -rf /var/tmp/dist/android-toolchain/gradle/glean/pythonenv
+
+echo "Building Fenix $(date)"
+pushd mobile/android/fenix
+
+cp -a $rootdir/[% c('input_files_by_name/tor-expert-bundle-aar') %]/tor-expert-bundle.aar app/
+
+# Use the Android Components we have just built
+echo autoPublish.android-components.dir=../android-components > local.properties
+
+[% IF c('var/has_l10n') -%]
+  tar -C $distdir -xf $rootdir/[% c('input_files_by_name/translation-fenix') %]
+  # Add our localized strings
+  supported_locales="[% tmpl(c('var/locales_mobile').join(' ')) %]"
+  for lang in $supported_locales; do
+    cp "/var/tmp/dist/translation-fenix/$lang/torbrowser_strings.xml" "app/src/main/res/values-$lang/"
+  done
+[% END -%]
+
+# Bug 40485: Inject deterministic build date into Glean.
+echo 'ext.gleanBuildDate = "0"' >> app/build.gradle
+
+variant='[% c("var/variant") %]'
+version_name="[% c('var/torbrowser_version') %] ([% c('var/geckoview_version') %])"
+
+gradle $GRADLE_FLAGS -PversionName="$version_name" "assemble$variant"
+
+echo "Build finished, copying the APK(s) to the destination directory $(date)"
+
+mkdir $distdir/[% project %]
+cp app/build/outputs/apk/fenix/$variant/*.apk $distdir/[% project %]
+
+popd
+


=====================================
projects/geckoview/build_apk
=====================================
@@ -1,10 +1,7 @@
 #!/bin/bash
 [% INCLUDE 'build_common' %]
 
-tar -C $distdir -xf $rootdir/[% c('input_files_by_name/translation-fenix') %]
-
-tar -xf [% c('input_files_by_name/glean-wheels') %]
-export GLEAN_PYTHON_WHEELS_DIR=$rootdir/glean-wheels
+echo "Starting the creation of the fat AAR $(date)"
 
 tar -C $builddir -xf [% c('input_files_by_name/geckoview_armv7') %]
 tar -C $builddir -xf [% c('input_files_by_name/geckoview_aarch64') %]
@@ -29,18 +26,6 @@ export MOZ_SOURCE_REPO="[% c('var/gitlab_project') %]"
 export MOZ_SOURCE_CHANGESET=[% c("var/git_commit") %]
 MOZCONFIG_EOF
 
-[% IF c("var/has_l10n") -%]
-  supported_locales="[% tmpl(c('var/locales_mobile').join(' ')).replace('-r', '-').replace('in', 'id').replace('iw', 'he') %]"
-  l10ncentral="$HOME/.mozbuild/l10n-central"
-  mkdir "$l10ncentral"
-  for tarball in $rootdir/[% c('input_files_by_name/firefox-l10n') %]/*; do
-    tar -C "$l10ncentral" -xf "$tarball"
-  done
-
-  # Do not setup our localization files, as we do not provide any frontend
-  # through GeckoView.
-[% END -%]
-
 # We still need to specify --tor-browser-version due to bug 34005.
 ./mach configure \
   --with-base-browser-version=[% c("var/torbrowser_version") %] \
@@ -49,43 +34,7 @@ MOZCONFIG_EOF
 
 ./mach build --verbose
 
-[% IF c('var/has_l10n') -%]
-  # No quotes on purpose, to pass each locale as an additional argument.
-  ./mach package-multi-locale --locales en-US $supported_locales
-[% END -%]
-
-pushd mobile/android/android-components
-gradle $GRADLE_FLAGS assembleGecko -x lint
-popd
-
-# The build might fail with "file exists" otherwise.
-rm -rf /var/tmp/dist/android-toolchain/gradle/glean/pythonenv
-
-pushd mobile/android/fenix
-
-cp -a $rootdir/[% c('input_files_by_name/tor-expert-bundle-aar') %]/tor-expert-bundle.aar app/
-
-# Use the Android Components we have just built
-echo autoPublish.android-components.dir=../android-components > local.properties
-
-# Add our localized strings
-supported_locales="[% tmpl(c('var/locales_mobile').join(' ')) %]"
-for lang in $supported_locales; do
-  cp "/var/tmp/dist/translation-fenix/$lang/torbrowser_strings.xml" "app/src/main/res/values-$lang/"
-done
-
-# Bug 40485: Inject deterministic build date into Glean.
-echo 'ext.gleanBuildDate = "0"' >> app/build.gradle
-
-variant='[% c("var/variant") %]'
-version_name="[% c('var/torbrowser_version') %] ([% c('var/geckoview_version') %])"
-
-gradle $GRADLE_FLAGS -PversionName="$version_name" "assemble$variant"
-
-mkdir $distdir/[% project %]
-cp app/build/outputs/apk/fenix/$variant/*.apk $distdir/[% project %]
-
-popd
+[% INCLUDE 'build_ac_fenix' %]
 
 cd $distdir/
 [% c('tar', {


=====================================
projects/geckoview/build_common
=====================================
@@ -37,6 +37,9 @@ cp -rl $gradle_repo/dl/android/maven2/* $gradle_repo || true
 cp -rl $gradle_repo/m2/* $gradle_repo || true
 cp -rl $gradle_repo/maven2/* $gradle_repo || true
 
+tar -xf [% c('input_files_by_name/glean-wheels') %]
+export GLEAN_PYTHON_WHEELS_DIR=$rootdir/glean-wheels
+
 tar -xf [% c('input_files_by_name/oss-licenses-plugin') %]
 cp -rl oss-licenses-plugin/. $gradle_repo
 


=====================================
projects/geckoview/config
=====================================
@@ -36,7 +36,7 @@ var:
     - openjdk-17-jdk-headless
   # this should be updated when the list of gradle dependencies is changed
   # see doc/how-to-create-gradle-dependencies-list.txt
-  gradle_dependencies_version: 14
+  gradle_dependencies_version: 15
   gradle_version: 8.8
   glean_parser: 14.0.1
   variant: beta
@@ -105,6 +105,7 @@ steps:
       - name: translation-fenix
         project: translation
         pkg_type: fenix
+        enable: '[% c("var/has_l10n") %]'
       - URL: '[% pc("glean", "var/glean_wheels_url/" _ c("var/glean_parser"), { error_if_undef => 1 }) %]'
         name: glean-wheels
         sha256sum: '[% pc("glean", "var/glean_wheels_sha256sum/" _ c("var/glean_parser"), { error_if_undef => 1 }) %]'
@@ -150,5 +151,18 @@ input_files:
   - filename: 'gradle-dependencies-[% c("var/gradle_dependencies_version") %]'
     name: gradle-dependencies
     exec: '[% INCLUDE "fetch-gradle-dependencies" %]'
+  - URL: '[% pc("glean", "var/glean_wheels_url/" _ c("var/glean_parser"), { error_if_undef => 1 }) %]'
+    name: glean-wheels
+    sha256sum: '[% pc("glean", "var/glean_wheels_sha256sum/" _ c("var/glean_parser"), { error_if_undef => 1 }) %]'
   - project: oss-licenses-plugin
     name: oss-licenses-plugin
+  - name: tor-expert-bundle-aar
+    project: tor-expert-bundle-aar
+    enable: '[% c("var/android_single_arch") %]'
+  - project: firefox-l10n
+    name: firefox-l10n
+    enable: '[% c("var/android_single_arch") && c("var/has_l10n") %]'
+  - name: translation-fenix
+    project: translation
+    pkg_type: fenix
+    enable: '[% c("var/android_single_arch") && c("var/has_l10n") %]'


=====================================
projects/geckoview/gradle-dependencies-list.txt
=====================================
@@ -2907,3 +2907,25 @@ fd64e97234d4c056018ed5ab1e22932bfe5a31b8d80ab9375b6b7b9dfa7ed031 | https://maven
 9f40ab0b8cf4e7cb0f593493c2ed96e7155d0e91eb592407597ecd61e2d5a054 | https://maven.google.com/androidx/compose/runtime/runtime/1.6.7/runtime-1.6.7.jar
 3018ecf7ef0302f1c2492e4c627ae36b763167779b4595fa89331553f5b0c51a | https://maven.google.com/androidx/compose/material/material-ripple/1.6.7/material-ripple-1.6.7.jar
 4e75469751c9d4c464c7d06af283b9737693c20bc4aaf657630bb294c27bbff1 | https://maven.google.com/androidx/compose/foundation/foundation-layout/1.6.7/foundation-layout-1.6.7.jar
+74c0e3f8c3df0b1d32ab9d839448c914586d3e8479611e4386fecfa6b3f0a26b | https://repo1.maven.org/maven2/com/squareup/okhttp3/okhttp-urlconnection/4.12.0/okhttp-urlconnection-4.12.0.jar
+a99cf993825e5a2ff12f50973398e7c9fc570055368bdf1026a79efcfb5e6d72 | https://repo1.maven.org/maven2/com/squareup/okhttp3/okhttp-urlconnection/4.12.0/okhttp-urlconnection-4.12.0.pom
+b88186fde75edc3871c5e785c112006dfdd670abba1bb50cdb669fd32291f411 | https://repo1.maven.org/maven2/com/squareup/leakcanary/leakcanary-android-instrumentation/2.14/leakcanary-android-instrumentation-2.14.aar
+db2f190ebcb2d5d2d5fdb535907df5ab0df0854db49186409ba51c7942441d96 | https://repo1.maven.org/maven2/com/squareup/leakcanary/leakcanary-android-instrumentation/2.14/leakcanary-android-instrumentation-2.14.pom
+15848fb56db32f4c7cdc72b324003183d52a4884d6bf09be708ac7f587d139b5 | https://dl.google.com/dl/android/maven2/androidx/lifecycle/lifecycle-common/2.3.1/lifecycle-common-2.3.1.jar
+8cd23d889a14095c6ce16840d29b1a6388fa5e115144c1309d4d6d469c1bc351 | https://dl.google.com/dl/android/maven2/androidx/lifecycle/lifecycle-common/2.3.1/lifecycle-common-2.3.1.pom
+67359f609dfc2bf65da1270b23033f856064ec279f058e0a70c715f7c9003031 | https://dl.google.com/dl/android/maven2/androidx/lifecycle/lifecycle-livedata/2.6.2/lifecycle-livedata-2.6.2.aar
+d7c9e019cf68779387481877878f6c499d1786b85f2c0480e9264dd5097c51c0 | https://dl.google.com/dl/android/maven2/androidx/lifecycle/lifecycle-livedata/2.6.2/lifecycle-livedata-2.6.2.pom
+0157de61a2064047896a058080f3fd67ba57ad9a94857b3f7a363660243e3f90 | https://maven.google.com/androidx/annotation/annotation-experimental/1.1.0/annotation-experimental-1.1.0.aar
+550a6601e1af47cf99501cc6cc15d1ebe9cef17b51e5dd58b6ab6c23568ef7a9 | https://maven.google.com/androidx/annotation/annotation-experimental/1.1.0/annotation-experimental-1.1.0.pom
+9029262bddce116e6d02be499e4afdba21f24c239087b76b3b57d7e98b490a36 | https://maven.google.com/androidx/annotation/annotation/1.2.0/annotation-1.2.0.jar
+62fb6dca2777efe08e7077d6b872d69110619df7fc21c99a6f54066499cc0383 | https://maven.google.com/androidx/annotation/annotation/1.2.0/annotation-1.2.0.pom
+4867fd5279742fba8388821930cb2affe06d81a52814e7e41e70392ea0ef887c | https://maven.google.com/androidx/lifecycle/lifecycle-runtime/2.6.2/lifecycle-runtime-2.6.2.aar
+8175255546e2a5f510865f84ace680660954730240b1905d9175b4345beda977 | https://maven.google.com/androidx/lifecycle/lifecycle-runtime/2.6.2/lifecycle-runtime-2.6.2.pom
+7bc7dcbab17636ec076f12afe4d02671265c389457b1b366b37a0e8cb91e2da0 | https://maven.google.com/androidx/lifecycle/lifecycle-viewmodel-savedstate/2.6.2/lifecycle-viewmodel-savedstate-2.6.2.aar
+7fc854440644cf52c35894d58d946b208e42769e8517d71a5efcba17865432de | https://maven.google.com/androidx/lifecycle/lifecycle-viewmodel-savedstate/2.6.2/lifecycle-viewmodel-savedstate-2.6.2.pom
+2256780a3cff4a1e57fbb3d442557c17dc363ab8af105bcaf5261d8e2d5db949 | https://maven.google.com/androidx/lifecycle/lifecycle-livedata-core/2.6.2/lifecycle-livedata-core-2.6.2.aar
+1faf8ebf53f28b2f0ae2c2095371ae67d0ca16ac328fce7f163609a43214b5a4 | https://maven.google.com/androidx/lifecycle/lifecycle-livedata-core/2.6.2/lifecycle-livedata-core-2.6.2.pom
+e4ff4338999e1c6c9c724719f5d4aa7dd61bf6f545d5256a27a9d375df9f2330 | https://maven.google.com/androidx/lifecycle/lifecycle-viewmodel/2.6.2/lifecycle-viewmodel-2.6.2.aar
+a9fb0b39a8360beef7bdc8f3953d4d78f3d85304fc80adac3c8eaf530d758050 | https://maven.google.com/androidx/lifecycle/lifecycle-viewmodel/2.6.2/lifecycle-viewmodel-2.6.2.pom
+f34831b6c71cd844e1d35d1be49d5e79447c5ab856346531b1e8676fda7374b1 | https://maven.google.com/androidx/lifecycle/lifecycle-common/2.6.2/lifecycle-common-2.6.2.jar
+57304cdac4da289a6ecdd0738e16b1d8858f1ef8e9fabe2d65a963719fd81dba | https://maven.google.com/androidx/lifecycle/lifecycle-common/2.6.2/lifecycle-common-2.6.2.pom


=====================================
projects/tor-expert-bundle-aar/build
=====================================
@@ -7,8 +7,12 @@ mkdir -p /var/tmp/build $distdir
 mkdir tor-expert-bundle-aar
 cd tor-expert-bundle-aar
 
-[% FOREACH arch = ['armv7', 'aarch64', 'x86', 'x86_64'] -%]
-  unzip -o $rootdir/[% c('input_files_by_name/tor-expert-bundle-' _ arch) %]/tor-expert-bundle-[% arch %].aar
+[% IF c("var/android_single_arch") -%]
+  unzip -o $rootdir/[% c('input_files_by_name/tor-expert-bundle') %]/tor-expert-bundle-[% c("arch") %].aar
+[% ELSE -%]
+  [% FOREACH arch = ['armv7', 'aarch64', 'x86', 'x86_64'] -%]
+    unzip -o $rootdir/[% c('input_files_by_name/tor-expert-bundle-' _ arch) %]/tor-expert-bundle-[% arch %].aar
+  [% END -%]
 [% END -%]
 
-jar -cvf $distdir/tor-expert-bundle.aar *
\ No newline at end of file
+jar -cvf $distdir/tor-expert-bundle.aar *


=====================================
projects/tor-expert-bundle-aar/config
=====================================
@@ -12,15 +12,22 @@ input_files:
     name: tor-expert-bundle-armv7
     target_replace:
       '^torbrowser-(?!testbuild).*': 'torbrowser-android-armv7'
+    enable: '[% !c("var/android_single_arch") %]'
   - project: tor-expert-bundle
     name: tor-expert-bundle-aarch64
     target_replace:
       '^torbrowser-(?!testbuild).*': 'torbrowser-android-aarch64'
+    enable: '[% !c("var/android_single_arch") %]'
   - project: tor-expert-bundle
     name: tor-expert-bundle-x86
     target_replace:
       '^torbrowser-(?!testbuild).*': 'torbrowser-android-x86'
+    enable: '[% !c("var/android_single_arch") %]'
   - project: tor-expert-bundle
     name: tor-expert-bundle-x86_64
     target_replace:
       '^torbrowser-(?!testbuild).*': 'torbrowser-android-x86_64'
+    enable: '[% !c("var/android_single_arch") %]'
+  - project: tor-expert-bundle
+    name: tor-expert-bundle
+    enable: '[% c("var/android_single_arch") %]'



View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/compare/396f4ad688192136cf1687aeab6a7a419b615089...d057d3b5af33d32d6a0f8bd6f549185cbf7c8e62

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/compare/396f4ad688192136cf1687aeab6a7a419b615089...d057d3b5af33d32d6a0f8bd6f549185cbf7c8e62
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tor-commits/attachments/20240910/89bfa249/attachment-0001.htm>


More information about the tor-commits mailing list