build 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/bash
  2. [% c("var/set_default_env") -%]
  3. [% pc(c('var/compiler'), 'var/setup', {
  4. compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')),
  5. gradle_tarfile => c("input_files_by_name/gradle"),
  6. }) %]
  7. distdir=/var/tmp/dist
  8. builddir=/var/tmp/build/[% project %]
  9. mkdir $distdir/[% project %]
  10. mkdir /var/tmp/build
  11. cat > get-moz-build-date << "EOF"
  12. [% INCLUDE "get-moz-build-date" %]
  13. EOF
  14. [% IF !c("var/fetch_gradle_dependencies") %]
  15. tar -C $distdir -xf [% c('input_files_by_name/geckoview') %]
  16. gradle_repo=$rootdir/[% c('input_files_by_name/gradle-dependencies') %]
  17. # This overwrites the release, beta, and nightly geckoview .aar files in our
  18. # gradle-dependencies directory to be sure that only the one we provide is
  19. # getting used when building beta/release code.
  20. find $gradle_repo -type f -name geckoview*omni*.aar -exec cp -f $distdir/geckoview/geckoview*omni*.aar {} \;
  21. cp -r $gradle_repo/dl/android/maven2/* $gradle_repo
  22. cp -r $gradle_repo/maven2/* $gradle_repo
  23. cp -r $gradle_repo/m2/* $gradle_repo
  24. mkdir /home/rbm/.m2
  25. ln -s $gradle_repo /home/rbm/.m2/repository
  26. # Put the Kotlin/Native compiler at the right place, see:
  27. # tor-browser-build#40217.
  28. kotlin_dir=/home/rbm/.konan
  29. mkdir $kotlin_dir
  30. find $gradle_repo -type f -name kotlin-native-prebuilt-linux*tar.gz -exec tar -C $kotlin_dir -xaf {} \;
  31. tar -C $distdir -xf [% c('input_files_by_name/application-services') %]
  32. # XXX: We could be smarter and just copy over the projects that are needed
  33. # according to the Gradle dependencies list.
  34. cp -rf $distdir/application-services/maven/org $gradle_repo
  35. [% END %]
  36. tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
  37. cd $builddir-[% c('version') %]
  38. # Avoid call to `getGitHash()`, which will fail b/c it invokes git, which is absent in
  39. # the build container. Instead just inject the commit hash, which we know!
  40. sed -i 's/getGitHash()/\"[% c('abbrev') %]\"/' components/support/base/build.gradle
  41. sed -i 's/tag = getGitHash()/tag = \"[% c('abbrev') %]\"/' publish.gradle
  42. [% IF c("var/fetch_gradle_dependencies") %]
  43. # XXX: fetching deps for `assembleGeckoBeta -x lint` by using that same target
  44. # results in some missing dependencies for yet unknown reasons. Thus, we use
  45. # `assemble` instead for now.
  46. gradle --debug --no-daemon assemble > gradle.log 2>&1 || ( cat gradle.log; exit 1 )
  47. $rootdir/gen_gradle_deps_file.sh gradle.log
  48. mv gradle-dependencies-list.txt '[% dest_dir _ "/" _ c("filename") %]'
  49. [% ELSE %]
  50. # Prepare Glean dependencies for offline build
  51. tar -xf $rootdir/[% c('input_files_by_name/glean') %]
  52. # We need to set `LC_ALL` and `LANG` to something that is not ASCII as encoding
  53. # otherwise `click` barfs. See: https://click.palletsprojects.com/python3/
  54. export LC_ALL=C.UTF-8
  55. export LANG=C.UTF-8
  56. patch -p1 < $rootdir/mavenLocal.patch
  57. eval $(perl $rootdir/get-moz-build-date [% pc("fenix", "var/copyright_year") %] [% pc("fenix", "var/torbrowser_version") %])
  58. if [ -z $MOZ_BUILD_DATE ]
  59. then
  60. echo "MOZ_BUILD_DATE is not set"
  61. exit 1
  62. fi
  63. # Increase the maximum memory usage, for when compiling with --disable-install-strip
  64. gradle_args="--offline --no-daemon -Dmaven.repo.local=$gradle_repo -Dorg.gradle.jvmargs=-Xmx8g"
  65. # See taskcluster/scripts/toolchain/android-gradle-dependencies.sh at line 36.
  66. # We hit the same problem when we run online to discover dependencies, but
  67. # since it works also for offline builds, we just leave it here
  68. gradle $gradle_args support-sync-telemetry:assemble
  69. gradle $gradle_args assembleGecko -x lint
  70. gradle $gradle_args publish
  71. # We only need the archives and .pom files for now.
  72. find components -regex '.*[% c('var/android_components_version') %].\(aar\|jar\|pom\)' -exec cp --parents {} $distdir \;
  73. # Package
  74. cd $distdir
  75. # Package just the maven directory structure for easier replacement of
  76. # Mozilla's android-components.
  77. find components -type d -name maven -exec cp -rf {} [% project %] \;
  78. [% c('tar', {
  79. tar_src => [ project ],
  80. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  81. }) %]
  82. [% END %]