From a1b47a1637c7faa54de6245e92818b65f2d8be07 Mon Sep 17 00:00:00 2001 From: Yunkon Kim Date: Fri, 17 Nov 2023 13:51:36 +0900 Subject: [PATCH] Add Makefile in the project root directory * Newly added Makefile is compatible with existing /src/Makefile --- Makefile | 20 ++++++++++++++++++++ src/Makefile | 18 ++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..839448f1b --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +default: + cd src/ && $(MAKE) + +cc: + cd src/ && $(MAKE) cc + +run: + cd src/ && $(MAKE) run + +runwithport: + cd src/ && $(MAKE) runwithport $(PORT) + +prod: + cd src/ && $(MAKE) prod + +clean: + cd src/ && $(MAKE) clean + +swag swagger: + cd src/ && $(MAKE) swag diff --git a/src/Makefile b/src/Makefile index 97e4eb267..57ed481f2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,12 +1,26 @@ default: go build -o cb-tumblebug + cc: GOOS=linux GOARCH=arm go build -o cb-tumblebug-arm -swag swagger: - ~/go/bin/swag i -o ./api/rest/docs + run: ./cb-tumblebug + runwithport: + @echo "Running on port $(PORT) (Usage: make runwithport PORT=8080)" ./cb-tumblebug --port=$(PORT) + +prod: + @echo "Build for production" +# Note - Using cgo write normal Go code that imports a pseudo-package "C". I may not need on cross-compiling. +# Note - You can find possible platforms by 'go tool dist list' for GOOS and GOARCH +# Note - Using the -ldflags parameter can help set variable values at compile time. +# Note - Using the -s and -w linker flags can strip the debugging information. + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags '-s -w' -o cb-tumblebug + clean: rm -v cb-tumblebug cb-tumblebug-arm + +swag swagger: + ~/go/bin/swag i -o ./api/rest/docs