build 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. [% END -%]
  9. distdir=/var/tmp/dist/[% project %]
  10. [% c("var/set_PTDIR_DOCSDIR") -%]
  11. mkdir -p $PTDIR $DOCSDIR
  12. [% IF c("var/osx") %]
  13. export CGO_ENABLED=1
  14. export CGO_CFLAGS="[% c("var/FLAGS") %] -mmacosx-version-min=10.7"
  15. export CGO_CXXFLAGS="[% c("var/FLAGS") %] -stdlib=libc++ -mmacosx-version-min=10.7"
  16. export CGO_LDFLAGS="[% c("var/FLAGS") %] -stdlib=libc++ -mmacosx-version-min=10.7"
  17. export CC="$clangdir/bin/clang"
  18. export CXX="$clangdir/bin/clang++"
  19. [% END %]
  20. tar -C /var/tmp/dist -xf [% c('input_files_by_name/go-webrtc') %]
  21. tar -C /var/tmp/dist -xf [% c('input_files_by_name/uniuri') %]
  22. tar -C /var/tmp/dist -xf [% c('input_files_by_name/goptlib') %]
  23. mkdir -p /var/tmp/build
  24. tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
  25. cd /var/tmp/build/[% project %]-[% c('version') %]
  26. cd client
  27. [% IF c("var/osx") -%]
  28. # Without faketime, snowflake-client would contain the timestamp of the
  29. # temporary client.a file created during "go build".
  30. [% c("var/faketime") %] go build -ldflags '-s'
  31. [% ELSE -%]
  32. go build -ldflags '-s'
  33. [% END -%]
  34. [% IF c("var/osx") -%]
  35. # Hack: Overwrite variable absolute paths embedded in the binary. clang 3.8.0
  36. # on Darwin embeds such paths and the issue is unsolved in upstream Go as of
  37. # 2016-06-28:
  38. # https://github.com/golang/go/issues/9206#issuecomment-310476743
  39. # The two kinds of paths are ("000000000" stands for 9 random digits):
  40. # /tmp/go-build000000000
  41. # /tmp/go-link-000000000
  42. # Such paths are the output of ioutil.TempDir("", "go-build") and
  43. # ioutil.TempDir("", "go-link-").
  44. cp -a client client.stomped
  45. sed -i -E -e 's#(/tmp/go-build|/tmp/go-link-)[0-9]{9}/#\1XXXXXXXXX/#g' client.stomped
  46. # Sanity check: make sure the file actually changed. If it did not, it could
  47. # mean that a change in go or clang has made this step unnecessary.
  48. if cmp client client.stomped
  49. then
  50. echo "No paths replaced in snowflake-client. Maybe the replacement failed or is no longer needed."
  51. echo "Check projects/snowflake/build"
  52. exit 1
  53. fi
  54. mv -f client.stomped client
  55. [% END -%]
  56. cp -a client[% IF c("var/windows") %].exe[% END %] $PTDIR/snowflake-client[% IF c("var/windows") %].exe[% END %]
  57. cd ..
  58. cp -a README.md LICENSE $DOCSDIR
  59. cd $distdir
  60. [% c('tar', {
  61. tar_src => [ '.' ],
  62. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  63. }) %]