build 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. cp -r $gradle_repo/plugins-release/* $gradle_repo
  11. mkdir -p /var/tmp/build $output_dir
  12. [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
  13. tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
  14. # Patch projects
  15. cd /var/tmp/build/[% project %]-[% c('version') %]
  16. # Gradle patch provided so that when generating a gradle dependency list, the
  17. # build will pull down the correct android tool versions
  18. patch -p1 < $rootdir/gradle.patch
  19. patch -p1 < $rootdir/0001-Bug-33931-Filter-bridges-in-stream-by-type.patch
  20. patch -p1 < $rootdir/0001-Bug-30318-Add-snowflake-support.patch
  21. [% FOREACH arch = ['armv7', 'aarch64', 'x86', 'x86_64'] -%]
  22. # Extract obfs4proxy from TorBrowser/Tor/PluggableTransports/obfs4proxy
  23. tar --strip-components=4 -xf $rootdir/[% c('input_files_by_name/obfs4-' _ arch) %]
  24. # Extract snowflake from TorBrowser/Tor/PluggableTransports/snowflake
  25. tar --strip-components=4 -xf $rootdir/[% c('input_files_by_name/snowflake-' _ arch) %]
  26. # Overwrite the obfs4proxy binary provided by Pluto and add Snowflake
  27. [% IF arch == "armv7" -%]
  28. cp obfs4proxy external/pluto/bin/armeabi-v7a/
  29. cp obfs4proxy external/pluto/bin/armeabi/
  30. cp snowflake-client external/pluto/bin/armeabi-v7a/
  31. cp snowflake-client external/pluto/bin/armeabi/
  32. [% ELSIF arch == "aarch64" -%]
  33. cp obfs4proxy external/pluto/bin/arm64-v8a/
  34. cp snowflake-client external/pluto/bin/arm64-v8a/
  35. [% ELSE -%]
  36. cp obfs4proxy external/pluto/bin/[% arch %]/
  37. cp snowflake-client external/pluto/bin/[% arch %]/
  38. [% END -%]
  39. rm obfs4proxy
  40. rm snowflake-client
  41. [% END -%]
  42. # Build Android Libraries and Apps
  43. gradle --offline --no-daemon -P androidplugin=3.6.0 -Dmaven.repo.local=$gradle_repo assembleRelease -x lint
  44. # Package
  45. cp universal/build/libs/* android/build/outputs/aar/* $output_dir