-
Notifications
You must be signed in to change notification settings - Fork 41
/
build_deps.sh
executable file
·90 lines (74 loc) · 2.31 KB
/
build_deps.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
#!/usr/bin/env bash
ROOT=$(pwd)
DEPS_LOCATION=_build/deps
OS=$(uname -s)
KERNEL=$(echo $(lsb_release -ds 2>/dev/null || cat /etc/*release 2>/dev/null | head -n1 | awk '{print $1;}') | awk '{print $1;}')
CPUS=`getconf _NPROCESSORS_ONLN 2>/dev/null || sysctl -n hw.ncpu`
# https://github.com/confluentinc/librdkafka.git
LIBRDKAFKA_DESTINATION=librdkafka
LIBRDKAFKA_REPO=https://github.com/confluentinc/librdkafka.git
LIBRDKAFKA_BRANCH=master
LIBRDKAFKA_REV=9b72ca3aa6c49f8f57eea02f70aadb1453d3ba1f
LIBRDKAFKA_SUCCESS=src/librdkafka.a
# https://github.com/cameron314/concurrentqueue.git
CQ_DESTINATION=concurrentqueue
CQ_REPO=https://github.com/cameron314/concurrentqueue.git
CQ_BRANCH=master
CQ_REV=cff1001582db67e357d5f77c31e73566003311f2
CQ_SUCCESS=concurrentqueue.h
fail_check()
{
"$@"
local status=$?
if [ $status -ne 0 ]; then
echo "error with $1" >&2
exit 1
fi
}
CheckoutLib()
{
if [ -f "$DEPS_LOCATION/$4/$5" ]; then
echo "$4 fork already exist. delete $DEPS_LOCATION/$4 for a fresh checkout ..."
else
#repo rev branch destination
echo "repo=$1 rev=$2 branch=$3"
mkdir -p $DEPS_LOCATION
pushd $DEPS_LOCATION
if [ ! -d "$4" ]; then
fail_check git clone -b $3 $1 $4
fi
pushd $4
fail_check git checkout $2
BuildLibrary $4
popd
popd
fi
}
BuildLibrary()
{
unset CFLAGS
unset CXXFLAGS
case $1 in
$LIBRDKAFKA_DESTINATION)
case $OS in
Darwin)
export HOMEBREW_NO_INSTALL_UPGRADE=true
export HOMEBREW_NO_INSTALL_CLEANUP=true
export HOMEBREW_NO_AUTO_UPDATE=1
brew install [email protected] lz4 zstd curl
OPENSSL_ROOT_DIR=$(brew --prefix [email protected])
export CPPFLAGS=-I$OPENSSL_ROOT_DIR/include/
export LDFLAGS=-L$OPENSSL_ROOT_DIR/lib
;;
esac
fail_check ./configure
fail_check make -j $CPUS
rm src/*.dylib
rm src/*.so
;;
*)
;;
esac
}
CheckoutLib $LIBRDKAFKA_REPO $LIBRDKAFKA_REV $LIBRDKAFKA_BRANCH $LIBRDKAFKA_DESTINATION $LIBRDKAFKA_SUCCESS
CheckoutLib $CQ_REPO $CQ_REV $CQ_BRANCH $CQ_DESTINATION $CQ_SUCCESS