diff --git a/Makefile b/Makefile index 2bd6e701..78e60362 100644 --- a/Makefile +++ b/Makefile @@ -22,12 +22,6 @@ VTAG := $(shell [ -z $(VTAG) ] && echo $(ETAG) || echo $(VTAG)) VERS ?= $(shell [ -z $(VTAG) ] && echo 'tip' || echo $(VTAG) ) LDFLAGS := "-X main.date=$(DATE) -X main.vers=$(VERS) -X main.hash=$(HASH)" -# Templates -# Built into the binary are the contents of ./templates. This is done by -# running 'pkger' which generates pkged.go containing templates encoded -# as Go objects and exposed at runtime as a filesystem. -PKGER ?= ./hack/update-pkger.sh - # All Code prerequisites, including generated files, etc. CODE := $(shell find . -name '*.go') pkged.go go.mod schema/func_yaml-schema.json TEMPLATES := $(shell find templates -name '*' -type f) @@ -65,6 +59,7 @@ bin/golangci-lint: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin v1.43.0 pkged.go: $(TEMPLATES) + # Removing temporary template files @rm -rf templates/node/cloudevents/node_modules @rm -rf templates/node/http/node_modules @rm -rf templates/python/cloudevents/__pycache__ @@ -77,8 +72,15 @@ pkged.go: $(TEMPLATES) @rm -rf templates/quarkus/http/target @rm -rf templates/springboot/cloudevents/target @rm -rf templates/springboot/http/target - # Generating pkged.go using pkger - $(PKGER) + # Encoding ./templates as pkged.go +# See ./hack/tools.go which triggers the vendoring of pkger cmd +# The temp file ./hack/package.go averts a "no buildable files" error +# gofmt updates the resultant pkged.go file to the new build tag f ormat. + @echo "package tools" > hack/package.go + @go run ./vendor/github.com/markbates/pkger/cmd/pkger + @rm hack/package.go + @gofmt -s -w pkged.go + clean: ## Remove generated artifacts such as binaries and schemas rm -f $(BIN) $(BIN_WINDOWS) $(BIN_LINUX) $(BIN_DARWIN) diff --git a/hack/update-pkger.sh b/hack/update-pkger.sh deleted file mode 100755 index 1f0841c6..00000000 --- a/hack/update-pkger.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2021 The Knative Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -o errexit -set -o nounset -set -o pipefail - -source $(dirname $0)/../vendor/knative.dev/hack/library.sh - -# Hack: touch a non-tagged file so that pkger doesn't complain -echo -e "package tools" > "$REPO_ROOT_DIR/hack/package.go" - -go run ./vendor/github.com/markbates/pkger/cmd/pkger - -# Hack: remove touched file. -rm "$REPO_ROOT_DIR/hack/package.go" - -# Ensure pkged.go is migrated -gofmt -s -w pkged.go