build 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/bash
  2. [% c("var/set_default_env") -%]
  3. [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
  4. distdir=/var/tmp/dist
  5. builddir=/var/tmp/build/[% project %]
  6. mkdir -p $distdir/[% project %]
  7. mkdir -p /var/tmp/build
  8. tar -C $GRADLE_HOME -xf $rootdir/[% c('input_files_by_name/gradle') %]
  9. cat > get-moz-build-date << "EOF"
  10. [% INCLUDE "get-moz-build-date" %]
  11. EOF
  12. [% IF !c("var/fetch_gradle_dependencies") %]
  13. [% pc('python', 'var/setup', { python_tarfile => c('input_files_by_name/python') }) %]
  14. tar -C $distdir -xf [% c('input_files_by_name/geckoview') %]
  15. gradle_repo=$rootdir/[% c('input_files_by_name/gradle-dependencies') %]
  16. # This overwrites the release, beta, and nightly geckoview .aar files in our
  17. # gradle-dependencies directory to be sure that only the one we provide is
  18. # getting used when building beta/release code.
  19. find $gradle_repo -type f -name geckoview*.aar -exec cp -f $distdir/geckoview/geckoview*.aar {} \;
  20. cp -r $gradle_repo/dl/android/maven2/* $gradle_repo
  21. cp -r $gradle_repo/maven2/* $gradle_repo
  22. cp -r $gradle_repo/m2/* $gradle_repo
  23. tar -C $distdir -xf [% c('input_files_by_name/application-services') %]
  24. # XXX: We could be smarter (both for a-s and a-c) and just copy over the
  25. # projects that are needed according to the Gradle dependencies list.
  26. cp -rf $distdir/application-services/maven/org $gradle_repo
  27. tar -C $distdir -xf [% c('input_files_by_name/android-components') %]
  28. cp -rf $distdir/android-components/maven/org $gradle_repo
  29. tar -C $distdir -xf $rootdir/[% c('input_files_by_name/tba-translation') %]
  30. [% END %]
  31. tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
  32. cd $builddir-[% c("version") %]
  33. # Move Android library dependencies so they will be included in the apk during the build
  34. cp $rootdir/[% c('input_files_by_name/topl') %]/* app/
  35. cp $rootdir/[% c('input_files_by_name/tor-android-service') %]/* app/
  36. # XXX We need the build variant in lower case. Do something smarter here.
  37. v=[% c("variant") %]
  38. [% IF c("var/fetch_gradle_dependencies") %]
  39. $GRADLE_HOME/gradle/bin/gradle --debug --no-daemon app:assemble[% c('variant') %] \
  40. app:assembleAndroidTest -x lint -PtestBuildType=${v,} -PdisableOptimization \
  41. > gradle.log 2>&1 \
  42. || ( cat gradle.log; exit 1 )
  43. $rootdir/gen_gradle_deps_file.sh gradle.log
  44. mv gradle-dependencies-list.txt '[% dest_dir _ "/" _ c("filename") %]'
  45. [% ELSE %]
  46. # Add our localized strings
  47. [% FOREACH lang = c('var/locales_mobile');
  48. SET lang = tmpl(lang); %]
  49. # Copy our torbrowser_strings.xml at the right place
  50. cp /var/tmp/dist/tba-translation/[% lang %]/torbrowser_strings.xml app/src/main/res/values-[% lang %]/
  51. [% END %]
  52. # Prepare Glean dependencies for offline build
  53. tar -xf $rootdir/[% c('input_files_by_name/glean') %]
  54. # We need to set `LC_ALL` and `LANG` to something that is not ASCII as encoding
  55. # otherwise `click` barfs. See: https://click.palletsprojects.com/python3/
  56. export LC_ALL=C.UTF-8
  57. export LANG=C.UTF-8
  58. patch -p1 < $rootdir/mavenLocal.patch
  59. eval $(perl $rootdir/get-moz-build-date [% c("var/copyright_year") %] [% c("var/torbrowser_version") %])
  60. if [ -z $MOZ_BUILD_DATE ]
  61. then
  62. echo "MOZ_BUILD_DATE is not set"
  63. exit 1
  64. fi
  65. version_name='[% c("var/torbrowser_version") %] ([% c("var/fenix_version") %]-[% c("variant") %])'
  66. # We need -PdisableOptimization for building tests. See:
  67. # https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/issues/40259#note_2732325
  68. $GRADLE_HOME/gradle/bin/gradle --offline --no-daemon -PversionName="$version_name" -Dmaven.repo.local=$gradle_repo app:assemble[% c('variant') %] -x lint -PtestBuildType=${v,}
  69. $GRADLE_HOME/gradle/bin/gradle --offline --no-daemon -PversionName="$version_name" -Dmaven.repo.local=$gradle_repo app:assembleAndroidTest -x lint -PtestBuildType=${v,} -PdisableOptimization
  70. cp app/build/outputs/apk/${v,}/*.apk $distdir/[% project %]
  71. cp app/build/outputs/apk/androidTest/${v,}/app-${v,}-androidTest.apk $distdir/[% project %]
  72. cd $distdir
  73. [% c('tar', {
  74. tar_src => [ project ],
  75. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  76. }) %]
  77. [% END %]