build 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. [% 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. # Put the Kotlin/Native compiler at the right place, see:
  24. # tor-browser-build#40217.
  25. kotlin_dir=/home/rbm/.konan
  26. mkdir $kotlin_dir
  27. find $gradle_repo -type f -name kotlin-native-prebuilt-linux*tar.gz -exec tar -C $kotlin_dir -xaf {} \;
  28. tar -C $distdir -xf [% c('input_files_by_name/application-services') %]
  29. # XXX: We could be smarter and just copy over the projects that are needed
  30. # according to the Gradle dependencies list.
  31. cp -rf $distdir/application-services/maven/org $gradle_repo
  32. [% END %]
  33. tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
  34. cd $builddir-[% c('version') %]
  35. patch -p1 < $rootdir/git.patch
  36. [% IF c("var/fetch_gradle_dependencies") %]
  37. # XXX: fetching deps for `assembleGeckoBeta -x lint` by using that same target
  38. # results in some missing dependencies for yet unknown reasons. Thus, we use
  39. # `assemble` instead for now.
  40. gradle --debug --no-daemon assemble > gradle.log 2>&1 || ( cat gradle.log; exit 1 )
  41. $rootdir/gen_gradle_deps_file.sh gradle.log
  42. mv gradle-dependencies-list.txt '[% dest_dir _ "/" _ c("filename") %]'
  43. [% ELSE %]
  44. # Prepare Glean dependencies for offline build
  45. tar -xf $rootdir/[% c('input_files_by_name/glean') %]
  46. # We need to set `LC_ALL` and `LANG` to something that is not ASCII as encoding
  47. # otherwise `click` barfs. See: https://click.palletsprojects.com/python3/
  48. export LC_ALL=C.UTF-8
  49. export LANG=C.UTF-8
  50. patch -p1 < $rootdir/mavenLocal.patch
  51. eval $(perl $rootdir/get-moz-build-date [% pc("fenix", "var/copyright_year") %] [% pc("fenix", "var/torbrowser_version") %])
  52. if [ -z $MOZ_BUILD_DATE ]
  53. then
  54. echo "MOZ_BUILD_DATE is not set"
  55. exit 1
  56. fi
  57. gradle_args="--offline --no-daemon -Dmaven.repo.local=$gradle_repo"
  58. gradle $gradle_args assembleGecko -x lint
  59. gradle $gradle_args publish
  60. # We only need the archives and .pom files for now.
  61. find components -regex '.*[% c('var/android_components_version') %].\(aar\|jar\|pom\)' -exec cp --parents {} $distdir \;
  62. # Package
  63. cd $distdir
  64. # Package just the maven directory structure for easier replacement of
  65. # Mozilla's android-components.
  66. find components -type d -name maven -exec cp -rf {} [% project %] \;
  67. [% c('tar', {
  68. tar_src => [ project ],
  69. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  70. }) %]
  71. [% END %]