config 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. # vim: filetype=yaml sw=2
  2. version: 1.19.4
  3. filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'
  4. container:
  5. use_container: 1
  6. var:
  7. go14_version: 1.4.3
  8. GOHOSTARCH: amd64
  9. setup: |
  10. mkdir -p /var/tmp/dist
  11. tar -C /var/tmp/dist -xf $rootdir/[% c("go_tarfile") %]
  12. [% IF pc(c("origin_project"), "var/no_crosscompile") -%]
  13. export GOOS=linux
  14. export GOARCH=[% c("var/GOHOSTARCH") %]
  15. [% ELSE -%]
  16. export GOOS=[% c("var/GOOS") %]
  17. export GOARCH=[% c("var/GOARCH") %]
  18. [% END -%]
  19. # Run in GOPATH mode: https://golang.org/cmd/go/#hdr-Module_support. (see:
  20. # #32027)
  21. export GO111MODULE=off
  22. export GOPATH=/var/tmp/dist/gopath
  23. export PATH=/var/tmp/dist/go/bin:/var/tmp/dist/gopath/bin:"$PATH"
  24. [% IF c("var/linux") -%]
  25. export CGO_LDFLAGS_ALLOW="-z|noexecstack"
  26. export CGO_LDFLAGS="-z noexecstack"
  27. [% END -%]
  28. [% IF c("var/linux-i686") -%]
  29. export CGO_ENABLED=1
  30. [% END -%]
  31. export GOTMPDIR=/var/tmp/build/go-tmp
  32. mkdir -p "$GOTMPDIR"
  33. # Template build script for building a go library.
  34. # This can be called as projects/go/var/build_go_lib.
  35. # You need to define /var/go_lib, and optionally var/go_lib_install as
  36. # a list of install targets.
  37. build_go_lib: |
  38. #!/bin/bash
  39. [% c("var/set_default_env") -%]
  40. [% pc('go', 'var/setup', { go_tarfile => c('input_files_by_name/go') }) %]
  41. distdir=/var/tmp/dist/[% project %]
  42. mkdir -p /var/tmp/build
  43. tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
  44. [% FOREACH dep = c("var/go_lib_deps") -%]
  45. tar -C /var/tmp/dist -xf [% c('input_files_by_name/' _ dep) %]
  46. [% END -%]
  47. mkdir -p $(dirname "$GOPATH/src/[% c("var/go_lib") %]")
  48. mv /var/tmp/build/[% project %]-[% c('version') %] "$GOPATH/src/[% c("var/go_lib") %]"
  49. cd "$GOPATH/src/[% c("var/go_lib") %]"
  50. for p in $(ls -1 $rootdir/*.patch 2> /dev/null | sort)
  51. do
  52. patch -p1 < $p
  53. done
  54. # Run in GOPATH mode: https://golang.org/cmd/go/#hdr-Module_support. (see:
  55. # #32027)
  56. export GO111MODULE=off
  57. [% IF c("var/build_go_lib_pre"); GET c("var/build_go_lib_pre"); END; -%]
  58. [% IF c("var/go_lib_install") -%]
  59. [% FOREACH inst IN c("var/go_lib_install") %]
  60. go install [% inst %]
  61. [% END %]
  62. [% ELSE %]
  63. go install [% c("var/go_lib") %]
  64. [% END %]
  65. cd /var/tmp/dist
  66. [% c('tar', {
  67. tar_src => [ 'gopath' ],
  68. tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
  69. }) %]
  70. targets:
  71. windows:
  72. var:
  73. GOOS: windows
  74. windows-i686:
  75. var:
  76. GOARCH: 386
  77. windows-x86_64:
  78. var:
  79. GOARCH: amd64
  80. macos-x86_64:
  81. var:
  82. GOARCH: amd64
  83. macos-aarch64:
  84. var:
  85. GOARCH: arm64
  86. macos:
  87. var:
  88. GOOS: darwin
  89. linux:
  90. var:
  91. GOOS: linux
  92. linux-x86_64:
  93. var:
  94. GOARCH: amd64
  95. linux-i686:
  96. var:
  97. GOARCH: 386
  98. linux-armhf:
  99. var:
  100. GOARCH14: arm
  101. GOARCH: arm
  102. linux-arm64:
  103. var:
  104. GOHOSTARCH: arm64
  105. GOARCH14: arm
  106. GOARCH: arm64
  107. android:
  108. var:
  109. GOOS: android
  110. android-x86:
  111. var:
  112. GOARCH: 386
  113. android-x86_64:
  114. var:
  115. GOARCH: amd64
  116. android-armv7:
  117. var:
  118. GOARCH: arm
  119. android-aarch64:
  120. var:
  121. GOARCH: arm64
  122. input_files:
  123. - project: container-image
  124. - name: '[% c("var/compiler") %]'
  125. project: '[% c("var/compiler") %]'
  126. enable: '[% ! c("var/linux") %]'
  127. - URL: 'https://golang.org/dl/go[% c("version") %].src.tar.gz'
  128. name: go
  129. sha256sum: eda74db4ac494800a3e66ee784e495bfbb9b8e535df924a8b01b1a8028b7f368
  130. - URL: 'https://golang.org/dl/go[% c("var/go14_version") %].src.tar.gz'
  131. name: go14
  132. sha256sum: 9947fc705b0b841b5938c48b22dc33e9647ec0752bae66e50278df4f23f64959
  133. - filename: 0001-Use-fixed-go-build-tmp-directory.patch
  134. enable: '[% c("var/android") %]'
  135. - filename: go-aarch64.patch