mirror of
https://github.com/pcvolkmer/docker-pps.git
synced 2025-04-19 09:46:50 +00:00
Add makefile and build script
Binary will be build in corresponding GOOS-GOARCH folder. Install command will build and install binary for current platform until GOOS and/or GOARCH env var is set.
This commit is contained in:
parent
71af908d16
commit
e4850f270d
21
Makefile
Normal file
21
Makefile
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
ifndef VERBOSE
|
||||||
|
.SILENT:
|
||||||
|
endif
|
||||||
|
|
||||||
|
all: binary
|
||||||
|
|
||||||
|
.PHONY: fmt
|
||||||
|
fmt:
|
||||||
|
sh ./scripts/build.sh fmt
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
sh ./scripts/build.sh clean
|
||||||
|
|
||||||
|
.PHONY: binary
|
||||||
|
binary:
|
||||||
|
sh ./scripts/build.sh build
|
||||||
|
|
||||||
|
.PHONY: install
|
||||||
|
install:
|
||||||
|
sh ./scripts/build.sh install
|
32
scripts/build.sh
Normal file
32
scripts/build.sh
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
TARGET=${TARGET:-"target"}
|
||||||
|
|
||||||
|
GOOS="$(go env GOOS)"
|
||||||
|
GOARCH="$(go env GOARCH)"
|
||||||
|
|
||||||
|
TARGET="$TARGET/${GOOS}-${GOARCH}/docker-pps"
|
||||||
|
if [ "${GOOS}" = "windows" ]; then
|
||||||
|
TARGET="${TARGET}.exe"
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
fmt)
|
||||||
|
go fmt $(go list)
|
||||||
|
;;
|
||||||
|
clean)
|
||||||
|
rm -rf ./target
|
||||||
|
;;
|
||||||
|
build)
|
||||||
|
go build -o "${TARGET}"
|
||||||
|
;;
|
||||||
|
install)
|
||||||
|
go install
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {fmt|clean|build|install}"
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user