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 4.8 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
  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.
  5. #
  6. # Requirements in addition to libraries and tools to build GMT:
  7. # 1) pngquant for squeezing PNG files down in size
  8. # 2) GMT_GSHHG_SOURCE and GMT_DCW_SOURCE environmental parameters set
  9. # 3) A ghostscript version we can include in the macOS bundle [MacPort]
  10. # 4) sphinx-build
  11. # 5) grealpath (package coreutils)
  12. # 6) GNU tar (package gnutar)
  13. reset_config() {
  14. rm -f ${TOPDIR}/cmake/ConfigUser.cmake
  15. if [ -f ${TOPDIR}/cmake/ConfigUser.cmake.orig ]; then # Restore what we had
  16. mv -f ${TOPDIR}/cmake/ConfigUser.cmake.orig ${TOPDIR}/cmake/ConfigUser.cmake
  17. fi
  18. }
  19. abort_build() { # Called when we abort this script via Crtl-C
  20. echo "build-release.sh: Detected Ctrl-C - aborting" >&2
  21. reset_config
  22. rm -rf ${TOPDIR}/build
  23. exit -1
  24. }
  25. TOPDIR=$(pwd)
  26. if [ $# -gt 0 ]; then
  27. cat <<- EOF >&2
  28. Usage: build-release.sh
  29. build-release.sh must be run from top-level gmt directory.
  30. Will create the release compressed tarballs and (under macOS) the bundle.
  31. Requires you have set GMT_PACKAGE_VERSION_* and GMT_PUBLIC_RELEASE in cmake/ConfigDefaults.cmake.
  32. Requires GMT_GSHHG_SOURCE and GMT_DCW_SOURCE to be set in the environment.
  33. EOF
  34. exit 1
  35. fi
  36. if [ ! -d cmake ]; then
  37. echo "build-release.sh: Must be run from top-level gmt directory" >&2
  38. exit 1
  39. fi
  40. # pngquant is need to optimize images
  41. if ! [ -x "$(command -v gmt)" ]; then
  42. echo 'build-release.sh: Error: pngquant is not found in your search PATH.' >&2
  43. exit 1
  44. fi
  45. # 0. Make sure GMT_GSHHG_SOURCE and GMT_DCW_SOURCE are set in the environment
  46. if [ "X${GMT_GSHHG_SOURCE}" = "X" ]; then
  47. echo "build-release.sh: Need to setenv GMT_GSHHG_SOURCE to point to directory with GSHHG files" >&2
  48. exit 1
  49. fi
  50. if [ "X${GMT_DCW_SOURCE}" = "X" ]; then
  51. echo "build-release.sh: Need to setenv GMT_DCW_SOURCE to point to directory with DCW files" >&2
  52. exit 1
  53. fi
  54. if [ $(egrep -c '^set \(GMT_PUBLIC_RELEASE TRUE\)' cmake/ConfigDefault.cmake) -eq 0 ]; then
  55. echo "build-release.sh: Need to set GMT_PUBLIC_RELEASE to TRUE in cmake/ConfigDefault.cmake" >&2
  56. exit 1
  57. fi
  58. G_ver=$(gs --version)
  59. echo "build-release.sh: You will be including Ghostscript version $G_ver"
  60. echo "build-release.sh: Running admin/gs-check.sh to ensure it passes our transparency test" >&2
  61. err=$(admin/gs_check.sh | grep Total | awk '{print $3}')
  62. if [ "X${err}" = "X0.0" ]; then
  63. echo "build-release.sh: Ghostscript version $G_ver passed the test - will be included" >&2
  64. else
  65. echo "build-release.sh: Ghostscript version $G_ver failed the test - install another gs" >&2
  66. exit 1
  67. fi
  68. # 1. Set basic ConfigUser.cmake file for a release build
  69. if [ -f cmake/ConfigUser.cmake ]; then
  70. cp cmake/ConfigUser.cmake cmake/ConfigUser.cmake.orig
  71. fi
  72. cp -f admin/ConfigReleaseBuild.cmake cmake/ConfigUser.cmake
  73. trap abort_build SIGINT
  74. # 2a. Make build dir and configure it
  75. rm -rf build
  76. mkdir build
  77. # 2b. Build list of external programs and shared libraries
  78. admin/build-macos-external-list.sh > build/add_macOS_cpack.txt
  79. cd build
  80. # 2c. Set CMake cache for MP build:
  81. cat << EOF > cache-mp-gcc.cmake
  82. # Cache settings for building the macOS release with GCC and OpenMP
  83. # This cache file is set for the binary paths of macports
  84. #
  85. SET ( CMAKE_C_COMPILER "/opt/local/bin/gcc-mp-9" CACHE STRING "GNU MP C compiler" )
  86. SET ( CMAKE_CXX_COMPILER "/opt/local/bin/g++-mp-9" CACHE STRING "GNU MP C++ compiler" )
  87. SET ( CMAKE_C_FLAGS -flax-vector-conversions CACHE STRING "C FLAGS")
  88. SET ( CMAKE_C_FLAGS_DEBUG -flax-vector-conversions CACHE STRING "C FLAGS DEBUG")
  89. SET ( CMAKE_C_FLAGS_RELEASE -flax-vector-conversions CACHE STRING "C FLAGS RELEASE")
  90. SET ( OpenMP_C_FLAGS -flax-vector-conversions CACHE STRING "C FLAGS OPENMP")
  91. EOF
  92. echo "build-release.sh: Configure and build tarballs" >&2
  93. cmake -G Ninja -C cache-mp-gcc.cmake ..
  94. # 3. Build the release and the tarballs
  95. cmake --build . --target gmt_release
  96. cmake --build . --target gmt_release_tar
  97. # 4. get the version string
  98. Version=$(src/gmt --version)
  99. # 5. Remove the uncompressed tarball
  100. rm -f gmt-${Version}-src.tar
  101. # 6. Install executables before building macOS Bundle
  102. cmake --build . --target install
  103. if [ $(uname) = "Darwin" ]; then
  104. echo "build-release.sh: Build macOS bundle" >&2
  105. # 7. Build the macOS Bundle
  106. cpack -G Bundle
  107. fi
  108. # 8. Report sha256 hash
  109. echo "build-release.sh: Report sha256sum per file" >&2
  110. shasum -a 256 gmt-${Version}-*
  111. # 9. Replace temporary ConfigReleaseBuild.cmake file with the original file
  112. reset_config
  113. # 10. Put the candidate products on my ftp site
  114. echo "build-release.sh: Place gmt-${Version}-src.tar.* on the ftp site" >&2
  115. if [ -f gmt-${Version}-darwin-x86_64.dmg ]; then
  116. echo "build-release.sh: Place gmt-${Version}-darwin-x86_64.dmg on the ftp site" >&2
  117. fi
  118. #scp gmt-${Version}-darwin-x86_64.dmg gmt-${Version}-src.tar.* ftp:/export/ftp1/ftp/pub/pwessel/release
Tip!

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

Comments

Loading...