build 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. [% c("var/set_default_env") -%]
  3. output_dir=[% dest_dir %]/[% c('filename') %]
  4. gradle_repo=$rootdir/[% c('input_files_by_name/gradle-dependencies') %]
  5. # The download script assumes artifact package name is the complete URL path.
  6. # In some cases this is incorrect, so copy those artifacts to correct location
  7. cp -r $gradle_repo/guardianproject/gpmaven/master/* $gradle_repo
  8. cp -r $gradle_repo/dl/android/maven2/* $gradle_repo
  9. cp -r $gradle_repo/maven2/* $gradle_repo
  10. mkdir -p /var/tmp/build $output_dir
  11. [% pc(c('var/compiler'), 'var/setup', {
  12. compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')),
  13. gradle_tarfile => c("input_files_by_name/gradle"),
  14. }) %]
  15. tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
  16. # Patch projects
  17. cd /var/tmp/build/[% project %]-[% c('version') %]
  18. # Gradle patch provided so that when generating a gradle dependency list, the
  19. # build will pull down the correct android tool versions
  20. patch -p1 < $rootdir/gradle.patch
  21. patch -p1 < $rootdir/0001-Bug-33931-Filter-bridges-in-stream-by-type.patch
  22. patch -p1 < $rootdir/0001-Bug-30318-Add-snowflake-support.patch
  23. [% FOREACH arch = ['armv7', 'aarch64', 'x86', 'x86_64'] -%]
  24. # Extract tor-expert-bundle
  25. tebdir=$rootdir/tor-expert-bundle-[% arch %]
  26. mkdir $tebdir
  27. tar -C $tebdir -xf $rootdir/[% c('input_files_by_name/tor-expert-bundle-' _ arch) %]
  28. ptdir=$tebdir/tor/pluggable_transports
  29. # Overwrite the obfs4proxy binary provided by Pluto and add Snowflake
  30. [% IF arch == "armv7" -%]
  31. cp $ptdir/obfs4proxy external/pluto/bin/armeabi-v7a/
  32. cp $ptdir/obfs4proxy external/pluto/bin/armeabi/
  33. cp $ptdir/snowflake-client external/pluto/bin/armeabi-v7a/
  34. cp $ptdir/snowflake-client external/pluto/bin/armeabi/
  35. [% ELSIF arch == "aarch64" -%]
  36. cp $ptdir/obfs4proxy external/pluto/bin/arm64-v8a/
  37. cp $ptdir/snowflake-client external/pluto/bin/arm64-v8a/
  38. [% ELSE -%]
  39. cp $ptdir/obfs4proxy external/pluto/bin/[% arch %]/
  40. cp $ptdir/snowflake-client external/pluto/bin/[% arch %]/
  41. [% END -%]
  42. [% END -%]
  43. # Build Android Libraries and Apps
  44. gradle --offline --no-daemon -P androidplugin=3.6.0 -Dmaven.repo.local=$gradle_repo assembleRelease -x lint
  45. # Package
  46. cp universal/build/libs/* android/build/outputs/aar/* $output_dir