forked from gjbae1212/fluent-bit-pubsub
-
Notifications
You must be signed in to change notification settings - Fork 2
/
make.sh
37 lines (33 loc) · 1.05 KB
/
make.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
#!/bin/bash
set -e -o pipefail
trap '[ "$?" -eq 0 ] || echo "Error Line:<$LINENO> Error Function:<${FUNCNAME}>"' EXIT
export GO111MODULE=on
cd `dirname $0`
CURRENT=`pwd`
function build
{
go build -buildmode=c-shared -o pubsub.so .
local osname=`go env | grep GOOS | awk -F "=" '{print $2}' | sed 's/\"//g'`
local archname=`go env | grep GOARCH | awk -F "=" '{print $2}' | sed 's/\"//g'`
mkdir -p $CURRENT/bin/${osname}_${archname} || true
mv pubsub.so pubsub.h $CURRENT/bin/${osname}_${archname}/
}
function build_linux
{
local plugin=`docker ps | grep pubsub | wc -l`
if [ $plugin -eq 1 ]
then
docker kill pubsub
fi
local osname=linux
local archname=amd64
mkdir -p $CURRENT/bin/${osname}_${archname} || true
docker build --no-cache -t pubsub:latest -f Dockerfile .
docker run -it --rm -d --name pubsub pubsub:latest /bin/bash
docker cp pubsub:/go/pubsub/pubsub.so $CURRENT/bin/${osname}_${archname}/
docker cp pubsub:/go/pubsub/pubsub.h $CURRENT/bin/${osname}_${archname}/
docker kill pubsub
}
CMD=$1
shift
$CMD $*