mirror of
https://github.com/DJSundog/wg-portal.git
synced 2024-11-23 07:03:50 -05:00
52 lines
1.5 KiB
Makefile
52 lines
1.5 KiB
Makefile
# Go parameters
|
|
GOCMD=go
|
|
MODULENAME=github.com/h44z/wg-portal
|
|
GOFILES:=$(shell go list ./... | grep -v /vendor/)
|
|
BUILDDIR=dist
|
|
BINARIES=$(subst cmd/,,$(wildcard cmd/*))
|
|
IMAGE=h44z/wg-portal
|
|
|
|
.PHONY: all test clean phony
|
|
|
|
all: dep build
|
|
|
|
build: dep $(addprefix $(BUILDDIR)/,$(BINARIES))
|
|
cp -r assets $(BUILDDIR)
|
|
cp scripts/wg-portal.service $(BUILDDIR)
|
|
cp scripts/wg-portal.env $(BUILDDIR)
|
|
|
|
dep:
|
|
$(GOCMD) mod download
|
|
|
|
validate: dep
|
|
$(GOCMD) fmt $(GOFILES)
|
|
$(GOCMD) vet $(GOFILES)
|
|
$(GOCMD) test -race $(GOFILES)
|
|
|
|
coverage: dep
|
|
$(GOCMD) fmt $(GOFILES)
|
|
$(GOCMD) test $(GOFILES) -v -coverprofile .testCoverage.txt
|
|
$(GOCMD) tool cover -func=.testCoverage.txt # use total:\s+\(statements\)\s+(\d+.\d+\%) as Gitlab CI regextotal:\s+\(statements\)\s+(\d+.\d+\%)
|
|
|
|
coverage-html: coverage
|
|
$(GOCMD) tool cover -html=.testCoverage.txt
|
|
|
|
test: dep
|
|
$(GOCMD) test $(MODULENAME)/... -v -count=1
|
|
|
|
clean:
|
|
$(GOCMD) clean $(GOFILES)
|
|
rm -rf .testCoverage.txt
|
|
rm -rf $(BUILDDIR)
|
|
|
|
docker-build:
|
|
docker build -t $(IMAGE) .
|
|
|
|
docker-push:
|
|
docker push $(IMAGE)
|
|
|
|
# For arch install: arm-linux-gnueabihf-gcc and aarch64-linux-gnu-gcc to crosscompile for arm
|
|
$(BUILDDIR)/%: cmd/%/main.go dep phony
|
|
GOOS=linux GOARCH=amd64 $(GOCMD) build -o $@-amd64 $<
|
|
CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc GOOS=linux GOARCH=arm64 $(GOCMD) build -ldflags "-linkmode external -extldflags -static" -o $@-arm64 $<
|
|
CGO_ENABLED=1 CC=arm-linux-gnueabihf-gcc GOOS=linux GOARCH=arm GOARM=7 $(GOCMD) build -ldflags "-linkmode external -extldflags -static" -o $@-arm $<
|