This repository has been archived by the owner on Jul 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
build
executable file
·87 lines (72 loc) · 1.68 KB
/
build
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
#!/bin/bash
#
# aborting if any command returns a non-zero value
set -e
#
# do not build plugins when passing "core" as first argument
if [ "$1" = "core" ];
then
skip_plugins="true"
fi
#
# set git build variables if git exists
if git status > /dev/null 2>&1 && [ -z $GIT_COMMIT ] && [ -z $GIT_BRANCH ] && [ -z $GIT_TAG ];
then
GIT_COMMIT=`git rev-parse --short HEAD`
GIT_BRANCH=`git rev-parse --symbolic-full-name --abbrev-ref HEAD`
GIT_TAG=`git tag --points-at $GIT_COMMIT | head -n 1`
fi
#
# load server dependencies
go get -v -t -d .
#
# build server
go build \
-o bin/neko \
-ldflags "
-s -w
-X 'github.com/demodesk/neko.buildDate=`date -u +'%Y-%m-%dT%H:%M:%SZ'`'
-X 'github.com/demodesk/neko.gitCommit=${GIT_COMMIT}'
-X 'github.com/demodesk/neko.gitBranch=${GIT_BRANCH}'
-X 'github.com/demodesk/neko.gitTag=${GIT_TAG}'
" \
cmd/neko/main.go;
#
# ensure plugins folder exists
mkdir -p bin/plugins
#
# if plugins are ignored
if [ "$skip_plugins" = "true" ];
then
echo "Not building plugins..."
exit 0
fi
#
# if plugins directory does not exist
if [ ! -d "./plugins" ];
then
echo "No plugins directory found, skipping..."
exit 0
fi
#
# remove old plugins
rm -f bin/plugins/*
#
# build plugins
for plugPath in ./plugins/*; do
if [ ! -d $plugPath ];
then
continue
fi
pushd $plugPath
echo "Building plugin: $plugPath"
if [ ! -f "go.plug.mod" ];
then
echo "go.plug.mod not found, skipping..."
popd
continue
fi
# build plugin
go build -modfile=go.plug.mod -buildmode=plugin -buildvcs=false -o "../../bin/plugins/${plugPath##*/}.so"
popd
done