Peter Kurfer
a720b0ee41
* supports HTTP * support TLS interception e.g. for HTTPS * support CA generation via cli * first draft of plugin API * support commands from plugins * includes Dockerfile * includes basic configuration
64 lines
No EOL
1.8 KiB
Makefile
64 lines
No EOL
1.8 KiB
Makefile
VERSION = $(shell git describe --dirty --tags --always)
|
|
DIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
|
|
BUILD_PATH = $(DIR)/main.go
|
|
PKGS = $(shell go list ./...)
|
|
TEST_PKGS = $(shell find . -type f -name "*_test.go" -printf '%h\n' | sort -u)
|
|
GOARGS = GOOS=linux GOARCH=amd64
|
|
GO_BUILD_ARGS = -ldflags="-w -s"
|
|
GO_CONTAINER_BUILD_ARGS = -ldflags="-w -s" -a -installsuffix cgo
|
|
GO_DEBUG_BUILD_ARGS = -gcflags "all=-N -l"
|
|
BINARY_NAME = inetmock
|
|
PLUGINS = $(wildcard $(DIR)pkg/plugins/*/.)
|
|
DEBUG_PORT = 2345
|
|
DEBUG_ARGS?= --development-logs=true
|
|
INETMOCK_PLUGINS_DIRECTORY = $(DIR)plugins
|
|
|
|
.PHONY: clean all format deps compile debug test cli-cover-report html-cover-report plugins $(PLUGINS)
|
|
|
|
all: clean format compile test plugins
|
|
|
|
clean:
|
|
@find $(DIR) -type f \( -name "*.out" -or -name "*.so" \) -exec rm -f {} \;
|
|
@rm -rf $(DIR)plugins
|
|
@rm -f $(DIR)$(BINARY_NAME) $(DIR)main
|
|
|
|
format:
|
|
@go fmt $(PKGS)
|
|
|
|
deps:
|
|
@go mod tidy
|
|
@go build -v $(BUILD_PATH)
|
|
|
|
compile: deps
|
|
ifdef DEBUG
|
|
@echo 'Compiling for debugging...'
|
|
@$(GOARGS) go build $(GO_DEBUG_BUILD_ARGS) -o $(DIR)$(BINARY_NAME) $(BUILD_PATH)
|
|
else ifdef CONTAINER
|
|
@echo 'Compiling for container usage...'
|
|
@$(GOARGS) go build $(GO_CONTAINER_BUILD_ARGS) -o $(DIR)$(BINARY_NAME) $(BUILD_PATH)
|
|
else
|
|
@echo 'Compiling for normal Linux env...'
|
|
@$(GOARGS) go build $(GO_BUILD_ARGS) -o $(DIR)$(BINARY_NAME) $(BUILD_PATH)
|
|
endif
|
|
|
|
debug:
|
|
@export INETMOCK_PLUGINS_DIRECTORY
|
|
@dlv exec $(DIR)$(BINARY_NAME) \
|
|
--headless \
|
|
--listen=:2345 \
|
|
--api-version=2 \
|
|
--accept-multiclient \
|
|
-- $(DEBUG_ARGS)
|
|
test:
|
|
@go test -coverprofile=./cov-raw.out -v $(TEST_PKGS)
|
|
@cat ./cov-raw.out | grep -v "generated" > ./cov.out
|
|
|
|
cli-cover-report:
|
|
@go tool cover -func=cov.out
|
|
|
|
html-cover-report:
|
|
@go tool cover -html=cov.out -o .coverage.html
|
|
|
|
plugins: $(PLUGINS)
|
|
$(PLUGINS):
|
|
$(MAKE) -C $@
|