Skip to content

Commit

Permalink
improved makefile docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lkingland committed Jun 23, 2023
1 parent 0702b4a commit 89225d7
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ KVER ?= $(shell git describe --tags --match 'knative-*')
LDFLAGS := "-X main.date=$(DATE) -X main.vers=$(VERS) -X main.kver=$(KVER) -X main.hash=$(HASH)"

# All Code prerequisites, including generated files, etc.
CODE := $(shell find . -name '*.go') generate/zz_filesystem_generated.go go.mod schema/func_yaml-schema.json
CODE := $(shell find . -name '*.go') \
generate/zz_filesystem_generated.go go.mod \
schema/func_yaml-schema.json \
templates/certs/ca-certificates.crt
TEMPLATES := $(shell find templates -name '*' -type f)

# Default Target
Expand Down Expand Up @@ -106,10 +109,10 @@ docs: .docs_stamp
#############

.PHONY: templates
templates: generate/zz_filesystem_generated.go ## Build the embedded templates
templates: templates-force generate/zz_filesystem_generated.go ## Build the embedded templates

.PHONY: generate/zz_filesystem_generated.go # do not cache; always rebuild
generate/zz_filesystem_generated.go:
generate/zz_filesystem_generated.go: templates/certs/ca-certificates.crt
rm -f schema/func_yaml-schema.json
@rm -f templates/go/cloudevents/go.sum
@rm -f templates/go/http/go.sum
@rm -rf templates/node/cloudevents/node_modules
Expand All @@ -131,6 +134,13 @@ generate/zz_filesystem_generated.go:
# Generating embedded templates filesystem
go generate pkg/functions/templates_embedded.go

# force the rebuild of the templates by removing the file. Rather than
# simply mark the target itself as .PHONY, this allows other tasks which
# depend on the file's existence (such as schema regeneration) to execute
# without always triggering a regen cascade.
.PHONY: templates-force
@rm -f generate/zz_filesystem_generated.go

# Checks that the generated embedded filesystem has been modified.
# In CI this is combined with a `make clean` to check that the templates
# embedded fileystem is up-to-date.
Expand Down Expand Up @@ -263,17 +273,18 @@ $(BIN_WINDOWS): generate/zz_filesystem_generated.go
######################

.PHONY: schema
schema: schema-clean schema/func_yaml-schema.json ## Generate func.yaml schema
schema: schema-clean schema/func_yaml-schema.json ## Ensures schema file exists.

schema/func_yaml-schema.json: pkg/functions/function.go pkg/functions/function_*.go generate/zz_filesystem_generated.go
# regenerating schema
@go run schema/generator/main.go

# remove schema if modified
# when combined with the target 'templates/certs/ca-certificates.crt',
# will rebuild schema if the schema file has been modified.
.PHONY: schema-clean
schema-clean:
-FILE="schema/func_yaml-schema.json"; [ -f $$FILE ] && git diff --name-only $$FILE | xargs rm -f
-@FILE="schema/func_yaml-schema.json"; [ -f $$FILE ] && git diff --name-only $$FILE | xargs rm -f

# Checks if the generated function schema file has been modified.
# In CI this is combined with a `make clean` to check that the schema
Expand All @@ -285,7 +296,7 @@ schema-modified-check: schema
exit 1; fi

.PHONY: certs
certs: certs-clean templates/certs/ca-certificates.crt ## Update root certificates
certs: certs-clean templates/certs/ca-certificates.crt ## Ensures root certs file exists.

templates/certs/ca-certificates.crt:
# Updating root certificates
Expand Down

0 comments on commit 89225d7

Please sign in to comment.