Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ goporto: $(PORTO)

.PHONY: for-all
for-all:
@set -e; for dir in $(ALL_MODS); do \
@set -e; for dir in $${ALL_MODS}; do \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed given the limits for command-line length on Windows. This way ALL_MODS is passed as an environment variable instead of being expanded in place.

(cd "$${dir}" && \
echo "running $${CMD} in $${dir}" && \
$${CMD} ); \
Expand Down
29 changes: 26 additions & 3 deletions Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ GOTESTSUM := $(TOOLS_BIN_DIR)/gotestsum
CHECKAPI := $(TOOLS_BIN_DIR)/checkapi
MODERNIZE := $(TOOLS_BIN_DIR)/modernize

# Tools used by go generate commands
MDATAGEN := $(TOOLS_BIN_DIR)/mdatagen
# The githubreceiver uses a "go generate" tool that is not used by other components.
GENQLIENT := $(TOOLS_BIN_DIR)/genqlient

GOTESTSUM_OPT?= --rerun-fails=1

# BUILD_TYPE should be one of (dev, release).
Expand Down Expand Up @@ -244,13 +249,31 @@ fmt: $(GOFUMPT) $(GOIMPORTS)
$(GOFUMPT) -l -w -extra .
$(GOIMPORTS) -w -local github.com/open-telemetry/opentelemetry-collector-contrib ./

.PHONY: generate-tools
generate-tools: $(MDATAGEN) $(GENQLIENT)
ifeq ($(GOOS),windows)
@echo Adding "exe" extensions to generate tools
@for f in $^; do \
cp -u "$$f" "$$f.exe"; \
done
endif

# On Windows changing path with absolute path includes ':' even escaping it is not enough to get it to correctly
# update PATH, so use a relative path when pre-pending to PATH on Windows. Unfortunately, realpath is not portable
# between mac and GNU based bash so keeping the full path on non-Windows OSes.
ifeq ($(GOOS),windows)
TOOLS_BIN_DIR_PORTABLE?=$(shell realpath --relative-to="$(CURDIR)" "$(TOOLS_BIN_DIR)")
else
TOOLS_BIN_DIR_PORTABLE?=$(TOOLS_BIN_DIR)
endif

.PHONY: generate
generate: install-tools
generate: generate-tools
ifeq ($(CURDIR),$(SRC_ROOT))
PATH="$(TOOLS_BIN_DIR):$$PATH" $(MAKE) for-all CMD="$(GOCMD) generate ./..."
PATH="$(TOOLS_BIN_DIR_PORTABLE):$$PATH" $(MAKE) for-all CMD="$(GOCMD) generate ./..."
$(MAKE) gofmt
else
PATH="$(TOOLS_BIN_DIR):$$PATH" $(GOCMD) generate ./...
PATH="$(TOOLS_BIN_DIR_PORTABLE):$$PATH" $(GOCMD) generate ./...
$(MAKE) fmt
endif

Expand Down