-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·79 lines (69 loc) · 2.67 KB
/
build.sh
File metadata and controls
executable file
·79 lines (69 loc) · 2.67 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
#!/bin/bash -e
# This script builds a specific cmake target.
# This script should be ran from the root directory of the project.
# ./scripts/build.sh my-build-target ON
#
# $1 the name of the target. For example "launchdarkly-cpp-common".
# $2 ON/OFF which enables/disables building in a test configuration (unit tests + contract tests.)
# $3 (optional) true/false to enable/disable CURL networking (LD_CURL_NETWORKING)
# $4 (optional) true/false to enable/disable Redis support (LD_BUILD_REDIS_SUPPORT)
function cleanup {
cd ..
}
mkdir -p build
cd build
# After we enter the directory we want to make sure we always exit it when the
# script ends.
trap cleanup EXIT
# Special case: unlike the other targets, enabling redis support will pull in redis++ and hiredis dependencies at
# configuration time. To ensure this only happens when asked, disable the support by default.
build_redis="OFF"
if [ "$1" == "launchdarkly-cpp-server-redis-source" ] || [ "$1" == "gtest_launchdarkly-cpp-server-redis-source" ]; then
build_redis="ON"
fi
# Check for CURL networking option
build_curl="OFF"
if [ "$3" == "true" ]; then
build_curl="ON"
fi
# Check for Redis support option (override the automatic detection if explicitly passed)
if [ "$4" == "true" ]; then
build_redis="ON"
elif [ "$4" == "false" ]; then
build_redis="OFF"
fi
# Set build type to Debug when testing is enabled
build_type="Release"
if [ "$2" == "ON" ]; then
build_type="Debug"
fi
# Special case: OpenTelemetry support requires additional dependencies.
# Enable OTEL support and fetch deps when building OTEL targets.
build_otel="OFF"
build_otel_fetch_deps="OFF"
build_contract_tests="$2"
if [ "$1" == "launchdarkly-cpp-server-otel" ] || [ "$1" == "gtest_launchdarkly-cpp-server-otel" ]; then
build_otel="ON"
build_otel_fetch_deps="ON"
fi
echo "==== Build Configuration ===="
echo "Target: $1"
echo "CMAKE_BUILD_TYPE: $build_type"
echo "BUILD_TESTING: $2"
echo "LD_BUILD_UNIT_TESTS: $2"
echo "LD_BUILD_CONTRACT_TESTS: $2"
echo "LD_BUILD_REDIS_SUPPORT: $build_redis"
echo "LD_CURL_NETWORKING: $build_curl"
echo "LD_BUILD_OTEL_SUPPORT: $build_otel"
echo "LD_BUILD_OTEL_FETCH_DEPS: $build_otel_fetch_deps"
echo "============================="
cmake -G Ninja -D CMAKE_BUILD_TYPE="$build_type" \
-D CMAKE_COMPILE_WARNING_AS_ERROR=TRUE \
-D BUILD_TESTING="$2" \
-D LD_BUILD_UNIT_TESTS="$2" \
-D LD_BUILD_CONTRACT_TESTS="$2" \
-D LD_BUILD_REDIS_SUPPORT="$build_redis" \
-D LD_CURL_NETWORKING="$build_curl" \
-D LD_BUILD_OTEL_SUPPORT="$build_otel" \
-D LD_BUILD_OTEL_FETCH_DEPS="$build_otel_fetch_deps" ..
cmake --build . --target "$1"