summaryrefslogtreecommitdiff
path: root/script/build-libgit2.sh
diff options
context:
space:
mode:
authorlhchavez <[email protected]>2020-02-23 14:49:04 +0000
committerlhchavez <[email protected]>2020-02-23 14:49:04 +0000
commit627447092fa24035ed3cd4cf31932dbef6f5a57f (patch)
tree48a9122be45522cf1ec72535cec18fd701db55d2 /script/build-libgit2.sh
parent03339f731aba66baacab3fd67e7b2d185cdacb33 (diff)
parent06764f48dce903bf95701c6ef75ad0fe46c0dedf (diff)
Merge remote-tracking branch 'upstream/master' into more-annotated-commit
Diffstat (limited to 'script/build-libgit2.sh')
-rwxr-xr-xscript/build-libgit2.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/script/build-libgit2.sh b/script/build-libgit2.sh
new file mode 100755
index 0000000..acbc84a
--- /dev/null
+++ b/script/build-libgit2.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+# Since CMake cannot build the static and dynamic libraries in the same
+# directory, this script helps build both static and dynamic versions of it and
+# have the common flags in one place instead of split between two places.
+
+set -e
+
+if [ "$#" -eq "0" ]; then
+ echo "Usage: $0 <--dynamic|--static>">&2
+ exit 1
+fi
+
+ROOT="$(cd "$(dirname "$0")/.." && echo "${PWD}")"
+VENDORED_PATH="${ROOT}/vendor/libgit2"
+
+case "$1" in
+ --static)
+ BUILD_PATH="${ROOT}/static-build"
+ BUILD_SHARED_LIBS=OFF
+ ;;
+
+ --dynamic)
+ BUILD_PATH="${ROOT}/dynamic-build"
+ BUILD_SHARED_LIBS=ON
+ ;;
+
+ *)
+ echo "Usage: $0 <--dynamic|--static>">&2
+ exit 1
+ ;;
+esac
+
+mkdir -p "${BUILD_PATH}/build" "${BUILD_PATH}/install/lib"
+
+cd "${BUILD_PATH}/build" &&
+cmake -DTHREADSAFE=ON \
+ -DBUILD_CLAR=OFF \
+ -DBUILD_SHARED_LIBS"=${BUILD_SHARED_LIBS}" \
+ -DREGEX_BACKEND=builtin \
+ -DCMAKE_C_FLAGS=-fPIC \
+ -DCMAKE_BUILD_TYPE="RelWithDebInfo" \
+ -DCMAKE_INSTALL_PREFIX="${BUILD_PATH}/install" \
+ "${VENDORED_PATH}" &&
+
+exec cmake --build . --target install