build 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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*.aar -exec cp -f $distdir/geckoview/geckoview*.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. patch -p1 < $rootdir/git.patch
  35. [% IF c("var/fetch_gradle_dependencies") %]
  36. # XXX: fetching deps for `assembleGeckoBeta -x lint` by using that same target
  37. # results in some missing dependencies for yet unknown reasons. Thus, we use
  38. # `assemble` instead for now.
  39. gradle --debug --no-daemon assemble > gradle.log 2>&1 || ( cat gradle.log; exit 1 )
  40. $rootdir/gen_gradle_deps_file.sh gradle.log
  41. mv gradle-dependencies-list.txt '[% dest_dir _ "/" _ c("filename") %]'
  42. [% ELSE %]
  43. # Prepare Glean dependencies for offline build
  44. tar -xf $rootdir/[% c('input_files_by_name/glean') %]
  45. # We need to set `LC_ALL` and `LANG` to something that is not ASCII as encoding
  46. # otherwise `click` barfs. See: https://click.palletsprojects.com/python3/
  47. export LC_ALL=C.UTF-8
  48. export LANG=C.UTF-8
  49. patch -p1 < $rootdir/mavenLocal.patch
  50. eval $(perl $rootdir/get-moz-build-date [% pc("fenix", "var/copyright_year") %] [% pc("fenix", "var/torbrowser_version") %])
  51. if [ -z $MOZ_BUILD_DATE ]
  52. then
  53. echo "MOZ_BUILD_DATE is not set"
  54. exit 1
  55. fi
  56. gradle_args="--offline --no-daemon -Dmaven.repo.local=$gradle_repo"
  57. gradle $gradle_args assembleGecko -x lint
  58. gradle $gradle_args publish
  59. # We only need the archives and .pom files for now.
  60. find components -regex '.*[% c('var/android_components_version') %].\(aar\|jar\|pom\)' -exec cp --parents {} $distdir \;
  61. # Package
  62. cd $distdir
  63. # Package just the maven directory structure for easier replacement of
  64. # Mozilla's android-components.
  65. find components -type d -name maven -exec cp -rf {} [% project %] \;
  66. [% c('tar', {
  67. tar_src => [ project ],
  68. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  69. }) %]
  70. [% END %]