Skip to content

Commit 64091fb

Browse files
authored
build pkged.go directly with make (#841)
Also removes the dependency on a modern bash when building on a stock OS X box (which ships with a 15-year old version).
1 parent f25724a commit 64091fb

2 files changed

Lines changed: 10 additions & 40 deletions

File tree

Makefile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ VTAG := $(shell [ -z $(VTAG) ] && echo $(ETAG) || echo $(VTAG))
2222
VERS ?= $(shell [ -z $(VTAG) ] && echo 'tip' || echo $(VTAG) )
2323
LDFLAGS := "-X main.date=$(DATE) -X main.vers=$(VERS) -X main.hash=$(HASH)"
2424

25-
# Templates
26-
# Built into the binary are the contents of ./templates. This is done by
27-
# running 'pkger' which generates pkged.go containing templates encoded
28-
# as Go objects and exposed at runtime as a filesystem.
29-
PKGER ?= ./hack/update-pkger.sh
30-
3125
# All Code prerequisites, including generated files, etc.
3226
CODE := $(shell find . -name '*.go') pkged.go go.mod schema/func_yaml-schema.json
3327
TEMPLATES := $(shell find templates -name '*' -type f)
@@ -65,6 +59,7 @@ bin/golangci-lint:
6559
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin v1.43.0
6660

6761
pkged.go: $(TEMPLATES)
62+
# Removing temporary template files
6863
@rm -rf templates/node/cloudevents/node_modules
6964
@rm -rf templates/node/http/node_modules
7065
@rm -rf templates/python/cloudevents/__pycache__
@@ -77,8 +72,15 @@ pkged.go: $(TEMPLATES)
7772
@rm -rf templates/quarkus/http/target
7873
@rm -rf templates/springboot/cloudevents/target
7974
@rm -rf templates/springboot/http/target
80-
# Generating pkged.go using pkger
81-
$(PKGER)
75+
# Encoding ./templates as pkged.go
76+
# See ./hack/tools.go which triggers the vendoring of pkger cmd
77+
# The temp file ./hack/package.go averts a "no buildable files" error
78+
# gofmt updates the resultant pkged.go file to the new build tag f ormat.
79+
@echo "package tools" > hack/package.go
80+
@go run ./vendor/github.com/markbates/pkger/cmd/pkger
81+
@rm hack/package.go
82+
@gofmt -s -w pkged.go
83+
8284

8385
clean: ## Remove generated artifacts such as binaries and schemas
8486
rm -f $(BIN) $(BIN_WINDOWS) $(BIN_LINUX) $(BIN_DARWIN)

hack/update-pkger.sh

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)