From 55c26a97ca27f3fb6fa4c483ddd3fbb72341e3ed Mon Sep 17 00:00:00 2001 From: Ciprian Dorin Craciun Date: Tue, 13 Aug 2019 21:35:36 +0300 Subject: [PATCH] [sources] Add support for "all-in-one" executable --- scripts/z-run | 43 ++++++++++++++++++++++++++++++++++++++++++ sources/cmd/wrapper.go | 38 +++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 sources/cmd/wrapper.go diff --git a/scripts/z-run b/scripts/z-run index e81c51c..59de292 100644 --- a/scripts/z-run +++ b/scripts/z-run @@ -156,6 +156,47 @@ +<< execute / wrapper / release + "${ZRUN[@]}" ':: go / build / wrapper / release' + exec -- env -i -- ./.outputs/binaries/release/kawipiko "${@}" +!! + + +<< go / build / wrapper / release + test "${#}" -eq 0 + _outputs="$( exec -- readlink -e -- ./.outputs )" + mkdir -p -- "${_outputs}/binaries/release" + rm -f -- "${_outputs}/binaries/release/kawipiko-server" + exec -- "${ZRUN[@]}" ':: go / tool' \ + build \ + -v \ + -tags 'netgo nobrotli' \ + -ldflags 'all=-s -extld=gcc -extldflags=-static' \ + -gcflags 'all=-l=4' \ + -o "${_outputs}/binaries/release/kawipiko" \ + -- ./cmd/wrapper.go \ + # +!! + + +<< go / build / wrapper / publish + test "${#}" -eq 0 + "${ZRUN[@]}" ':: go / build / wrapper / release' + if test ! -e ./.outputs/publish ; then + mkdir -- ./.outputs/publish + fi + if test ! -e ./.outputs/publish/binaries ; then + mkdir -- ./.outputs/publish/binaries + fi + cp -T -- \ + ./.outputs/binaries/release/kawipiko \ + ./.outputs/publish/binaries/kawipiko \ + # +!! + + + + << go / build / debug "${ZRUN[@]}" ':: go / build / archiver / debug' "${@}" "${ZRUN[@]}" ':: go / build / server / debug' "${@}" @@ -164,11 +205,13 @@ << go / build / release "${ZRUN[@]}" ':: go / build / archiver / release' "${@}" "${ZRUN[@]}" ':: go / build / server / release' "${@}" + "${ZRUN[@]}" ':: go / build / wrapper / release' "${@}" !! ++<< go / build / publish "${ZRUN[@]}" ':: go / build / archiver / publish' "${@}" "${ZRUN[@]}" ':: go / build / server / publish' "${@}" + "${ZRUN[@]}" ':: go / build / wrapper / publish' "${@}" !! diff --git a/sources/cmd/wrapper.go b/sources/cmd/wrapper.go new file mode 100644 index 0000000..28e8bb7 --- /dev/null +++ b/sources/cmd/wrapper.go @@ -0,0 +1,38 @@ + +package main + + +import "fmt" +import "os" + + +import "github.com/volution/kawipiko/cmd/server" +import "github.com/volution/kawipiko/cmd/archiver" + + + + +func main () () { + + if len (os.Args) >= 2 { + + _command := os.Args[1] + os.Args = os.Args[1:] + + switch _command { + + case "server" : + server.Main () + + case "archiver" : + archiver.Main () + + default : + fmt.Fprintf (os.Stderr, "[!!] [44887671] unknown command: `%s`; aborting!\n", _command) + } + + } else { + fmt.Fprintf (os.Stderr, "[!!] [3628f38a] expected command: `server` or `archiver`; aborting!\n") + } +} +