Skip to content

Commit

Permalink
Add quick Makefile recipe
Browse files Browse the repository at this point in the history
- add `quick` recipe to build non-prod binaries for one-off
  testing purposes
- update `clean` recipe
  - prune binaries generated by new `quick` recipe
  - remove empty asset build paths

refs GH-471
  • Loading branch information
atc0005 committed Feb 6, 2023
1 parent 1748e6d commit 5ba74be
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export SEMVER := $(shell git describe --always --long)
# explicitly disable use of cgo
# removes potential need for linkage against local c library (e.g., glibc)
BUILDCMD := CGO_ENABLED=0 go build -mod=vendor -trimpath -a -ldflags "-s -w -X $(VERSION_VAR_PKG).version=$(VERSION)"
QUICK_BUILDCMD := go build -mod=vendor
GOCLEANCMD := go clean -mod=vendor ./...
GITCLEANCMD := git clean -xfd
CHECKSUMCMD := sha256sum -b
Expand Down Expand Up @@ -158,14 +159,26 @@ goclean:
@echo "Removing object files and cached files ..."
@$(GOCLEANCMD)
@echo "Removing any existing release assets"
@mkdir -p "$(OUTPUTDIR)"
@rm -vf $(wildcard ${OUTPUTDIR}/*/*-linux-*)
@rm -vf $(wildcard ${OUTPUTDIR}/*/*-windows-*)
@rm -vf $(wildcard ${OUTPUTDIR}/*.rpm)
@rm -vf $(wildcard ${OUTPUTDIR}/*.rpm.sha256)
@rm -vf $(wildcard ${OUTPUTDIR}/*.deb)
@rm -vf $(wildcard ${OUTPUTDIR}/*.deb.sha256)
@rm -vf $(wildcard ${OUTPUTDIR}/*-links.txt)
@mkdir -p "$(ROOT_PATH)"
@rm -vf $(wildcard $(ROOT_PATH)/*/*-linux-*)
@rm -vf $(wildcard $(ROOT_PATH)/*/*-windows-*)
@rm -vf $(wildcard $(ROOT_PATH)/*.rpm)
@rm -vf $(wildcard $(ROOT_PATH)/*.rpm.sha256)
@rm -vf $(wildcard $(ROOT_PATH)/*.deb)
@rm -vf $(wildcard $(ROOT_PATH)/*.deb.sha256)
@rm -vf $(wildcard $(ROOT_PATH)/*-links.txt)

@echo "Removing any existing quick build release assets"
@for target in $(WHAT); do \
rm -vf $(ROOT_PATH)/$${target}/$${target}; \
done

@echo "Removing any empty asset build paths"
@for target in $(WHAT); do \
if [ -d "$(ROOT_PATH)/$${target}" ]; then \
rmdir --verbose --ignore-fail-on-non-empty $(ROOT_PATH)/$${target}; \
fi; \
done

.PHONY: clean
## clean: alias for goclean
Expand Down Expand Up @@ -212,6 +225,19 @@ depsinstall: gogeninstall
all: clean windows linux
@echo "Completed all cross-platform builds ..."

.PHONY: quick
## quick: generates non-release binaries for current platform, arch
quick:
@echo "Building non-release assets for current platform, arch ..."

@for target in $(WHAT); do \
mkdir -p $(ROOT_PATH)/$${target} && \
echo " Building $${target} binary" && \
$(QUICK_BUILDCMD) -o $(ROOT_PATH)/$${target}/$${target} ${PWD}/cmd/$${target}; \
done

@echo "Completed tasks for quick build"

.PHONY: windows-x86
## windows-x86: generates assets for Windows x86 systems
windows-x86:
Expand Down

0 comments on commit 5ba74be

Please sign in to comment.