-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·119 lines (104 loc) · 4.76 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·119 lines (104 loc) · 4.76 KB
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
#!/bin/bash
set -e
# Check if VCPKG_ROOT is set and points to the correct directory
if [ -z "$VCPKG_ROOT" ]; then
echo "Error: VCPKG_ROOT is not set. Please run 'source install-prerequisities.sh' or 'source setenvs.sh' before running this script."
exit 1
fi
EXPECTED_VCPKG_ROOT="$(pwd)/vcpkg"
if [ "$VCPKG_ROOT" != "$EXPECTED_VCPKG_ROOT" ]; then
echo "Error: VCPKG_ROOT points to the vcpkg of another project '$VCPKG_ROOT'. Please run 'source install-prerequisities.sh' or 'source setenvs.sh' before running this script."
exit 1
fi
# Check if VCPKG_OVERLAY_TRIPLETS is set
if [ -z "$VCPKG_OVERLAY_TRIPLETS" ]; then
echo "Error: VCPKG_OVERLAY_TRIPLETS is not set. Please set it to the path of the triplets directory."
exit 1
fi
# Parse command-line options
PROD_BUILD=false
TARGET_TRIPLET=""
CHAINLOAD_TOOLCHAIN_FILE=""
PLATFORM=""
ANDROID_ABI="arm64-v8a"
ANDROID_PLATFORM=24
STANDALONE_PACKAGES=true
while [[ "$#" -gt 0 ]]; do
case $1 in
--prod) PROD_BUILD=true ;;
--ios) TARGET_TRIPLET="arm64-ios"; CHAINLOAD_TOOLCHAIN_FILE="$(pwd)/overlaytriplets/arm64-ios.cmake"; PLATFORM="OS64"; CREATE_XCFRAMEWORK=true ;;
--android) TARGET_TRIPLET="arm64-android"; CHAINLOAD_TOOLCHAIN_FILE="$ANDROID_NDK/build/cmake/android.toolchain.cmake";;
# Skip the per-package standalone builds and build only the root
# tree (MODERNIZATION.md "After the consolidation: CI speed"). The
# root tree is self-contained — sibling find_package calls are
# guarded with if(NOT TARGET ...) in the package CMakeLists — so no
# standalone build dirs are needed. The full standalone build
# validates that each package works as an independent vcpkg-style
# unit; that check is host-independent and the iOS CI job runs it by
# construction (the XCFramework is assembled from the per-package
# outputs), so ALL validate legs pass this flag. Not allowed with
# --ios for the same reason.
--no-standalone) STANDALONE_PACKAGES=false ;;
*) echo "Unknown parameter passed: $1. Usage: ./install.sh [--prod] [--ios] [--android] [--no-standalone]"; exit 1 ;;
esac
shift
done
if [ "$STANDALONE_PACKAGES" = false ] && [ "$TARGET_TRIPLET" = "arm64-ios" ]; then
echo "Error: --no-standalone cannot be combined with --ios (the XCFramework is built from the per-package outputs)."
exit 1
fi
# Set build type based on the --prod flag
if [ "$PROD_BUILD" = true ]; then
BUILD_TYPE="Release"
else
BUILD_TYPE="Debug"
fi
# Print the target platform if specified
if [ -n "$TARGET_TRIPLET" ]; then
export PLATFORM=$PLATFORM
echo "Target platform: $TARGET_TRIPLET"
fi
git config core.hooksPath .githooks
./merge-dependencies.sh
if [ -n "$TARGET_TRIPLET" ]; then
vcpkg install --x-install-root=build/vcpkg_installed --triplet=$TARGET_TRIPLET
else
vcpkg install --x-install-root=build/vcpkg_installed
fi
# Call build for all monorepo packages in their own build directories
if [ "$STANDALONE_PACKAGES" = true ]; then
for package in $(cat MonorepoPackages.cmake | grep -v "set(MonorepoPackages" | grep -v ")"); do
cd packages/$package/build
if [ -n "$TARGET_TRIPLET" ]; then
if [ "$TARGET_TRIPLET" = "arm64-android" ]; then
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DVCPKG_TARGET_TRIPLET=$TARGET_TRIPLET -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$CHAINLOAD_TOOLCHAIN_FILE -DANDROID_ABI=$ANDROID_ABI -DANDROID_PLATFORM=$ANDROID_PLATFORM ..
else
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DVCPKG_TARGET_TRIPLET=$TARGET_TRIPLET -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$CHAINLOAD_TOOLCHAIN_FILE -DPLATFORM=$PLATFORM ..
fi
else
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE ..
fi
cmake --build .
#if the package is streamr-libstreamrproxyclient, run cmake --install .
if [ "$package" = "streamr-libstreamrproxyclient" ]; then
if [ "$TARGET_TRIPLET" = "arm64-ios" ]; then
cd ../../..
./create-streamr-xcframework.pl
cd packages/$package/build
fi
cmake --install .
fi
cd ../../..
done
fi
# Call build for the root project
echo "Building root project"
if [ -n "$TARGET_TRIPLET" ]; then
if [ "$TARGET_TRIPLET" = "arm64-android" ]; then
cd build && cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DVCPKG_TARGET_TRIPLET=$TARGET_TRIPLET -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$CHAINLOAD_TOOLCHAIN_FILE -DANDROID_ABI=$ANDROID_ABI -DANDROID_PLATFORM=$ANDROID_PLATFORM .. && cmake --build . && cd ..
else
cd build && cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DVCPKG_TARGET_TRIPLET=$TARGET_TRIPLET -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$CHAINLOAD_TOOLCHAIN_FILE -DPLATFORM=$PLATFORM .. && cmake --build . && cd ..
fi
else
cd build && cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE .. && cmake --build . && cd ..
fi