Skip to content

Commit

Permalink
[chore] make generate respects GROUP and uses mdatagen in .tools
Browse files Browse the repository at this point in the history
  • Loading branch information
jade-guiton-dd committed Nov 18, 2024
1 parent 97659b5 commit 15b1cbb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ PKG_MODS := $(shell find ./pkg/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) )
CMD_MODS_0 := $(shell find ./cmd/[a-m]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) )
CMD_MODS_1 := $(shell find ./cmd/[n-z]* $(FIND_MOD_ARGS) -not -path "./cmd/otel*col/*" -exec $(TO_MOD_DIR) )
CMD_MODS := $(CMD_MODS_0) $(CMD_MODS_1)
OTHER_MODS := $(shell find . $(EX_COMPONENTS) $(EX_INTERNAL) $(EX_PKG) $(EX_CMD) $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) $(PWD)
OTHER_MODS := $(shell find . $(EX_COMPONENTS) $(EX_INTERNAL) $(EX_PKG) $(EX_CMD) $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) .
ALL_MODS := $(RECEIVER_MODS) $(PROCESSOR_MODS) $(EXPORTER_MODS) $(EXTENSION_MODS) $(CONNECTOR_MODS) $(INTERNAL_MODS) $(PKG_MODS) $(CMD_MODS) $(OTHER_MODS)
CGO_MODS := ./receiver/hostmetricsreceiver

Expand Down Expand Up @@ -307,8 +307,7 @@ docker-telemetrygen:

.PHONY: generate
generate: install-tools
cd ./internal/tools && go install go.opentelemetry.io/collector/cmd/mdatagen
$(MAKE) for-all CMD="$(GOCMD) generate ./..."
PATH="$$PWD/.tools:$$PATH" $(MAKE) $(FOR_GROUP_TARGET) TARGET="modgenerate"
$(MAKE) gofmt

.PHONY: githubgen-install
Expand Down
24 changes: 14 additions & 10 deletions Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -83,29 +83,29 @@ TESTIFYLINT_OPT?= --enable-all --disable=float-compare,require-error,suite-subte
# BUILD_TYPE should be one of (dev, release).
BUILD_TYPE?=release

ALL_PKG_DIRS := $(shell $(GOCMD) list -f '{{ .Dir }}' ./... | $(NORMALIZE_DIRS))
ALL_PKG_DIRS = $(shell $(GOCMD) list -f '{{ .Dir }}' ./... | $(NORMALIZE_DIRS))

ALL_SRC := $(shell find $(ALL_PKG_DIRS) -name '*.go' \
ALL_SRC = $(shell find $(ALL_PKG_DIRS) -name '*.go' \
-not -path '*/third_party/*' \
-not -path '*/local/*' \
-type f | sort)

ALL_SRC_AND_SHELL := find . -type f \( -iname '*.go' -o -iname "*.sh" \) ! -path '**/third_party/*' | sort
ALL_SRC_AND_SHELL = find . -type f \( -iname '*.go' -o -iname "*.sh" \) ! -path '**/third_party/*' | sort

# All source code and documents. Used in spell check.
ALL_SRC_AND_DOC_CMD := find $(ALL_PKG_DIRS) -name "*.md" -o -name "*.go" -o -name "*.yaml" -not -path '*/third_party/*' -type f | sort
ALL_SRC_AND_DOC_CMD = find $(ALL_PKG_DIRS) -name "*.md" -o -name "*.go" -o -name "*.yaml" -not -path '*/third_party/*' -type f | sort
ifeq ($(UNIX_SHELL_ON_WINDOWS),true)
# Windows has a low limit, 8192 chars, to create a process. Workaround it by breaking it in smaller commands.
MISSPELL_CMD := $(ALL_SRC_AND_DOC_CMD) | xargs -n 20 $(MISSPELL)
MISSPELL_CORRECTION_CMD := $(ALL_SRC_AND_DOC_CMD) | xargs -n 20 $(MISSPELL_CORRECTION)
MISSPELL_CMD = $(ALL_SRC_AND_DOC_CMD) | xargs -n 20 $(MISSPELL)
MISSPELL_CORRECTION_CMD = $(ALL_SRC_AND_DOC_CMD) | xargs -n 20 $(MISSPELL_CORRECTION)
else
ALL_SRC_AND_DOC := $(shell $(ALL_SRC_AND_DOC_CMD))
MISSPELL_CMD := $(MISSPELL) $(ALL_SRC_AND_DOC)
MISSPELL_CORRECTION_CMD := $(MISSPELL_CORRECTION) $(ALL_SRC_AND_DOC)
ALL_SRC_AND_DOC = $(shell $(ALL_SRC_AND_DOC_CMD))
MISSPELL_CMD = $(MISSPELL) $(ALL_SRC_AND_DOC)
MISSPELL_CORRECTION_CMD = $(MISSPELL_CORRECTION) $(ALL_SRC_AND_DOC)
endif

# ALL_PKGS is used with 'go cover'
ALL_PKGS := $(shell $(GOCMD) list $(sort $(dir $(ALL_SRC))))
ALL_PKGS = $(shell $(GOCMD) list $(sort $(dir $(ALL_SRC))))

ADDLICENSE_CMD := $(ADDLICENSE) -s=only -y "" -c "The OpenTelemetry Authors"

Expand Down Expand Up @@ -254,3 +254,7 @@ testifylint-fix:
gci: $(TOOLS_BIN_DIR)/gci
@echo "running $(GCI)"
@$(GCI) write -s standard -s default -s "prefix(github.com/open-telemetry/opentelemetry-collector-contrib)" $(ALL_SRC_AND_DOC)

.PHONY: modgenerate
modgenerate:
$(GOCMD) generate ./...

0 comments on commit 15b1cbb

Please sign in to comment.