neko/build

88 lines
1.7 KiB
Plaintext
Raw Normal View History

2022-04-16 07:28:00 +12:00
#!/bin/bash
#
# aborting if any command returns a non-zero value
set -e
2022-05-08 10:32:20 +12:00
#
# do not build plugins when passing "core" as first argument
if [ "$1" = "core" ];
then
skip_plugins="true"
fi
2022-04-16 07:28:00 +12:00
#
# set git build variables if git exists
2022-07-05 05:14:52 +12:00
if git version > /dev/null && [ -z $GIT_COMMIT ] && [ -z $GIT_BRANCH ] && [ -z $GIT_TAG ];
2022-04-16 07:28:00 +12:00
then
GIT_COMMIT=`git rev-parse --short HEAD`
GIT_BRANCH=`git rev-parse --symbolic-full-name --abbrev-ref HEAD`
2022-07-05 05:14:52 +12:00
GIT_TAG=`git tag --points-at $GIT_COMMIT | head -n 1`
2022-04-16 07:28:00 +12:00
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}'
2022-04-16 07:28:00 +12:00
" \
cmd/neko/main.go;
2022-07-14 10:57:00 +12:00
#
# ensure plugins folder exists
mkdir -p bin/plugins
2022-05-08 10:32:20 +12:00
#
# if plugins are ignored
if [ "$skip_plugins" = "true" ];
then
echo "Not building plugins..."
exit 0
fi
2022-04-16 07:28:00 +12:00
#
# if plugins directory does not exist
if [ ! -d "./plugins" ];
then
echo "No plugins directory found, skipping..."
exit 0
fi
2022-05-08 10:32:20 +12:00
#
2022-07-14 10:57:00 +12:00
# remove old plugins
2022-05-08 10:32:20 +12:00
rm -f bin/plugins/*
2022-04-16 07:28:00 +12:00
#
# build plugins
for plugPath in ./plugins/*; do
2022-07-14 11:07:50 +12:00
if [ ! -d $plugPath ];
then
continue
fi
2022-04-16 07:28:00 +12:00
pushd $plugPath
2022-05-03 23:17:04 +12:00
echo "Building plugin: $plugPath"
2022-05-08 10:22:45 +12:00
if [ ! -f "go.plug.mod" ];
then
echo "go.plug.mod not found, skipping..."
popd
continue
fi
2022-04-16 07:28:00 +12:00
# build plugin
2022-07-15 09:47:45 +12:00
go build -modfile=go.plug.mod -buildmode=plugin -buildvcs=false -o "../../bin/plugins/${plugPath##*/}.so"
2022-04-16 07:28:00 +12:00
popd
done