zhangmeng
2020-01-20 7f325a2532bca346f77549b049851888e0e4255c
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
#!/bin/sh
 
target="all"
 
if [ $# != 0 -a "$1" != "all" ]; then
    target=$1
fi
 
cur_dir=`pwd`
src=$cur_dir"/libgowrapper"
 
runtime_dir=$cur_dir"/libs"
 
# runtime_dir not exist, then create
if [ ! -d $runtime_dir ];then
    mkdir $runtime_dir 
    echo "~~~CREATE RUNTIME LIBRARY DIRECTORY $runtime_dir"  
fi
 
cd $src
 
for value in `ls`; do
    if [ ! -d $src"/"$value ];then
        continue
    fi
 
    if [ "$target" != "all" -a "$target" != "$value" ]; then
        continue
    fi
# build so file
    cd $src"/"$value
    go build -buildmode=plugin -o lib$value.so -a
    if [ $? != 0 ]; then
        echo "!!!CREATE lib$value.so FAILED, WATCH IT"
        continue
    fi
 
    deps_dir=$runtime_dir"/"$value
    if [ ! -d $deps_dir ];then
        mkdir -p $deps_dir
    fi
 
# move to runtime_dir
    rm -fr $deps_dir/*
    mv -f lib$value.so $deps_dir
# move sdk to runtime_dir
    if [ -d `pwd`/sdk/lib ]; then
        cp -fr `pwd`/sdk/lib/* $deps_dir
    fi
    
    if [ -d `pwd`/thirdparty/lib ]; then
        cp -fr `pwd`/thirdparty/lib/* $deps_dir
    fi
 
    echo "~~~WATCH lib$value.so In $deps_dir IF CORRECT"
 
    cd $src
done