mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 12:42:34 +02:00
fix Makefile
This commit is contained in:
parent
91f6369ba9
commit
e7ff7402b4
1 changed files with 31 additions and 29 deletions
58
Makefile
58
Makefile
|
@ -4,38 +4,53 @@ export GOOS = linux
|
||||||
|
|
||||||
LDFLAGS = -X github.com/yusing/go-proxy/pkg.version=${VERSION}
|
LDFLAGS = -X github.com/yusing/go-proxy/pkg.version=${VERSION}
|
||||||
|
|
||||||
|
|
||||||
|
ifeq ($(agent), 1)
|
||||||
|
NAME = godoxy-agent
|
||||||
|
CMD_PATH = ./agent/cmd
|
||||||
|
else
|
||||||
|
NAME = godoxy
|
||||||
|
CMD_PATH = ./cmd
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(trace), 1)
|
ifeq ($(trace), 1)
|
||||||
debug = 1
|
debug = 1
|
||||||
GODOXY_TRACE ?= 1
|
GODOXY_TRACE ?= 1
|
||||||
|
GODEBUG = gctrace=1 inittrace=1 schedtrace=3000
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(race), 1)
|
||||||
|
debug = 1
|
||||||
|
BUILD_FLAGS += -race
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(debug), 1)
|
ifeq ($(debug), 1)
|
||||||
CGO_ENABLED = 0
|
CGO_ENABLED = 0
|
||||||
GODOXY_DEBUG = 1
|
GODOXY_DEBUG = 1
|
||||||
BUILD_FLAGS = -tags production
|
BUILD_FLAGS += -gcflags=all='-N -l'
|
||||||
else ifeq ($(pprof), 1)
|
endif
|
||||||
|
|
||||||
|
ifeq ($(pprof), 1)
|
||||||
CGO_ENABLED = 1
|
CGO_ENABLED = 1
|
||||||
GODEBUG = gctrace=1 inittrace=1 schedtrace=3000
|
GORACE = log_path=logs/pprof strip_path_prefix=$(shell pwd)/ halt_on_error=1
|
||||||
GORACE = log_path=logs/pprof strip_path_prefix=$(shell pwd)/
|
BUILD_FLAGS = -tags pprof
|
||||||
BUILD_FLAGS = -race -gcflags=all='-N -l' -tags pprof
|
VERSION := ${VERSION}-pprof
|
||||||
DOCKER_TAG = pprof
|
|
||||||
VERSION += -pprof
|
|
||||||
else
|
else
|
||||||
CGO_ENABLED = 0
|
CGO_ENABLED = 0
|
||||||
LDFLAGS += -s -w
|
LDFLAGS += -s -w
|
||||||
BUILD_FLAGS = -pgo=auto -tags production
|
BUILD_FLAGS = -pgo=auto -tags production
|
||||||
DOCKER_TAG = latest
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
BUILD_FLAGS += -ldflags='$(LDFLAGS)'
|
BUILD_FLAGS += -ldflags='$(LDFLAGS)'
|
||||||
|
|
||||||
|
export NAME
|
||||||
|
export CMD_PATH
|
||||||
export CGO_ENABLED
|
export CGO_ENABLED
|
||||||
export GODOXY_DEBUG
|
export GODOXY_DEBUG
|
||||||
export GODOXY_TRACE
|
export GODOXY_TRACE
|
||||||
export GODEBUG
|
export GODEBUG
|
||||||
export GORACE
|
export GORACE
|
||||||
export BUILD_FLAGS
|
export BUILD_FLAGS
|
||||||
export DOCKER_TAG
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
GODOXY_TEST=1 go test ./internal/...
|
GODOXY_TEST=1 go test ./internal/...
|
||||||
|
@ -45,14 +60,14 @@ get:
|
||||||
|
|
||||||
build:
|
build:
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
go build ${BUILD_FLAGS} -o bin/godoxy ./cmd
|
go build ${BUILD_FLAGS} -o bin/${NAME} ${CMD_PATH}
|
||||||
if [ $(shell id -u) -eq 0 ]; \
|
if [ $(shell id -u) -eq 0 ]; \
|
||||||
then setcap CAP_NET_BIND_SERVICE=+eip bin/godoxy; \
|
then setcap CAP_NET_BIND_SERVICE=+eip bin/${NAME}; \
|
||||||
else sudo setcap CAP_NET_BIND_SERVICE=+eip bin/godoxy; \
|
else sudo setcap CAP_NET_BIND_SERVICE=+eip bin/${NAME}; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
run:
|
run:
|
||||||
[ -f .env ] && godotenv -f .env go run ${BUILD_FLAGS} ./cmd
|
[ -f .env ] && godotenv -f .env go run ${BUILD_FLAGS} ${CMD_PATH}
|
||||||
|
|
||||||
mtrace:
|
mtrace:
|
||||||
bin/godoxy debug-ls-mtrace > mtrace.json
|
bin/godoxy debug-ls-mtrace > mtrace.json
|
||||||
|
@ -72,21 +87,8 @@ ci-test:
|
||||||
cloc:
|
cloc:
|
||||||
cloc --not-match-f '_test.go$$' cmd internal pkg
|
cloc --not-match-f '_test.go$$' cmd internal pkg
|
||||||
|
|
||||||
push-docker-io:
|
link-binary:
|
||||||
BUILDER=build docker buildx build \
|
ln -s /app/${NAME} bin/run
|
||||||
--platform linux/arm64,linux/amd64 \
|
|
||||||
-f Dockerfile \
|
|
||||||
-t docker.io/yusing/godoxy-nightly:${DOCKER_TAG} \
|
|
||||||
-t docker.io/yusing/godoxy-nightly:${VERSION}-${BUILD_DATE} \
|
|
||||||
--build-arg VERSION="${VERSION}-nightly-${BUILD_DATE}" \
|
|
||||||
--build-arg BUILD_FLAGS="${BUILD_FLAGS}" \
|
|
||||||
--push .
|
|
||||||
|
|
||||||
build-docker:
|
|
||||||
docker build -t godoxy-nightly \
|
|
||||||
--build-arg VERSION="${VERSION}-nightly-${BUILD_DATE}" \
|
|
||||||
--build-arg BUILD_FLAGS="${BUILD_FLAGS}" \
|
|
||||||
.
|
|
||||||
|
|
||||||
# To generate schema
|
# To generate schema
|
||||||
# comment out this part from typescript-json-schema.js#L884
|
# comment out this part from typescript-json-schema.js#L884
|
||||||
|
|
Loading…
Add table
Reference in a new issue