build 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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/[% project %]
  5. builddir=/var/tmp/build/[% project %]
  6. mkdir $distdir
  7. mkdir /var/tmp/build
  8. tar -C $GRADLE_HOME -xf $rootdir/[% c('input_files_by_name/gradle') %]
  9. cd /var/tmp/dist
  10. [% FOREACH arch = ['armv7', 'aarch64', 'x86', 'x86_64', 'linux-x86_64'] -%]
  11. tar -xf $rootdir/[% c('input_files_by_name/nss-' _ arch) %]
  12. mv nss nss-[% arch %]
  13. tar -xf $rootdir/[% c('input_files_by_name/sqlcipher-' _ arch) %]
  14. mv sqlcipher sqlcipher-[% arch %]
  15. [% END -%]
  16. tar -xf $rootdir/[% c('input_files_by_name/rust') %]
  17. tar -xf $rootdir/[% c('input_files_by_name/uniffi-rs') %]
  18. export PATH=/var/tmp/dist/rust/bin:/var/tmp/dist/uniffi-rs:$PATH
  19. cd $rootdir
  20. export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
  21. [% IF !c('var/fetch_gradle_dependencies') %]
  22. gradle_repo=$rootdir/[% c('input_files_by_name/gradle-dependencies') %]
  23. cp -r $gradle_repo/dl/android/maven2/* $gradle_repo
  24. cp -r $gradle_repo/m2/* $gradle_repo
  25. cp -r $gradle_repo/maven2/* $gradle_repo
  26. [% END %]
  27. tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
  28. # Prepare the offline build.
  29. # Move the directory for hardcoding the path in .cargo/config.
  30. mv /var/tmp/build/[% project %]-[% c('version') %] $builddir
  31. tar -C $builddir -xjf application-services-vendor-[% c('version') %].tar.bz2
  32. cd $builddir
  33. # Make sure our vendored crates are used for offline builds.
  34. cat >> .cargo/config << 'EOF'
  35. [source.crates-io]
  36. replace-with = "vendored-sources"
  37. [source.vendored-sources]
  38. directory = "/var/tmp/build/application-services/vendor"
  39. [net]
  40. offline=true
  41. EOF
  42. # Move NSS and SQLCipher to the right place
  43. # XXX: Maybe merge with the loop above.
  44. archs="armv7 aarch64 x86 x86_64 linux-x86_64"
  45. for a in $archs
  46. do
  47. if [ "$a" == "armv7" ]
  48. then
  49. mkdir -p libs/android/armeabi-v7a
  50. mv /var/tmp/dist/nss-$a libs/android/armeabi-v7a/nss
  51. mv /var/tmp/dist/sqlcipher-$a libs/android/armeabi-v7a/sqlcipher
  52. elif [ "$a" == "aarch64" ]
  53. then
  54. mkdir -p libs/android/arm64-v8a
  55. mv /var/tmp/dist/nss-$a libs/android/arm64-v8a/nss
  56. mv /var/tmp/dist/sqlcipher-$a libs/android/arm64-v8a/sqlcipher
  57. elif [ "$a" == "linux-x86_64" ]
  58. then
  59. mkdir -p libs/desktop/linux-x86-64
  60. mv /var/tmp/dist/nss-$a libs/desktop/linux-x86-64/nss
  61. mv /var/tmp/dist/sqlcipher-$a libs/desktop/linux-x86-64/sqlcipher
  62. else
  63. mkdir -p libs/android/$a
  64. mv /var/tmp/dist/nss-$a libs/android/$a/nss
  65. mv /var/tmp/dist/sqlcipher-$a libs/android/$a/sqlcipher
  66. fi
  67. done
  68. patch -p1 < $rootdir/no-git.patch
  69. export RUST_ANDROID_GRADLE_PYTHON_COMMAND=python3
  70. [% IF c('var/fetch_gradle_dependencies') %]
  71. # XXX: `assemble` is still not enough to see all fetched dependencies via
  72. # Gradle's --debug. See: tor-browser-build#40056.
  73. gradle --debug --no-daemon assemble > gradle.log 2>&1 || ( cat gradle.log; exit 1 )
  74. $rootdir/gen_gradle_deps_file.sh gradle.log
  75. mv gradle-dependencies-list.txt '[% dest_dir _ "/" _ c("filename") %]'
  76. [% ELSE %]
  77. # Prepare Glean dependencies for offline build
  78. tar -xf $rootdir/[% c('input_files_by_name/glean-wheels') %]
  79. # We need to set `LC_ALL` and `LANG` to something that is not ASCII as encoding
  80. # otherwise `click` barfs. See: https://click.palletsprojects.com/python3/
  81. export LC_ALL=C.UTF-8
  82. export LANG=C.UTF-8
  83. patch -p1 < $rootdir/mavenLocal.patch
  84. gradle_flags="--offline --no-daemon -Dmaven.repo.local=$gradle_repo"
  85. gradle $gradle_flags assembleRelease
  86. gradle $gradle_flags publish
  87. cd build
  88. find maven -regex '.*[0-9].\(aar\|pom\)' -exec cp --parents {} $distdir \;
  89. cd /var/tmp/dist
  90. [% c('tar', {
  91. tar_src => [ project ],
  92. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  93. }) %]
  94. [% END %]