-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- migrate to docker-based ocb - upgrade to 0.112.0 ocb and components - make build targets lazy
- Loading branch information
1 parent
394fd45
commit e11d2bd
Showing
11 changed files
with
177 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,63 @@ | ||
############################################# | ||
#### Common Makefiles for distributions ##### | ||
############################################# | ||
# Note: file is included in Makefile within distro folders, | ||
# so paths are relative to distro folder unless they use SRC_ROOT | ||
|
||
# SRC_ROOT is the top of the source tree. | ||
SRC_ROOT := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) | ||
BUILD_DIR=$(shell basename $(shell yq '.dist.output_path' 'manifest.yaml')) | ||
|
||
FIND_MOD_ARGS=-type f -name "go.mod" | ||
TO_MOD_DIR=dirname {} \; | sort | grep -E '^./' | ||
DISTRIBUTIONS_MODS := $(shell find ./**/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) | ||
|
||
## Retrive all used dependencies in the same output | ||
# RESULTS := $(foreach dir,$(DISTRIBUTIONS_MODS),$(shell cd $(dir) && go list -mod=mod -m -json all)) | ||
######################## | ||
#### Check targets ##### | ||
######################## | ||
|
||
.PHONY: assert_build-dir | ||
assert_build-dir: | ||
@test $(BUILD_DIR) = _build || (echo "expected build directory _build but was $(BUILD_DIR): required because it is hardcoded for goreleaser" && exit 1) | ||
|
||
NOTICE_OUTPUT ?= THIRD_PARTY_NOTICES.md | ||
GO_MOD_TMP_FILE ?= /tmp/tmp_notices.json | ||
|
||
.PHONY: third-party-notices | ||
third-party-notices: OUT ?= THIRD_PARTY_NOTICES.md | ||
third-party-notices: | ||
third-party-notices: assert_build-dir | ||
@command -v go-licence-detector &> /dev/null || (echo "go-license-detector tool not found, install it from the base directory with \"make internal/tools\"" && exit 1) | ||
$(foreach dir,$(DISTRIBUTIONS_MODS),$(shell cd $(dir) && go list -mod=mod -m -json all >> /tmp/tmp_notices.json)) | ||
@go-licence-detector \ | ||
-in /tmp/tmp_notices.json \ | ||
-rules $(SRC_ROOT)/internal/assets/license/rules.json \ | ||
-noticeTemplate $(SRC_ROOT)/internal/assets/license/THIRD_PARTY_NOTICES.md.tmpl \ | ||
-noticeOut $(OUT) | ||
@echo '' > /tmp/tmp_notices.json | ||
echo '' > $(GO_MOD_TMP_FILE);\ | ||
cd $(BUILD_DIR) && go list -mod=mod -m -json all >> $(GO_MOD_TMP_FILE);\ | ||
go-licence-detector \ | ||
-in $(GO_MOD_TMP_FILE) \ | ||
-rules $(SRC_ROOT)/internal/assets/license/rules.json \ | ||
-noticeTemplate $(SRC_ROOT)/internal/assets/license/THIRD_PARTY_NOTICES.md.tmpl \ | ||
-noticeOut $(NOTICE_OUTPUT) | ||
|
||
.PHONY: third-party-notices-check | ||
third-party-notices-check: third-party-notices | ||
@git diff --name-only | grep -q "THIRD_PARTY_NOTICES.md" && { echo "Third party notices out of date, please run \"make licenses\" and commit the changes in this PR."; exit 1; } || exit 0 | ||
@git diff --name-only | grep -q $(NOTICE_OUTPUT) \ | ||
&& { \ | ||
echo "Third party notices out of date, please run \"make licenses\" and commit the changes in this PR.";\ | ||
echo "Diff of $(NOTICE_OUTPUT):";\ | ||
git --no-pager diff HEAD -- $(NOTICE_OUTPUT);\ | ||
echo "go.mod file used:";\ | ||
cat $(BUILD_DIR)/go.mod;\ | ||
exit 1;\ | ||
} \ | ||
|| exit 0 | ||
|
||
|
||
######################## | ||
#### Build targets ##### | ||
######################## | ||
DISTRO_NAME=$(shell basename $(shell pwd)) | ||
BINARY_NAME=$(shell yq '.dist.name' 'manifest.yaml') | ||
|
||
build-distro: assert_build-dir $(BUILD_DIR)/$(BINARY_NAME) | ||
$(BUILD_DIR)/$(BINARY_NAME): manifest.yaml | ||
$(SRC_ROOT)/scripts/build.sh -d $(DISTRO_NAME) | ||
|
||
generate-sources-for-distro: assert_build-dir $(BUILD_DIR)/go.mod | ||
$(BUILD_DIR)/go.mod: manifest.yaml | ||
$(SRC_ROOT)/scripts/build.sh -d $(DISTRO_NAME) -s true | ||
|
||
.PHONY: clean-build-dir-distro | ||
clean-build-dir-distro: | ||
rm -rf $(BUILD_DIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,14 @@ | ||
GO ?= go | ||
GORELEASER ?= goreleaser | ||
|
||
OTELCOL_BUILDER_VERSION ?= 0.108.0 | ||
OTELCOL_BUILDER_DIR ?= ${HOME}/bin | ||
OTELCOL_BUILDER ?= ${OTELCOL_BUILDER_DIR}/ocb | ||
|
||
DISTRIBUTIONS ?= "nr-otel-collector" | ||
|
||
.PHONY: ci | ||
ci: build | ||
|
||
build: go ocb | ||
@./scripts/build.sh -d "${DISTRIBUTIONS}" -b ${OTELCOL_BUILDER} -g ${GO} | ||
|
||
generate: generate-sources | ||
|
||
generate-sources: go ocb | ||
@./scripts/build.sh -d "${DISTRIBUTIONS}" -s true -b ${OTELCOL_BUILDER} -g ${GO} | ||
|
||
goreleaser-verify: goreleaser | ||
@${GORELEASER} release --snapshot --rm-dist | ||
|
||
.PHONY: ocb | ||
ocb: | ||
ifeq (, $(shell command -v ocb 2>/dev/null)) | ||
@{ \ | ||
[ ! -x '$(OTELCOL_BUILDER)' ] || exit 0; \ | ||
set -e ;\ | ||
os=$$(uname | tr A-Z a-z) ;\ | ||
machine=$$(uname -m) ;\ | ||
[ "$${machine}" != x86 ] || machine=386 ;\ | ||
[ "$${machine}" != x86_64 ] || machine=amd64 ;\ | ||
[ "$${machine}" != aarch64 ] || machine=arm64 ;\ | ||
echo "Installing ocb ($${os}/$${machine}) at $(OTELCOL_BUILDER_DIR)";\ | ||
mkdir -p $(OTELCOL_BUILDER_DIR) ;\ | ||
curl -sLo $(OTELCOL_BUILDER) "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/cmd%2Fbuilder%2Fv$(OTELCOL_BUILDER_VERSION)/ocb_$(OTELCOL_BUILDER_VERSION)_$${os}_$${machine}" ;\ | ||
chmod +x $(OTELCOL_BUILDER) ;\ | ||
} | ||
else | ||
OTELCOL_BUILDER=$(shell command -v ocb) | ||
endif | ||
.PHONY: build | ||
build: | ||
@$(MAKE) for-all-target TARGET="build-distro" | ||
|
||
.PHONY: go | ||
go: | ||
@{ \ | ||
if ! command -v '$(GO)' >/dev/null 2>/dev/null; then \ | ||
echo >&2 '$(GO) command not found. Please install golang. https://go.dev/doc/install'; \ | ||
exit 1; \ | ||
fi \ | ||
} | ||
.PHONY: generate-sources | ||
generate-sources: | ||
@$(MAKE) for-all-target TARGET="generate-sources-for-distro" | ||
|
||
.PHONY: goreleaser | ||
goreleaser: | ||
@{ \ | ||
if ! command -v '$(GORELEASER)' >/dev/null 2>/dev/null; then \ | ||
echo >&2 '$(GORELEASER) command not found. Please install goreleaser. https://goreleaser.com/install/'; \ | ||
exit 1; \ | ||
fi \ | ||
} | ||
.PHONY: clean-build-dir | ||
clean-build-dir: | ||
@$(MAKE) for-all-target TARGET="clean-build-dir-distro" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,7 @@ | ||
|
||
GROUP ?= all | ||
FOR_GROUP_TARGET=for-$(GROUP)-target | ||
|
||
# Define a delegation target for each distribution | ||
.PHONY: $(ALL_DISTRIBUTIONS) | ||
$(ALL_DISTRIBUTIONS): | ||
$(MAKE) -C $@ $(TARGET) | ||
|
||
# Trigger each module's delegation target | ||
.PHONY: for-all-target | ||
for-all-target: $(ALL_DISTRIBUTIONS) | ||
|
||
.PHONY: licenses | ||
licenses: internal/tools build | ||
@$(MAKE) $(FOR_GROUP_TARGET) TARGET="third-party-notices" | ||
licenses: internal/tools generate-sources | ||
@$(MAKE) for-all-target TARGET="third-party-notices" | ||
|
||
.PHONY: licenses-check | ||
licenses-check: internal/tools build | ||
@$(MAKE) $(FOR_GROUP_TARGET) TARGET="third-party-notices-check" | ||
licenses-check: internal/tools generate-sources | ||
@$(MAKE) for-all-target TARGET="third-party-notices-check" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.