build 3.7 KB

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