build 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. [% c("var/set_default_env") -%]
  3. [% pc('go', 'var/setup', { go_tarfile => c('input_files_by_name/go') }) %]
  4. [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
  5. [% IF c("var/linux") %]
  6. tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/binutils') %]
  7. export PATH="/var/tmp/dist/binutils/bin:$PATH"
  8. # The go-webrtc package sets _GLIBCXX_USE_CXX11_ABI=0 for compatibility with
  9. # the prebuilt libwebrtc-magic.a libraries. Since we build our own
  10. # libwebrtc-magic.a with the C++11 ABI, we have to undo that setting here,
  11. # using CGO_CXXFLAGS.
  12. export CGO_CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=1"
  13. [% END -%]
  14. distdir=/var/tmp/dist/[% project %]
  15. [% c("var/set_PTDIR_DOCSDIR") -%]
  16. mkdir -p $PTDIR $DOCSDIR
  17. [% IF c("var/osx") %]
  18. export CGO_ENABLED=1
  19. export CGO_CFLAGS="[% c("var/FLAGS") %] -mmacosx-version-min=10.7"
  20. export CGO_CXXFLAGS="[% c("var/FLAGS") %] -stdlib=libc++ -mmacosx-version-min=10.7"
  21. export CGO_LDFLAGS="[% c("var/FLAGS") %] -stdlib=libc++ -mmacosx-version-min=10.7"
  22. export CC="$clangdir/bin/clang"
  23. export CXX="$clangdir/bin/clang++"
  24. [% END %]
  25. tar -C /var/tmp/dist -xf [% c('input_files_by_name/go-webrtc') %]
  26. tar -C /var/tmp/dist -xf [% c('input_files_by_name/uniuri') %]
  27. tar -C /var/tmp/dist -xf [% c('input_files_by_name/goptlib') %]
  28. mkdir -p /var/tmp/build
  29. tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
  30. cd /var/tmp/build/[% project %]-[% c('version') %]
  31. mkdir -p "$GOPATH/src/git.torproject.org/pluggable-transports"
  32. ln -sf "$PWD" "$GOPATH/src/git.torproject.org/pluggable-transports/snowflake.git"
  33. cd client
  34. [% IF c("var/osx") -%]
  35. # Without faketime, snowflake-client would contain the timestamp of the
  36. # temporary client.a file created during "go build".
  37. # The -tmpdir flag overrides what would otherwise be a randomly generated
  38. # path, /tmp/go-link-RANDOMNUM/go.o.
  39. mkdir -p /var/tmp/go-link.tmpdir
  40. [% c("var/faketime") %] go build -ldflags '-s -tmpdir /var/tmp/go-link.tmpdir'
  41. [% ELSE -%]
  42. go build -ldflags '-s'
  43. [% END -%]
  44. cp -a client[% IF c("var/windows") %].exe[% END %] $PTDIR/snowflake-client[% IF c("var/windows") %].exe[% END %]
  45. cd ..
  46. cp -a README.md LICENSE $DOCSDIR
  47. cd $distdir
  48. [% c('tar', {
  49. tar_src => [ '.' ],
  50. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  51. }) %]