-
Notifications
You must be signed in to change notification settings - Fork 50
/
build_libgit2.sh
executable file
·53 lines (42 loc) · 1.06 KB
/
build_libgit2.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
#!/bin/sh
set -e
if [ -z "$ARCHS" ]; then
ARCHS=$(uname -m)
fi
# augment path to help it find cmake installed e.g. via brew.
# Xcode's Run Script phase doesn't seem to honor
# ~/.MacOSX/environment.plist
if [[ $ARCHS == 'arm64' ]]; then
HOMEBREW_ROOT="/opt/homebrew"
OPENSSL_DIR="openssl"
else
HOMEBREW_ROOT="/usr/local"
OPENSSL_DIR="openssl@3"
fi
PATH="${HOMEBREW_ROOT}/bin:$PATH"
if [ "libgit2-mac.a" -nt "libgit2" ]
then
echo "No update needed."
exit 0
fi
cd "libgit2"
if [ -d "build" ]; then
rm -rf "build"
fi
mkdir build
cd build
# OpenSSL is keg-only, so add its pkgconfig location manually
export PKG_CONFIG_PATH="${HOMEBREW_ROOT}/opt/${OPENSSL_DIR}/lib/pkgconfig"
cmake -DBUILD_SHARED_LIBS:BOOL=OFF \
-DUSE_SSH=ON \
-DCMAKE_PREFIX_PATH="${HOMEBREW_ROOT}/opt/libssh2" \
-DBUILD_CLAR:BOOL=OFF \
-DTHREADSAFE:BOOL=ON \
..
cmake --build .
product="libgit2.a"
install_path="../../"
if [ "libgit2.a" -nt "${install_path}/libgit2-mac.a" ]; then
cp -v "libgit2.a" "${install_path}/libgit2-mac.a"
fi
echo "libgit2 has been updated."