Skip to content

Commit

Permalink
Improve the make experience. (open-telemetry#47)
Browse files Browse the repository at this point in the history
* Add checks for all the tools which are used by the build process.
* Switch from `which` to `commmand` since
** `command` is a builtin to the shell.
** This also fixes an issue which was causing tools to be downloaded
   reguardless of whether it has been downloaded previously.

Signed-off-by: Harold Dost <harolddost@gmail.com>
  • Loading branch information
hdost authored Dec 21, 2021
1 parent 5ddd7d9 commit 61df2fa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
22 changes: 16 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ DISTRIBUTIONS ?= "otelcol,otelcol-contrib"
ci: check build
check: ensure-goreleaser-up-to-date

build: ocb
build: go ocb
@./scripts/build.sh -d "${DISTRIBUTIONS}" -b ${OTELCOL_BUILDER} -g ${GO}

generate: generate-sources generate-goreleaser

generate-goreleaser: yq
generate-goreleaser: yq envsubst
@./scripts/generate-goreleaser-config.sh -d "${DISTRIBUTIONS}" -y "${YQ}"

generate-sources: ocb
generate-sources: go ocb
@./scripts/build.sh -d "${DISTRIBUTIONS}" -s true -b ${OTELCOL_BUILDER} -g ${GO}

goreleaser-verify:
Expand All @@ -30,7 +30,7 @@ ensure-goreleaser-up-to-date: generate-goreleaser
@git diff -s --exit-code .goreleaser.yaml || (echo "Build failed: The goreleaser templates have changed but the .goreleaser.yaml hasn't. Run 'make generate-goreleaser' and update your PR." && exit 1)

ocb:
ifeq (, $(shell which ocb >/dev/null 2>/dev/null))
ifeq (, $(shell command -v ocb 2>/dev/null))
@{ \
set -e ;\
os=$$(uname | tr A-Z a-z) ;\
Expand All @@ -43,11 +43,21 @@ ifeq (, $(shell which ocb >/dev/null 2>/dev/null))
chmod +x $(OTELCOL_BUILDER) ;\
}
else
OTELCOL_BUILDER=$(shell which ocb)
OTELCOL_BUILDER=$(shell command -v ocb)
endif

go:
ifeq (, $(shell command -v go 2>/dev/null))
$(error go command not found. Please install golang. https://go.dev/doc/install )
endif

envsubst:
ifeq (, $(shell command -v envsubst 2>/dev/null))
$(error envsubst command not found. Please install gettext. )
endif

yq:
ifeq (, $(shell which yq >/dev/null 2>/dev/null))
ifeq (, $(shell command -v yq 2>/dev/null ))
@{ \
set -e ;\
os=$$(uname | tr A-Z a-z) ;\
Expand Down
6 changes: 4 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ for distribution in $(echo $distributions | tr "," "\n")
do
pushd "${REPO_DIR}/distributions/${distribution}" > /dev/null
mkdir -p _build

echo Building: ${distribution}
echo Using Builder: ${BUILDER}
echo Using Go: ${GO}
${BUILDER} --skip-compilation=${skipcompilation} --go ${GO} --config manifest.yaml > _build/build.log 2>&1
if [ $? != 0 ]; then
echo "❌ ERROR: failed to build the distribution '${distribution}'."
Expand All @@ -46,4 +48,4 @@ do
fi

popd > /dev/null
done
done

0 comments on commit 61df2fa

Please sign in to comment.