-
Notifications
You must be signed in to change notification settings - Fork 49
/
build_unix.sh
executable file
·90 lines (83 loc) · 2.57 KB
/
build_unix.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
#!/bin/bash
set -e
case ${1:-$(uname -m)} in
x86_64|x64)
vcpkg_arch=x64
linux_arch=x86_64
osx_arch=x86_64
;;
aarch64|arm64)
vcpkg_arch=arm64
linux_arch=aarch64
osx_arch=arm64
;;
*)
echo "Architecture not supported"
exit 1
;;
esac
case $(uname) in
Linux)
os=linux
[ -f /etc/redhat-release ] && platform=redhat-linux || platform=linux-gnu
options="-D CMAKE_SYSTEM_PROCESSOR=$linux_arch \
-D CMAKE_C_COMPILER=$(which $linux_arch-$platform-gcc) \
-D CMAKE_CXX_COMPILER=$(which $linux_arch-$platform-g++) \
-D CMAKE_STRIP=$(which $linux_arch-$platform-strip 2>/dev/null || which strip)"
;;
Darwin)
os=osx
options="-D CMAKE_OSX_ARCHITECTURES=$osx_arch"
if ! which brew >/dev/null || [ ! -x $(brew --prefix)/opt/bison/bin/bison ]
then
echo 'The version of bison provided with macOS is too old.'
echo 'Please install a newer version with Homebrew (https://brew.sh):'
echo '$ brew install bison'
exit 1
else
export PATH="$(brew --prefix)/opt/bison/bin:$PATH"
fi
;;
*)
echo "OS not supported"
exit 1
;;
esac
triplet=$vcpkg_arch-$os
# Find vcpkg or download it if required
if [ -z "$VCPKG_INSTALLATION_ROOT" ]; then
if [ -n "$VCPKG_ROOT" ]; then
VCPKG_INSTALLATION_ROOT=$VCPKG_ROOT
else
VCPKG_INSTALLATION_ROOT=$PWD/build/vcpkg
if [ ! -d "$VCPKG_INSTALLATION_ROOT" ]; then
git clone https://github.com/microsoft/vcpkg.git "$VCPKG_INSTALLATION_ROOT"
$VCPKG_INSTALLATION_ROOT/bootstrap-vcpkg.sh
fi
fi
fi
# Cmake build types
build_types="Debug Release"
# Only build release configuration in CI
if [ "$GITHUB_ACTIONS" = "true" ]
then
build_types="Release"
custom_triplets_dir=$PWD/build/custom-triplets
mkdir -p "$custom_triplets_dir"
for vcpkg_triplet_file in $VCPKG_INSTALLATION_ROOT/triplets/{,community/}$triplet.cmake
do
if [ -f "$vcpkg_triplet_file" ]; then
custom_triplet_file="$custom_triplets_dir/$triplet.cmake"
cp "$vcpkg_triplet_file" "$custom_triplet_file"
echo "set(VCPKG_BUILD_TYPE release)" >> "$custom_triplet_file"
fi
done
options+=" -D VCPKG_OVERLAY_TRIPLETS=$custom_triplets_dir"
fi
for build_type in $build_types
do
echo ">> Building ParquetSharpNative $build_type for $triplet"
build_dir=build/$triplet-$(tr A-Z a-z <<<$build_type)
cmake -B $build_dir -S . -D VCPKG_TARGET_TRIPLET=$triplet -D CMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake -D CMAKE_BUILD_TYPE=$build_type $options
cmake --build $build_dir -j
done