/
Makefile.Common
27 lines (23 loc) · 1.15 KB
/
Makefile.Common
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
# SRC_ROOT is the top of the source tree.
SRC_ROOT := $(shell git rev-parse --show-toplevel)
GO_BUILD_TAGS=""
GOCMD?= go
GOOS=$(shell $(GOCMD) env GOOS)
GOARCH=$(shell $(GOCMD) env GOARCH)
# In order to help reduce toil related to managing tooling for the open telemetry collector
# this section of the makefile looks at only requiring command definitions to be defined
# as part of $(TOOLS_MOD_DIR)/tools.go, following the existing practice.
# Modifying the tools' `go.mod` file will trigger a rebuild of the tools to help
# ensure that all contributors are using the most recent version to make builds repeatable everywhere.
TOOLS_MOD_DIR := $(SRC_ROOT)/internal/tools
TOOLS_MOD_REGEX := "\s+_\s+\".*\""
TOOLS_PKG_NAMES := $(shell grep -E $(TOOLS_MOD_REGEX) < $(TOOLS_MOD_DIR)/tools.go | tr -d " _\"")
TOOLS_BIN_DIR := $(SRC_ROOT)/.tools
TOOLS_BIN_NAMES := $(addprefix $(TOOLS_BIN_DIR)/, $(notdir $(TOOLS_PKG_NAMES)))
BUILDER := $(TOOLS_BIN_DIR)/builder
GOIMPORTS := $(TOOLS_BIN_DIR)/goimports
LINT := $(TOOLS_BIN_DIR)/golangci-lint
.PHONY: fmt
fmt: $(GOIMPORTS)
gofmt -w -s ./
$(GOIMPORTS) -w -local github.com/atoulme/stdinotel ./