forked from makman07/curve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sdk.sh
76 lines (62 loc) · 2.09 KB
/
sdk.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
#!/usr/bin/env bash
set -e
g_root="${PWD}"
build_jni_library() {
# 1) generate jni native header file
local maven_repo="/home/${USER}/.m2/repository"
cd "${g_root}/curvefs/sdk/java/src/main/java"
javac -cp "${maven_repo}/org/apache/commons/commons-compress/1.24.0/commons-compress-1.24.0.jar":"${maven_repo}/org/apache/hadoop/hadoop-common/2.7.3/hadoop-common-2.7.3.jar":. \
-h \
"${g_root}/curvefs/sdk/java/native/" \
io/opencurve/curve/fs/libfs/CurveFsMount.java
# 2) build libcurvefs_jni.so
cd "${g_root}"
# TODO: --config=gcc7-later
bazel build \
--config=gcc7-later \
--compilation_mode=opt \
--copt -g \
--copt -DUNINSTALL_SIGSEGV=1 \
--copt -DCLIENT_CONF_PATH="\"${g_root}/curvefs/conf/client.conf\"" \
//curvefs/sdk/java/native:curvefs_jni
}
copy_jni_library() {
local dest="${g_root}/curvefs/sdk/java/native/build/libcurvefs"
rm -rf "${dest}"
mkdir -p "${dest}"
# 1) copy the dependencies of the libcurvefs_jni.so
local jni_so="$(realpath "${g_root}/bazel-bin/curvefs/sdk/java/native/libcurvefs_jni.so")"
ldd "${jni_so}" | grep '=>' | awk '{ print $1, $3 }' | while read -r line;
do
name=$(echo "${line}" | cut -d ' ' -f1)
path=$(echo "${line}" | cut -d ' ' -f2)
sudo cp "$(realpath "${path}")" "${dest}/${name}"
done
# 2) copy libcurvefs_jni.so
sudo cp "${jni_so}" "${dest}"
# 3) achive libcurvefs
cd "${g_root}/curvefs/sdk/java/native/build/"
tar -cf libcurvefs.tar libcurvefs
rm -rf libcurvefs
}
build_hadoop_jar() {
# build curvefs-hadoop-1.0-SNAPSHOT.jar
cd "${g_root}/curvefs/sdk/java"
mvn clean
mvn package
}
display_output() {
local src="${g_root}/curvefs/sdk/java/target/curvefs-hadoop-1.0-SNAPSHOT.jar"
local dest="${g_root}/curvefs/sdk/output";
rm -rf "${dest}"
mkdir -p "${dest}"
cp "${src}" "${dest}"
echo -e "\nBuild SDK success => ${dest}/curvefs-hadoop-1.0-SNAPSHOT.jar"
}
main() {
build_jni_library
copy_jni_library
build_hadoop_jar
display_output
}
main