Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

build-release.sh 7.6 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
  1. #!/usr/bin/env bash
  2. #
  3. # Script that builds a GMT release and makes the compressed tarballs.
  4. # If run under macOS it also builds the macOS Bundle. For now it
  5. # must be run in a MacPort installation for the bundle to be built.
  6. #
  7. # Requirements in addition to libraries and tools to build GMT:
  8. # 1) pngquant for squeezing PNG files down in size (package pngquant)
  9. # 2) GMT_GSHHG_SOURCE and GMT_DCW_SOURCE environmental parameters set
  10. # 3) A ghostscript version we can include in the macOS bundle [MacPort]
  11. # 4) sphinx-build
  12. # 5) grealpath (package coreutils)
  13. # 6) GNU tar (package gnutar)
  14. # 7) For OpenMP: clang-mp-11 and clang++-mp-11 must be installed and in path (package clang-11)
  15. #
  16. # Notes:
  17. # 1. CMAKE_INSTALL_PATH, EXEPLUSLIBS, and EXESHARED in build-macos-external-list.sh may need to be changed for different users.
  18. # 2. Settings for GS_LIB, PROJ_LIB etc in cmake/dist/startup_macosx.sh.in may need to be updated as new gs,proj.gm releases are issued
  19. CLANG_V=11 # Current Clang version to use
  20. # Temporary ftp site for pre-release files:
  21. GMT_FTP_URL=ftp.soest.hawaii.edu
  22. GMT_FTP_DIR=/export/ftp1/ftp/pub/gmtrelease
  23. reset_config() {
  24. rm -f ${TOPDIR}/cmake/ConfigUser.cmake
  25. if [ -f ${TOPDIR}/cmake/ConfigUser.cmake.orig ]; then # Restore what we had
  26. mv -f ${TOPDIR}/cmake/ConfigUser.cmake.orig ${TOPDIR}/cmake/ConfigUser.cmake
  27. fi
  28. }
  29. abort_build() { # Called when we abort this script via Crtl-C
  30. echo "build-release.sh: Detected Ctrl-C - aborting" >&2
  31. reset_config
  32. rm -rf ${TOPDIR}/build
  33. exit -1
  34. }
  35. TOPDIR=$(pwd)
  36. do_ftp=0
  37. if [ "X${1}" = "X-p" ]; then
  38. do_ftp=1
  39. elif [ "X${1}" = "X-m" ]; then
  40. do_ftp=2
  41. elif [ $# -gt 0 ]; then
  42. cat <<- EOF >&2
  43. Usage: build-release.sh [-p|m]
  44. build-release.sh must be run from top-level gmt directory.
  45. Will create the release compressed tarballs and (under macOS) the bundle.
  46. Requires you have set GMT_PACKAGE_VERSION_* and GMT_PUBLIC_RELEASE in cmake/ConfigDefaults.cmake.
  47. Requires GMT_GSHHG_SOURCE and GMT_DCW_SOURCE to be set in the environment.
  48. Passing -p means we copy the files to the SOEST ftp directory
  49. Passing -m means only copy the macOS bundle to the SOEST ftp directory
  50. [Default places no files in the SOEST ftp directory]
  51. EOF
  52. exit 1
  53. fi
  54. if [ ! -d admin ]; then
  55. echo "build-release.sh: Must be run from top-level gmt directory" >&2
  56. exit 1
  57. fi
  58. # pngquant is need to optimize images
  59. if ! [ -x "$(command -v pngquant)" ]; then
  60. echo 'build-release.sh: Error: pngquant is not found in your search PATH.' >&2
  61. exit 1
  62. fi
  63. # sphinx-build is need to build the docs
  64. if ! [ -x "$(command -v sphinx-build)" ]; then
  65. echo 'build-release.sh: Error: sphinx-build is not found in your search PATH.' >&2
  66. exit 1
  67. fi
  68. # grealpath is need to build the dependency list of libs
  69. if ! [ -x "$(command -v grealpath)" ]; then
  70. echo 'build-release.sh: Error: grealpath is not found in your search PATH.' >&2
  71. exit 1
  72. fi
  73. # gnutar is need to build the tarballs
  74. if ! [ -x "$(command -v gnutar)" ]; then
  75. echo 'build-release.sh: Error: gnutar is not found in your search PATH.' >&2
  76. exit 1
  77. fi
  78. # 0. Make sure GMT_GSHHG_SOURCE and GMT_DCW_SOURCE are set in the environment
  79. if [ "X${GMT_GSHHG_SOURCE}" = "X" ]; then
  80. echo "build-release.sh: Need to setenv GMT_GSHHG_SOURCE to point to directory with GSHHG files" >&2
  81. exit 1
  82. fi
  83. if [ "X${GMT_DCW_SOURCE}" = "X" ]; then
  84. echo "build-release.sh: Need to setenv GMT_DCW_SOURCE to point to directory with DCW files" >&2
  85. exit 1
  86. fi
  87. if [ $(egrep -c '^set \(GMT_PUBLIC_RELEASE TRUE\)' cmake/ConfigDefault.cmake) -eq 0 ]; then
  88. echo "build-release.sh: Need to set GMT_PUBLIC_RELEASE to TRUE in cmake/ConfigDefault.cmake" >&2
  89. exit 1
  90. fi
  91. G_ver=$(gs --version)
  92. echo "build-release.sh: You will be including Ghostscript version $G_ver"
  93. echo "build-release.sh: Running admin/gs-check.sh to ensure it passes our transparency test" >&2
  94. err=$(admin/gs_check.sh | grep Total | awk '{print $3}')
  95. if [ "X${err}" = "X0.0" ]; then
  96. echo "build-release.sh: Ghostscript version $G_ver passed the test - will be included" >&2
  97. else
  98. echo "build-release.sh: Ghostscript version $G_ver failed the test - install another gs" >&2
  99. exit 1
  100. fi
  101. trap abort_build SIGINT
  102. # 1. Set basic ConfigUser.cmake file for a release build
  103. if [ -f cmake/ConfigUser.cmake ]; then
  104. cp cmake/ConfigUser.cmake cmake/ConfigUser.cmake.orig
  105. fi
  106. cp -f admin/ConfigReleaseBuild.cmake cmake/ConfigUser.cmake
  107. # 2a. Make build dir and configure it
  108. rm -rf build
  109. mkdir build
  110. # 2b. Build list of external programs and shared libraries
  111. admin/build-macos-external-list.sh > build/add_macOS_cpack.txt
  112. if [ $? -ne 0 ]; then
  113. echo 'build-release.sh: Error: Requires either MacPorts of HomeBrew' >&2
  114. exit 1
  115. fi
  116. cd build
  117. # 2c. Set CMake cache for MP build:
  118. COMPC=$(which clang-mp-${CLANG_V})
  119. COMPG=$(which clang++-mp-${CLANG_V})
  120. echo "build-release.sh: Configure and build tarballs" >&2
  121. if [ "X${COMPC}" = "X" ]; then # No clang support, no OpenMP
  122. echo 'build-release.sh: Warning: clang-mp-${CLANG_V} is not found in your search PATH - OpenMP will be disabled.' >&2
  123. cmake -G Ninja ..
  124. else
  125. # clang-mp-${CLANG_V} is needed to build with OpenMP
  126. if ! [ -x "$(command -v clang-mp-${CLANG_V})" ]; then
  127. echo 'build-release.sh: Error: clang-mp-${CLANG_V} is not found in your search PATH.' >&2
  128. exit 1
  129. fi
  130. # clang++-mp-${CLANG_V} is needed to build with OpenMP
  131. if ! [ -x "$(command -v clang++-mp-${CLANG_V})" ]; then
  132. echo 'build-release.sh: Error: clang++-mp-${CLANG_V} is not found in your search PATH.' >&2
  133. exit 1
  134. fi
  135. cat <<- EOF > cache-mp-clang.cmake
  136. # Cache settings for building the macOS release with Clang and OpenMP
  137. # This cache file is set for the binary paths of macports
  138. #
  139. SET ( CMAKE_C_COMPILER "/opt/local/bin/clang-mp-${CLANG_V}" CACHE STRING "CLANG MP C compiler" )
  140. SET ( CMAKE_CXX_COMPILER "/opt/local/bin/clang++-mp-${CLANG_V}" CACHE STRING "CLANG MP C++ compiler" )
  141. SET ( CMAKE_C_FLAGS -flax-vector-conversions CACHE STRING "C FLAGS")
  142. SET ( CMAKE_C_FLAGS_DEBUG -flax-vector-conversions CACHE STRING "C FLAGS DEBUG")
  143. SET ( CMAKE_C_FLAGS_RELEASE -flax-vector-conversions CACHE STRING "C FLAGS RELEASE")
  144. SET ( OpenMP_C_FLAGS -flax-vector-conversions CACHE STRING "C FLAGS OPENMP")
  145. EOF
  146. cmake -G Ninja -C cache-mp-clang.cmake ..
  147. fi
  148. # 3. Build the release and the tarballs
  149. cmake --build . --target gmt_release
  150. cmake --build . --target gmt_release_tar
  151. # 4. get the version string
  152. Version=$(src/gmt --version)
  153. # 5. Remove the uncompressed tarball
  154. rm -f gmt-${Version}-src.tar
  155. # 6. Install executables before building macOS Bundle
  156. cmake --build . --target install
  157. if [ $(uname) = "Darwin" ]; then
  158. echo "build-release.sh: Build macOS bundle" >&2
  159. # 7. Build the macOS Bundle
  160. cpack -G Bundle
  161. fi
  162. # 8. Report sha256 hash
  163. echo "build-release.sh: Report sha256sum per file" >&2
  164. shasum -a 256 gmt-${Version}-*
  165. # 9. Replace temporary ConfigReleaseBuild.cmake file with the original file
  166. reset_config
  167. # 10. Paul or Meghan may place the candidate products on the pwessel/release ftp site
  168. if [ $do_ftp -eq 1 ]; then # Place file in pwessel SOEST ftp release directory and set permissions
  169. type=$(uname -m)
  170. echo "build-release.sh: Placing gmt-${Version}-src.tar.* on the ftp site" >&2
  171. scp gmt-${Version}-src.tar.* ${GMT_FTP_URL}:${GMT_FTP_DIR}
  172. if [ -f gmt-${Version}-darwin-${type}.dmg ]; then
  173. echo "build-release.sh: Placing gmt-${Version}-darwin-${type}.dmg on the ftp site" >&2
  174. scp gmt-${Version}-darwin-${type}.dmg ${GMT_FTP_URL}:${GMT_FTP_DIR}
  175. fi
  176. ssh ${USER}@${GMT_FTP_URL} "chmod o+r,g+rw ${GMT_FTP_DIR}/gmt-*"
  177. fi
  178. if [ $do_ftp -eq 2 ]; then # Place M1 bundle file on ftp
  179. type=$(uname -m)
  180. if [ -f gmt-${Version}-darwin-${type}.dmg ]; then
  181. echo "build-release.sh: Placing gmt-${Version}-darwin-${type}.dmg on the ftp site" >&2
  182. scp gmt-${Version}-darwin-${type}.dmg ${GMT_FTP_URL}:${GMT_FTP_DIR}
  183. fi
  184. ssh ${USER}@${GMT_FTP_URL} "chmod o+r,g+rw ${GMT_FTP_DIR}/gmt-*"
  185. fi
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...