Skip to content

Commit

Permalink
fix: include Makefile.defs (#0)
Browse files Browse the repository at this point in the history
Signed-off-by: tkrop <[email protected]>
  • Loading branch information
tkrop committed Dec 15, 2023
1 parent 7b1d22c commit 61cadfc
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 11 deletions.
5 changes: 4 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ issues:
linters: [ errcheck ]
# Exclude certain revive standards from being applied in tests.
- path: "_test\\.go"
text: "^(max-public-structs|function-length|cognitive-complexity|unchecked-type-assertion):"
text: "^(max-public-structs|function-length|cognitive-complexity):"
linters: [ revive ]
# Exclude dots in unfinished thoughts.
- source: "(noinspection|TODO)"
Expand Down Expand Up @@ -160,6 +160,9 @@ linters-settings:
# Fails to disable writers that actually cannot return errors.
- name: unhandled-error
disabled: true
# Fails to detect and exclude type safe usages of type assertions.
- name: unchecked-type-assertion
disabled: true
# Fails to restrict sufficiently in switches with numeric values.
- name: add-constant
disabled: true
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ endif
# request targets, while the single target can be used to define the
# precondition of custom target.
.PHONY: $(TARGETS) $(addprefix target/,$(TARGETS))
$(TARGETS):; $(GOBIN)/go-make $(MAKEFLAGS) $(MAKECMDGOALS);
$(TARGETS):
@PARAMS=$(MAKECMDGOALS) $(MAKECMDGOALS :=); \
$(GOBIN)/go-make $(MAKEFLAGS) $${PARAMS};
$(addprefix target/,$(TARGETS)): target/%:
$(GOBIN)/go-make $(MAKEFLAGS) $*;

Expand Down
12 changes: 8 additions & 4 deletions Makefile.base
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ go-pkg = $(shell awk -v mode="$(1)" -v filter="$(3)" -v not="$(4)" ' \
}' <<<"$(2)")


BROWSER ?= xdg-open
VERSION ?= snapshot
ifeq ($(wildcard VERSION),VERSION)
BUILD_VERSION := v$(shell cat VERSION)
Expand Down Expand Up @@ -205,8 +206,9 @@ run-vars-image = $(call run-vars-docker)
run-aws-setup = true

ifneq ("$(wildcard Makefile.defs)","")
$(info info: please define custom functions in Makefile.defs)
include Makefile.defs
else
$(warning info: please define custom functions in Makefile.defs)
endif


Expand Down Expand Up @@ -514,10 +516,12 @@ $(TARGETS_UNINSTALL): uninstall-%:; rm -f $(GOBIN)/$*;
#@ initialize the project to prepare it for building.
init: $(TARGETS_INIT)
#@ initialize the go module and package dependencies.
init-go: go.mod go.sum
init-go: go.sum
go.sum: go.mod
go mod tidy -go=$(GOVERSION);
go mod download;
go.mod go.sum:
go mod init "$(REPOSITORY)"
go.mod:
go mod init "$(REPOSITORY)";
#@ initialize the pre-commit hook.
init-hooks: .git/hooks/pre-commit
.git/hooks/pre-commit:
Expand Down
24 changes: 24 additions & 0 deletions Makefile.defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Setup environment for all run-targets (to be modified)
define run-setup
true
endef

# Define variables for all run-targets (to be modified)
define run-vars

endef

# Define variables for local run-targets (to be modified)
define run-vars-local

endef

# Define variables for image run-targets (to be modified)
define run-vars-image

endef

# Define aws localstack setup (to be modified).
define run-aws-setup
true
endef
6 changes: 3 additions & 3 deletions Makefile.vars
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ CODACY_API_BASE_URL := https://api.codacy.com
#CODACY_CONTINUE := true

# Setup required targets before testing (default: <empty>).
#TEST_DEPS := run-db
#TEST_DEPS := run-db run-aws
# Setup required targets before running commands (default: <empty>).
#RUN_DEPS := run-db
#RUN_DEPS := run-db run-aws
# Setup required aws services for testing (default: <empty>).
#AWS_SERVICES :=
#AWS_SERVICES := s3 sqs

# Setup when to push images (default: pulls [never, pulls, merges])
IMAGE_PUSH ?= never
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.6
0.0.7
1 change: 1 addition & 0 deletions internal/make/fixtures/targets-trace.err
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ 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
2 changes: 1 addition & 1 deletion internal/make/fixtures/targets-trace.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Makefile.base:383: target 'targets' does not exist
Makefile.base:385: target 'targets' does not exist
make --no-builtin-rules --no-builtin-variables --print-data-base \
--question --makefile=Makefile.base 2>/dev/null | \
if [ "" != "raw" ]; then awk -v RS= -F: ' \
Expand Down
1 change: 1 addition & 0 deletions internal/make/fixtures/targets.err
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Makefile.base:18: info: please customize variables in Makefile.vars
Makefile.base:211: info: please define custom functions in Makefile.defs

0 comments on commit 61cadfc

Please sign in to comment.