-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathmakefile
More file actions
97 lines (74 loc) · 2.46 KB
/
makefile
File metadata and controls
97 lines (74 loc) · 2.46 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
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
# Function to execute a command.
# Accepts command to execute as first parameter.
define exec-command
$(1)
endef
GOCMD?= go
# SRC_ROOT is the top of the source tree.
SRC_ROOT := $(shell git rev-parse --show-toplevel)
TOOLS_MOD_DIR := $(SRC_ROOT)/internal/tools
TOOLS_MOD := $(TOOLS_MOD_DIR)/go.mod
GOFUMPT := go tool -modfile $(TOOLS_MOD) gofumpt
GOIMPORTS := go tool -modfile $(TOOLS_MOD) goimports
GOACC := go tool -modfile $(TOOLS_MOD) go-acc
# Find all .proto files.
BASELINE_PROTO_FILES := $(wildcard internal/opamp-spec/proto/*.proto)
all: test build-examples
.PHONY: test
test:
$(GOCMD) test -race ./...
cd internal/examples && $(GOCMD) test -race ./...
.PHONY: test-with-cover
test-with-cover:
$(GOACC) --output=coverage.out --ignore=protobufs ./...
show-coverage: test-with-cover
# Show coverage as HTML in the default browser.
$(GOCMD) tool cover -html=coverage.out
.PHONY: build-examples
build-examples:
$(MAKE) -C internal/examples build-examples
.PHONY: build-example-agent
build-example-agent:
$(MAKE) -C internal/examples build-example-agent
.PHONY: build-example-supervisor
build-example-supervisor:
$(MAKE) -C internal/examples build-example-supervisor
.PHONY: build-example-server
build-example-server:
$(MAKE) -C internal/examples build-example-server
.PHONY: run-examples
run-examples:
$(MAKE) -C internal/examples run-examples
OTEL_DOCKER_PROTOBUF ?= otel/build-protobuf:0.14.0
# Generate Protobuf Go files.
.PHONY: gen-proto
gen-proto:
mkdir -p ${PWD}/internal/proto/
@if [ ! -d "${PWD}/internal/opamp-spec/proto" ]; then \
echo "${PWD}/internal/opamp-spec/proto does not exist."; \
echo "Run \`git submodule update --init\` to fetch the submodule"; \
exit 1; \
fi
$(foreach file,$(BASELINE_PROTO_FILES),$(call exec-command,docker run --rm -v${PWD}:${PWD} \
-w${PWD} $(OTEL_DOCKER_PROTOBUF) --proto_path=${PWD}/internal/opamp-spec/proto/ \
--go_out=${PWD}/internal/proto/ -I${PWD}/internal/proto/ ${PWD}/$(file)))
cp -R internal/proto/github.com/open-telemetry/opamp-go/protobufs/* protobufs/
rm -rf internal/proto/github.com/
$(MAKE) fmt
.PHONY: gomoddownload
gomoddownload:
$(GOCMD) mod download
.PHONY: install-tools
install-tools:
go get -modfile $(TOOLS_MOD) tool
.PHONY: tidy
tidy:
rm -fr go.sum
$(GOCMD) mod tidy
cd internal/examples && rm -fr go.sum && $(GOCMD) mod tidy
cd $(TOOLS_MOD_DIR) && rm -fr go.sum && $(GOCMD) mod tidy
.PHONY: fmt
fmt:
gofmt -w -s ./
$(GOIMPORTS) -w ./
$(GOFUMPT) -l -w .