-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (40 loc) · 1.44 KB
/
Makefile
File metadata and controls
52 lines (40 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
export GO111MODULE = on
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
LDFLAGS := -ldflags "-s -w -X github.com/go-appsec/toolbox/sectool/config.Version=$(VERSION)"
ifneq ($(shell command -v bash),)
test test-all: SHELL := bash
test test-all: .SHELLFLAGS := -o pipefail -c
_FILTER := | grep -v "no test files"
endif
.PHONY: build build-cross clean test test-all test-cover bench lint
build:
@mkdir -p bin
go build $(LDFLAGS) -o bin/sectool ./sectool
PLATFORMS := linux-amd64 linux-arm64 darwin-amd64 darwin-arm64 windows-amd64 windows-arm64
build-cross:
@mkdir -p bin
@for platform in $(PLATFORMS); do \
os=$$(echo $$platform | cut -d'-' -f1); \
arch=$$(echo $$platform | cut -d'-' -f2); \
ext=""; \
if [ "$$os" = "windows" ]; then ext=".exe"; fi; \
echo "Building sectool for $$os/$$arch..."; \
GOOS=$$os GOARCH=$$arch go build $(LDFLAGS) -o bin/sectool-$$platform$$ext ./sectool; \
if [ "$$os" = "windows" ]; then \
(cd bin && zip sectool-$$platform.zip sectool-$$platform$$ext && rm sectool-$$platform$$ext); \
else \
gzip bin/sectool-$$platform; \
fi; \
done
clean:
rm -rf bin/
test:
go test -short ./... $(_FILTER)
test-all:
go test -race -cover ./... $(_FILTER)
test-cover:
go test -race -coverprofile=test.out ./... && go tool cover --html=test.out
bench:
go test --benchmem -benchtime=20s -bench='Benchmark.*' -run='^$$' ./...
lint:
golangci-lint run --timeout=600s && go vet ./...