-
Notifications
You must be signed in to change notification settings - Fork 164
/
Makefile
127 lines (99 loc) · 3.15 KB
/
Makefile
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Copyright (c) 2018 Zededa, Inc.
# SPDX-License-Identifier: Apache-2.0
# Goals
# 1. Build go provision binaries for arm64 and amd64
# 2. Build on Linux as well on Mac
HOSTARCH := $(subst aarch64,arm64,$(subst x86_64,amd64,$(shell uname -m)))
ZARCH ?= $(HOSTARCH)
DISTDIR := dist/$(ZARCH)
BUILD_VERSION ?=
DOCKER_ARCH_ARGS:=--platform linux/$(ZARCH)
DOCKER_ARGS:=$(DOCKER_ARCH_ARGS) --build-arg ZARCH=$(ZARCH)
DOCKER_TAG:=lfedge/eve-pillar:local-$(ZARCH)
APPS = zedbox
APPS1 = $(notdir $(wildcard cmd/*))
# find all GOFILES
GOFILES = $(shell find . -path ./vendor -prune -o -name '*go' -print)
.PHONY: all clean build test build-docker build-docker-git shell
all: build
$(DISTDIR):
mkdir -p $(DISTDIR)
build: $(APPS) $(APPS1)
TAGS=
ifeq ($(RSTATS),y)
TAGS+=rstats
endif
ifneq ($(HV),)
TAGS+=$(HV)
endif
ifneq ($(TAGS),)
TAGS:=-tags "$(TAGS)"
endif
LDFLAGS=
ifneq ($(DEV),y)
LDFLAGS+=-s -w
endif
ifeq ($(RSTATS),y)
LDFLAGS+=-X=github.com/lf-edge/eve/pkg/pillar/rstats.Endpoint=$(RSTATS_ENDPOINT)
LDFLAGS+=-X=github.com/lf-edge/eve/pkg/pillar/rstats.Tag=$(RSTATS_TAG)
endif
LDFLAGS:=-ldflags "$(LDFLAGS)"
GCFLAGS=
ifeq ($(DEV),y)
GCFLAGS:=-gcflags=all="-N -l"
endif
$(APPS): $(DISTDIR)/$(APPS)
$(DISTDIR)/$(APPS): $(DISTDIR)
@echo "Building $@"
GO111MODULE=on GOOS=linux GOARCH=$(ZARCH) go build -mod=vendor $(TAGS) $(GCFLAGS) $(LDFLAGS) -o $@ ./$(@F)
$(APPS1): $(DISTDIR)
@echo $@
@rm -f $(DISTDIR)/$@
@ln -s $(APPS) $(DISTDIR)/$@
shell:
make -C ../.. shell
build-docker:
docker build $(DOCKER_ARGS) -t $(DOCKER_TAG) .
build-docker-dev:
docker build $(DOCKER_ARGS) -t $(DOCKER_TAG) . --target build
enter-docker-dev: build-docker-dev
docker run --platform linux/$(ZARCH) -it --rm --entrypoint /bin/sh $(DOCKER_TAG)
build-docker-git:
git archive HEAD | docker build $(DOCKER_ARGS) -t $(DOCKER_TAG) -
build-docker-test:
docker build $(DOCKER_ARGS) --build-arg TEST_TOOLS=y -t $(DOCKER_TAG) . --target build
test: build-docker-test
rm -f results.json
rm -f results.xml
touch results.json
touch results.xml
docker run --memory=800m --platform linux/$(ZARCH) -w /pillar \
--mount type=bind,source=./results.json,target=/pillar/results.json \
--mount type=bind,source=./results.xml,target=/pillar/results.xml \
--entrypoint /final/opt/gotestsum $(DOCKER_TAG) \
--jsonfile /pillar/results.json \
--junitfile /pillar/results.xml \
--raw-command -- go test -tags kubevirt -coverprofile=coverage.txt -covermode=atomic -race -json \
./...
docker run --memory=800m --platform linux/$(ZARCH) -w /pillar \
--entrypoint /bin/sh $(DOCKER_TAG) \
/pillar/build-scripts/fuzz_test.sh
test-profiling-create: build-docker-test
docker run --memory=800m --platform linux/$(ZARCH) -w /pillar \
--mount type=bind,source=./,target=/pillar/ \
--entrypoint /bin/sh $(DOCKER_TAG) \
/pillar/build-scripts/memprof_test.sh
test-profiling: test-profiling-create
for i in *.profile; \
do go tool pprof -output "$${i}.png" -png "$${i}" ;\
done
clean:
@rm -rf $(DISTDIR)
fmt:
@gofmt -w -s $(GOFILES)
fmt-check:
@gofmt -l $(GOFILES)
fmt-check-details:
@gofmt -d $(GOFILES)
vet:
go vet $(TAGS) ./...