-
Notifications
You must be signed in to change notification settings - Fork 0
/
tools-build.sh
346 lines (314 loc) · 10.3 KB
/
tools-build.sh
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
#!/bin/bash
# Requirements:
# - C and C++ compilers (min. GCC 13 or Clang 18)
# - CMake
# - Rust toolchain
# - Git
# - wget
# - libgeos
# - sqlite3
# - libtiff
# Default variable values
build_tyler=false
build_tyler_db=false
build_geoflow_roofer=false
build_geos=false
build_proj=false
build_lastools=false
build_gdal=false
build_geotiff=false
build_pdal=false
geos_version="3.12.1"
geotiff_version="1.7.3"
proj_version="9.4.0"
lastools_version="2.0.3"
gdal_version="3.8.5"
pdal_version="2.8.0"
geoflow_bundle_version="2024.08.09"
jobs=8
root_dir=$PWD
clean_up=false
# Function to display script usage
# Ref.: https://medium.com/@wujido20/handling-flags-in-bash-scripts-4b06b4d0ed04
usage() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " -h, --help Display this help message"
echo " -d, --dir Change to this directory"
echo " --clean Delete all build directories, incl. vcpkg"
echo " -j, --jobs Number of jobs to run in parallel for the compilation [default 8]"
echo " --build-all Build all dependencies"
echo " --build-tyler Build Tyler"
echo " --build-tyler-db Build Tyler-db"
echo " --build-geoflow-roofer Build Geoflow-roofer"
echo " --build-geos Build GEOS"
echo " --build-proj Build PROJ"
echo " --build-lastools Build LASTools"
echo " --build-gdal Build GDAL"
echo " --build-geotiff Build GeoTIFF"
echo " --build-pdal Build PDAL"
}
has_argument() {
[[ ("$1" == *=* && -n ${1#*=}) || ( ! -z "$2" && "$2" != -*) ]];
}
extract_argument() {
echo "${2:-${1#*=}}"
}
# Function to handle options and arguments
handle_options() {
while [ $# -gt 0 ]; do
case $1 in
-h | --help)
usage
exit 0
;;
-d | --dir*)
if ! has_argument $@; then
echo "Directory not specified." >&2
usage
exit 1
fi
root_dir=$(extract_argument $@)
shift
;;
--clean)
clean_up=true
;;
-j | --jobs*)
if ! has_argument $@; then
echo "Number of jobs not specified." >&2
usage
exit 1
fi
jobs=$(extract_argument $@)
shift
;;
--build-all)
build_tyler=true
build_tyler_db=true
build_geoflow_roofer=true
build_geos=true
build_proj=true
build_lastools=true
build_gdal=true
build_geotiff=true
build_pdal=true
;;
--build-tyler)
build_tyler=true
;;
--build-tyler-db)
build_tyler_db=true
;;
--build-geoflow-roofer)
build_geoflow_roofer=true
;;
--build-geos)
build_geos=true
;;
--build-proj)
build_proj=true
;;
--build-lastools)
build_lastools=true
;;
--build-gdal)
build_gdal=true
;;
--build-geotiff)
build_geotiff=true
;;
--build-pdal)
build_pdal=true
;;
*)
echo "Invalid option: $1" >&2
usage
exit 1
;;
esac
shift
done
}
# Main script execution
handle_options "$@"
cd $root_dir || exit
if [ "$build_tyler" = true ] ; then
printf "\n\nInstalling Tyler...\n\n"
cd $root_dir || exit
cargo install \
--root . \
--git https://github.com/3DGI/tyler.git \
--branch multi-format-output \
--bin tyler
tyler_resources=share/tyler/resources
if ! [ -d "$tyler_resources" ] ; then
mkdir -p "$tyler_resources"/geof
fi
wget --no-verbose https://raw.githubusercontent.com/3DGI/tyler/multi-format-output/resources/geof/createGLB.json -O "$tyler_resources"/geof/createGLB.json
wget --no-verbose https://raw.githubusercontent.com/3DGI/tyler/multi-format-output/resources/geof/createMulti.json -O "$tyler_resources"/geof/createMulti.json
wget --no-verbose https://raw.githubusercontent.com/3DGI/tyler/multi-format-output/resources/geof/metadata.json -O "$tyler_resources"/geof/metadata.json
wget --no-verbose https://raw.githubusercontent.com/3DGI/tyler/multi-format-output/resources/geof/process_feature.json -O "$tyler_resources"/geof/process_feature.json
wget --no-verbose https://raw.githubusercontent.com/3DGI/tyler/multi-format-output/resources/geof/process_feature_multi.json -O "$tyler_resources"/geof/process_feature_multi.json
fi
if [ "$build_tyler_db" = true ] ; then
printf "\n\nInstalling Tyler-db...\n\n"
cd $root_dir || exit
cargo install \
--root . \
--git https://github.com/3DGI/tyler.git \
--branch postgres-footprints \
--bin tyler-db
fi
if [ "$build_geos" = true ] ; then
rm -rf geos-${geos_version}
wget --no-verbose https://download.osgeo.org/geos/geos-${geos_version}.tar.bz2
tar xfj geos-${geos_version}.tar.bz2
mkdir geos-${geos_version}/build
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$root_dir \
-DBUILD_TESTING:bool=OFF \
-DBUILD_DOCUMENTATION:bool=OFF \
-DBUILD_SHARED_LIBS:bool=ON \
-S geos-${geos_version} \
-B geos-${geos_version}/build
cmake --build geos-${geos_version}/build -j $jobs --target install --config Release
rm -rf geos-${geos_version}
rm geos-${geos_version}.tar.bz2
fi
if [ "$build_lastools" = true ] ; then
printf "\n\nInstalling LAStools...\n\n"
cd $root_dir || exit
rm -rf LAStools
wget --no-verbose https://github.com/LAStools/LAStools/archive/refs/tags/v${lastools_version}.zip -O LAStools.zip
unzip -q LAStools.zip
mkdir LAStools-${lastools_version}/build
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$root_dir \
-S LAStools-${lastools_version} \
-B LAStools-${lastools_version}/build
cmake --build LAStools-${lastools_version}/build -j $jobs --target install --config Release
rm -rf LAStools-${lastools_version}
rm LAStools.zip
fi
if [ "$build_proj" = true ] ; then
printf "\n\nInstalling proj...\n\n"
cd $root_dir || exit
rm -rf proj-${proj_version}
wget --no-verbose https://download.osgeo.org/proj/proj-${proj_version}.tar.gz
tar -xf proj-${proj_version}.tar.gz
mkdir proj-${proj_version}/build
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$root_dir \
-S proj-${proj_version} \
-B proj-${proj_version}/build
cmake --build proj-${proj_version}/build -j $jobs --target install --config Release
rm -rf proj-${proj_version}
rm proj-${proj_version}.tar.gz
fi
if [ "$build_geotiff" = true ] ; then
printf "\n\nInstalling GeoTIFF...\n\n"
cd $root_dir || exit
rm -rf libgeotiff-${geotiff_version}
wget --no-verbose https://github.com/OSGeo/libgeotiff/releases/download/${geotiff_version}/libgeotiff-${geotiff_version}.tar.gz
tar -xf libgeotiff-${geotiff_version}.tar.gz
mkdir libgeotiff-${geotiff_version}/build
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$root_dir \
-DCMAKE_PREFIX_PATH=$root_dir \
-S libgeotiff-${geotiff_version} \
-B libgeotiff-${geotiff_version}/build
cmake --build libgeotiff-${geotiff_version}/build -j $jobs --target install --config Release
rm -rf libgeotiff-${geotiff_version}
rm libgeotiff-${geotiff_version}.tar.gz
fi
if [ "$build_gdal" = true ] ; then
printf "\n\nInstalling GDAL...\n\n"
cd $root_dir || exit
rm -rf gdal-${gdal_version}
wget --no-verbose https://github.com/OSGeo/gdal/releases/download/v${gdal_version}/gdal-${gdal_version}.tar.gz
tar -xf gdal-${gdal_version}.tar.gz
mkdir gdal-${gdal_version}/build
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$root_dir \
-DCMAKE_PREFIX_PATH=$root_dir \
-S gdal-${gdal_version} \
-B gdal-${gdal_version}/build
cmake --build gdal-${gdal_version}/build -j $jobs --target install --config Release
rm -rf gdal-${gdal_version}
rm gdal-${gdal_version}.tar.gz
fi
if [ "$build_pdal" = true ] ; then
printf "\n\nInstalling PDAL...\n\n"
cd $root_dir || exit
rm -rf PDAL-${pdal_version}-src
wget --no-verbose https://github.com/PDAL/PDAL/releases/download/${pdal_version}/PDAL-${pdal_version}-src.tar.gz
tar -xf PDAL-${pdal_version}-src.tar.gz
mkdir PDAL-${pdal_version}-src/build
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$root_dir \
-DCMAKE_PREFIX_PATH=$root_dir \
-S PDAL-${pdal_version}-src \
-B PDAL-${pdal_version}-src/build
cmake --build PDAL-${pdal_version}-src/build -j $jobs --target install --config Release
rm -rf PDAL-${pdal_version}-src
rm PDAL-${pdal_version}-src.tar.gz
fi
if [ "$build_geoflow_roofer" = true ] ; then
cd $root_dir || exit
if ! [ -d vcpkg ] ; then
printf "\n\nInstalling vcpkg...\n\n"
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg && ./bootstrap-vcpkg.sh -disableMetrics
fi
export VCPKG_ROOT="$root_dir/vcpkg"
printf "\n\nInstalling Geoflow-roofer...\n\n"
cd $root_dir || exit
git clone https://github.com/3DBAG/geoflow-roofer.git
mkdir geoflow-roofer/build
cd geoflow-roofer
$root_dir/vcpkg/vcpkg x-update-baseline
cd $root_dir
cmake \
--preset vcpkg-minimal \
-DRF_USE_LOGGER_SPDLOG=ON \
-DRF_BUILD_APPS=ON \
-DCMAKE_INSTALL_PREFIX=$root_dir \
-S geoflow-roofer \
-B geoflow-roofer/build
cmake --build geoflow-roofer/build -j $jobs --target install --config Release
geoflow_flowcharts=share/geoflow-bundle/flowcharts
if ! [ -d "$geoflow_flowcharts" ] ; then
mkdir -p "$geoflow_flowcharts"
fi
wget --no-verbose https://raw.githubusercontent.com/geoflow3d/gfc-brecon/79ab70bc7b08aee37a1ceca7e3bb4db18c0f2778/stream/reconstruct_bag.json -O "$geoflow_flowcharts/reconstruct_bag.json"
rm -rf geoflow-roofer
fi
if [ "$clean_up" = true ] ; then
cd $root_dir || exit
printf "\n\nDeleting build artifacts...\n\n"
rm geos-${geos_version}.tar.bz2 || true
rm -rf geos-${geos_version} || true
rm LAStools.zip || true
rm -rf LAStools-${lastools_version} || true
rm proj-${proj_version}.tar.gz || true
rm -rf proj-${proj_version} || true
rm gdal-${gdal_version}.tar.gz || true
rm -rf gdal-${gdal_version} || true
rm gdal-${gdal_version}.tar.gz || true
rm -rf gdal-${gdal_version} || true
rm libgeotiff-${geotiff_version}.tar.gz || true
rm -rf libgeotiff-${geotiff_version} || true
rm PDAL-${pdal_version}-src.tar.gz || true
rm -rf PDAL-${pdal_version}-src || true
rm -rf build || true
rm -rf geoflow-bundle-src || true
rm -rf geoflow-roofer || true
rm -rf vcpkg || true
fi