-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
165 additions
and
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ else | |
endif | ||
|
||
GOBIN ?= $(shell go env GOPATH)/bin | ||
GOMAKE ?= github.com/tkrop/[email protected].23 | ||
GOMAKE ?= github.com/tkrop/[email protected].24 | ||
TARGETS := $(shell command -v go-make >/dev/null || \ | ||
go install $(GOMAKE) && go-make targets) | ||
|
||
|
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 |
---|---|---|
|
@@ -64,13 +64,13 @@ TOOLS_GO := $(TOOLS_GO) \ | |
github.com/icholy/gomajor \ | ||
github.com/golang/mock/mockgen \ | ||
github.com/tkrop/go-testing/cmd/mock \ | ||
github.com/tkrop/go-make | ||
github.com/tkrop/go-make@v0.0.24 | ||
TOOLS_SH := $(TOOLS_SH) \ | ||
github.com/anchore/syft \ | ||
github.com/anchore/grype | ||
|
||
# function for correct gol-package handling. | ||
go-pkg = $(shell awk -v mode="$(1)" -v filter="$(3)" -v not="$(4)" ' \ | ||
# function for correct go-package handling. | ||
go-pkg = $(shell awk -v mode="$(2)" -v filter="$(3)" -v not="$(4)" ' \ | ||
BEGIN { FS = "[/@]"; RS = "[ \n\r]" } { \ | ||
field = NF; \ | ||
if (version = index($$0, "@")) { field-- } \ | ||
|
@@ -98,8 +98,15 @@ go-pkg = $(shell awk -v mode="$(1)" -v filter="$(3)" -v not="$(4)" ' \ | |
if (version) { \ | ||
return substr($$0, 1, index($$0, "@") - 1) \ | ||
} else { return $$0 } \ | ||
}' <<<"$(2)") | ||
|
||
}' <<<"$(1)") | ||
git-pkg = $(shell awk -v mode="$(2)" ' \ | ||
BEGIN { RS = "[ \n\r]" } { \ | ||
if (mode == "repo") { \ | ||
print "git@" gensub("/",":",1,substr($$0, 1, index($$0, "@") - 1)) ".git" \ | ||
} else if (mode == "tag") { \ | ||
print substr($$0, index($$0, "@") + 1) \ | ||
} \ | ||
}' <<<"$(1)") | ||
|
||
BROWSER ?= xdg-open | ||
VERSION ?= snapshot | ||
|
@@ -220,8 +227,8 @@ COMMANDS := $(shell $(FIND) -name "main.go" | xargs -r readlink -f | \ | |
COMMANDS_PKG := $(shell $(FIND) -name "main.go" | xargs -r readlink -f | \ | ||
sed -E "s/^(.*\/([^/]*))\/main.go$$/\2=\1/; s|$(CURDIR)|.|") | ||
COMMANDS_REGEX := $(shell echo "^$(COMMANDS)$$" | tr ' ' '|' ) | ||
COMMANDS_GO := $(call go-pkg,cmd,$(TOOLS_GO),$(COMMANDS_REGEX),not) | ||
COMMANDS_SH := $(call go-pkg,cmd,$(TOOLS_SH),$(COMMANDS_REGEX),not) | ||
COMMANDS_GO := $(call go-pkg,$(TOOLS_GO),cmd,$(COMMANDS_REGEX),not) | ||
COMMANDS_SH := $(call go-pkg,$(TOOLS_SH),cmd,$(COMMANDS_REGEX),not) | ||
|
||
|
||
# Setup optimized golang mock setup environment. | ||
|
@@ -368,15 +375,21 @@ targets:: | |
else cat -; fi || true; | ||
|
||
#@ create a clone of the base repository to update from. | ||
BASE ?= [email protected]:tkrop/go-make.git | ||
setup/base:: # TODO: support cloning of a distinct revision. | ||
GOMAKE ?= $(call go-pkg,$(TOOLS_GO),install,^go-make$$) | ||
setup/base:: | ||
@$(eval BASEDIR = $(shell mktemp -d)) ( \ | ||
trap "rm -rf $${DIR}" INT TERM EXIT; \ | ||
while pgrep $(MAKE) > /dev/null; do sleep 1; done; \ | ||
rm -rf $${DIR} \ | ||
) & \ | ||
REPO="$(call git-pkg,$(GOMAKE),repo)"; TAG="$(call git-pkg,$(GOMAKE),tag)"; \ | ||
git clone --no-checkout --depth 2 --single-branch \ | ||
--branch main $(BASE) $(BASEDIR) 2> /dev/null; \ | ||
--branch main $${REPO} $(BASEDIR) 2> /dev/null || \ | ||
( echo "error: cloning repo $${REPO} [$${TAG}]" >"/dev/stderr"; exit 1 ) && \ | ||
if [ "$${TAG}" != "latest" ]; then \ | ||
cd $(BASEDIR) && git checkout tags/$${TAG} 2> /dev/null || \ | ||
( echo "error: finding tag $${REPO} [$${TAG}]" >"/dev/stderr"; exit 1 ) \ | ||
fi; | ||
|
||
|
||
## Git-Support: targets for standard git commands (experimental). | ||
|
@@ -397,23 +410,23 @@ git-graph:: | |
--pretty=format:"%Cred%h %Cgreen%ad%Creset | %s $${SUFFIX}"; | ||
#@ cleans up all local branches except the default and current branch. | ||
git-clean:: | ||
@BRANCH="$$(git branch --show-current)"; \ | ||
@git fetch; BRANCH="$$(git branch --show-current)"; \ | ||
MAIN="$$(git remote show origin | grep "HEAD branch:" | cut -d ' ' -f 5)"; \ | ||
BRANCHES=($$(git branch | cut -c 3- | grep -vw "$${MAIN}\|$${BRANCH}")); \ | ||
for BRANCH in $"$${BRANCHES[@]}"; do \ | ||
git branch --delete "$${BRANCH}"; \ | ||
done; | ||
#@ checks out default branch and cleans up all local branches except the default. | ||
git-reset:: | ||
@BRANCH="$$(git branch --show-current)"; \ | ||
@git fetch; BRANCH="$$(git branch --show-current)"; \ | ||
MAIN="$$(git remote show origin | grep "HEAD branch:" | cut -d ' ' -f 5)"; \ | ||
if [ "$${BRANCH}" != "$${MAIN}" ]; then git checkout "$${MAIN}" || exit 1; fi; \ | ||
for BRANCH in $$(git branch | cut -c 3- | grep -vw "$${MAIN}"); do \ | ||
git branch --delete "$${BRANCH}"; \ | ||
done; | ||
|
||
#@ <branch> <message> # creates a branch with the current change set using next issue. | ||
git-create:: git-create-feature | ||
# TODO: check whether I'm on the default branch and on remote HEAD. | ||
git-create-fix git-create-chore git-create-feature:: git-create-%: | ||
@BRANCH="$(firstword $(RUNARGS))"; \ | ||
MESSAGE="$(wordlist 2,$(words $(RUNARGS)),$(RUNARGS))"; \ | ||
|
@@ -555,7 +568,7 @@ test-go = \ | |
fi; \ | ||
echo -e "\t$${GOCHANGE} your local go version to $${VERSION} or "; \ | ||
echo -e "\trun 'make update-go $${VERSION}' to adjust the project!"; \ | ||
exit -1; \ | ||
exit 1; \ | ||
fi; \ | ||
done; | ||
|
||
|
@@ -1011,7 +1024,7 @@ install-all:: $(TARGETS_INSTALL_ALL) | |
# install go tools used by the project. | ||
$(TARGETS_INSTALL_GO):: install-%: $(GOBIN)/% | ||
$(addprefix $(GOBIN)/,$(COMMANDS_GO)): $(GOBIN)/%: | ||
go install $(call go-pkg,install,$(TOOLS_GO),^$*$$); | ||
go install $(call go-pkg,$(TOOLS_GO),install,^$*$$); | ||
# install go tools providing an install.sh script. | ||
$(TARGETS_INSTALL_SH):: install-%: $(GOBIN)/% | ||
$(addprefix $(GOBIN)/,$(COMMANDS_SH)): $(GOBIN)/%: | ||
|
@@ -1041,7 +1054,7 @@ uninstall-all:: $(TARGETS_UNINSTALL_ALL) | |
|
||
# uninstall go tools used by the project. | ||
$(TARGETS_UNINSTALL_GO):: uninstall-%: | ||
@#PACKAGE=$(call go-pkg,strip,$(TOOLS_GO),^$*$$); \ | ||
@#PACKAGE=$(call go-pkg,$(TOOLS_GO),strip,^$*$$); \ | ||
rm -rf $(wildcard $(GOBIN)/$* $(GOBIN)/$*.config); | ||
# uninstall npm based tools used by the project. | ||
$(TARGETS_UNINSTALL_NPM):: uninstall-%: | ||
|
@@ -1359,7 +1372,7 @@ update-tools:: $(TARGETS_UPDATE_GO) $(TARGETS_INSTALL_SH) $(TARGETS_INSTALL_NPM) | |
|
||
# update go tools used by the project. | ||
$(TARGETS_UPDATE_GO):: update-%: | ||
go install $(call go-pkg,update,$(TOOLS_GO),^$*$$); | ||
go install $(call go-pkg,$(TOOLS_GO),update,^$*$$); | ||
|
||
## Custom: custom extension targets. | ||
|
||
|
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 +1 @@ | ||
0.0.23 | ||
0.0.24 |
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ else | |
endif | ||
|
||
GOBIN ?= $(shell go env GOPATH)/bin | ||
GOMAKE ?= github.com/tkrop/[email protected].23 | ||
GOMAKE ?= github.com/tkrop/[email protected].24 | ||
TARGETS := $(shell command -v go-make >/dev/null || \ | ||
go install $(GOMAKE) && go-make targets) | ||
|
||
|
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 |
---|---|---|
|
@@ -64,13 +64,13 @@ TOOLS_GO := $(TOOLS_GO) \ | |
github.com/icholy/gomajor \ | ||
github.com/golang/mock/mockgen \ | ||
github.com/tkrop/go-testing/cmd/mock \ | ||
github.com/tkrop/go-make | ||
github.com/tkrop/go-make@v0.0.24 | ||
TOOLS_SH := $(TOOLS_SH) \ | ||
github.com/anchore/syft \ | ||
github.com/anchore/grype | ||
|
||
# function for correct gol-package handling. | ||
go-pkg = $(shell awk -v mode="$(1)" -v filter="$(3)" -v not="$(4)" ' \ | ||
# function for correct go-package handling. | ||
go-pkg = $(shell awk -v mode="$(2)" -v filter="$(3)" -v not="$(4)" ' \ | ||
BEGIN { FS = "[/@]"; RS = "[ \n\r]" } { \ | ||
field = NF; \ | ||
if (version = index($$0, "@")) { field-- } \ | ||
|
@@ -98,8 +98,15 @@ go-pkg = $(shell awk -v mode="$(1)" -v filter="$(3)" -v not="$(4)" ' \ | |
if (version) { \ | ||
return substr($$0, 1, index($$0, "@") - 1) \ | ||
} else { return $$0 } \ | ||
}' <<<"$(2)") | ||
|
||
}' <<<"$(1)") | ||
git-pkg = $(shell awk -v mode="$(2)" ' \ | ||
BEGIN { RS = "[ \n\r]" } { \ | ||
if (mode == "repo") { \ | ||
print "git@" gensub("/",":",1,substr($$0, 1, index($$0, "@") - 1)) ".git" \ | ||
} else if (mode == "tag") { \ | ||
print substr($$0, index($$0, "@") + 1) \ | ||
} \ | ||
}' <<<"$(1)") | ||
|
||
BROWSER ?= xdg-open | ||
VERSION ?= snapshot | ||
|
@@ -220,8 +227,8 @@ COMMANDS := $(shell $(FIND) -name "main.go" | xargs -r readlink -f | \ | |
COMMANDS_PKG := $(shell $(FIND) -name "main.go" | xargs -r readlink -f | \ | ||
sed -E "s/^(.*\/([^/]*))\/main.go$$/\2=\1/; s|$(CURDIR)|.|") | ||
COMMANDS_REGEX := $(shell echo "^$(COMMANDS)$$" | tr ' ' '|' ) | ||
COMMANDS_GO := $(call go-pkg,cmd,$(TOOLS_GO),$(COMMANDS_REGEX),not) | ||
COMMANDS_SH := $(call go-pkg,cmd,$(TOOLS_SH),$(COMMANDS_REGEX),not) | ||
COMMANDS_GO := $(call go-pkg,$(TOOLS_GO),cmd,$(COMMANDS_REGEX),not) | ||
COMMANDS_SH := $(call go-pkg,$(TOOLS_SH),cmd,$(COMMANDS_REGEX),not) | ||
|
||
|
||
# Setup optimized golang mock setup environment. | ||
|
@@ -368,15 +375,21 @@ targets:: | |
else cat -; fi || true; | ||
|
||
#@ create a clone of the base repository to update from. | ||
BASE ?= [email protected]:tkrop/go-make.git | ||
setup/base:: # TODO: support cloning of a distinct revision. | ||
GOMAKE ?= $(call go-pkg,$(TOOLS_GO),install,^go-make$$) | ||
setup/base:: | ||
@$(eval BASEDIR = $(shell mktemp -d)) ( \ | ||
trap "rm -rf $${DIR}" INT TERM EXIT; \ | ||
while pgrep $(MAKE) > /dev/null; do sleep 1; done; \ | ||
rm -rf $${DIR} \ | ||
) & \ | ||
REPO="$(call git-pkg,$(GOMAKE),repo)"; TAG="$(call git-pkg,$(GOMAKE),tag)"; \ | ||
git clone --no-checkout --depth 2 --single-branch \ | ||
--branch main $(BASE) $(BASEDIR) 2> /dev/null; \ | ||
--branch main $${REPO} $(BASEDIR) 2> /dev/null || \ | ||
( echo "error: cloning repo $${REPO} [$${TAG}]" >"/dev/stderr"; exit 1 ) && \ | ||
if [ "$${TAG}" != "latest" ]; then \ | ||
cd $(BASEDIR) && git checkout tags/$${TAG} 2> /dev/null || \ | ||
( echo "error: finding tag $${REPO} [$${TAG}]" >"/dev/stderr"; exit 1 ) \ | ||
fi; | ||
|
||
|
||
## Git-Support: targets for standard git commands (experimental). | ||
|
@@ -397,23 +410,23 @@ git-graph:: | |
--pretty=format:"%Cred%h %Cgreen%ad%Creset | %s $${SUFFIX}"; | ||
#@ cleans up all local branches except the default and current branch. | ||
git-clean:: | ||
@BRANCH="$$(git branch --show-current)"; \ | ||
@git fetch; BRANCH="$$(git branch --show-current)"; \ | ||
MAIN="$$(git remote show origin | grep "HEAD branch:" | cut -d ' ' -f 5)"; \ | ||
BRANCHES=($$(git branch | cut -c 3- | grep -vw "$${MAIN}\|$${BRANCH}")); \ | ||
for BRANCH in $"$${BRANCHES[@]}"; do \ | ||
git branch --delete "$${BRANCH}"; \ | ||
done; | ||
#@ checks out default branch and cleans up all local branches except the default. | ||
git-reset:: | ||
@BRANCH="$$(git branch --show-current)"; \ | ||
@git fetch; BRANCH="$$(git branch --show-current)"; \ | ||
MAIN="$$(git remote show origin | grep "HEAD branch:" | cut -d ' ' -f 5)"; \ | ||
if [ "$${BRANCH}" != "$${MAIN}" ]; then git checkout "$${MAIN}" || exit 1; fi; \ | ||
for BRANCH in $$(git branch | cut -c 3- | grep -vw "$${MAIN}"); do \ | ||
git branch --delete "$${BRANCH}"; \ | ||
done; | ||
|
||
#@ <branch> <message> # creates a branch with the current change set using next issue. | ||
git-create:: git-create-feature | ||
# TODO: check whether I'm on the default branch and on remote HEAD. | ||
git-create-fix git-create-chore git-create-feature:: git-create-%: | ||
@BRANCH="$(firstword $(RUNARGS))"; \ | ||
MESSAGE="$(wordlist 2,$(words $(RUNARGS)),$(RUNARGS))"; \ | ||
|
@@ -555,7 +568,7 @@ test-go = \ | |
fi; \ | ||
echo -e "\t$${GOCHANGE} your local go version to $${VERSION} or "; \ | ||
echo -e "\trun 'make update-go $${VERSION}' to adjust the project!"; \ | ||
exit -1; \ | ||
exit 1; \ | ||
fi; \ | ||
done; | ||
|
||
|
@@ -1011,7 +1024,7 @@ install-all:: $(TARGETS_INSTALL_ALL) | |
# install go tools used by the project. | ||
$(TARGETS_INSTALL_GO):: install-%: $(GOBIN)/% | ||
$(addprefix $(GOBIN)/,$(COMMANDS_GO)): $(GOBIN)/%: | ||
go install $(call go-pkg,install,$(TOOLS_GO),^$*$$); | ||
go install $(call go-pkg,$(TOOLS_GO),install,^$*$$); | ||
# install go tools providing an install.sh script. | ||
$(TARGETS_INSTALL_SH):: install-%: $(GOBIN)/% | ||
$(addprefix $(GOBIN)/,$(COMMANDS_SH)): $(GOBIN)/%: | ||
|
@@ -1041,7 +1054,7 @@ uninstall-all:: $(TARGETS_UNINSTALL_ALL) | |
|
||
# uninstall go tools used by the project. | ||
$(TARGETS_UNINSTALL_GO):: uninstall-%: | ||
@#PACKAGE=$(call go-pkg,strip,$(TOOLS_GO),^$*$$); \ | ||
@#PACKAGE=$(call go-pkg,$(TOOLS_GO),strip,^$*$$); \ | ||
rm -rf $(wildcard $(GOBIN)/$* $(GOBIN)/$*.config); | ||
# uninstall npm based tools used by the project. | ||
$(TARGETS_UNINSTALL_NPM):: uninstall-%: | ||
|
@@ -1359,7 +1372,7 @@ update-tools:: $(TARGETS_UPDATE_GO) $(TARGETS_INSTALL_SH) $(TARGETS_INSTALL_NPM) | |
|
||
# update go tools used by the project. | ||
$(TARGETS_UPDATE_GO):: update-%: | ||
go install $(call go-pkg,update,$(TOOLS_GO),^$*$$); | ||
go install $(call go-pkg,$(TOOLS_GO),update,^$*$$); | ||
|
||
## Custom: custom extension targets. | ||
|
||
|
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,5 +1,6 @@ | ||
call: targets --trace | ||
info: {"path":"github.com/tkrop/go-make","repo":"[email protected]:tkrop/go-make","build":"0001-01-01T00:00:00Z","commit":"0001-01-01T00:00:00Z","dirty":true,"go":"{{GOVERSION}}","platform":"{{PLATFORM}}","compiler":"{{COMPILER}}"} | ||
exec: make --file Makefile.base targets --trace [go-make/internal/make] | ||
Makefile.base:18: info: please customize variables in Makefile.vars | ||
Makefile.base:211: info: please define custom functions in Makefile.defs | ||
exec: git status --short [make.test.config] | ||
exec: make --file make.test.config/Makefile.base targets --trace [go-make/internal/make] | ||
make.test.config/Makefile.base:18: info: please customize variables in Makefile.vars | ||
make.test.config/Makefile.base:218: info: please define custom functions in Makefile.defs |
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,2 +1,2 @@ | ||
Makefile.base:18: info: please customize variables in Makefile.vars | ||
Makefile.base:211: info: please define custom functions in Makefile.defs | ||
make.test.config/Makefile.base:18: info: please customize variables in Makefile.vars | ||
make.test.config/Makefile.base:218: info: please define custom functions in Makefile.defs |
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.