-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
58 lines (43 loc) · 1.56 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
NAME=ipsw
BINARY=packer-plugin-$(NAME)
PROJECT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
.DEFAULT_GOAL = build
PACKER_SDC := go run github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc
# Generate
HCL2_SOURCES := $(shell grep -r -l "go:generate.*mapstructure-to-hcl2" **/*.go)
HCL2_GENERATED = $(HCL2_SOURCES:.go=.hcl2spec.go)
$(HCL2_GENERATED): %.hcl2spec.go : %.go
@go generate -run="-command|hcl2" $<
# Build
.PHONY: build
build: $(HCL2_GENERATED)
@go generate main.go
@go build -o $(BINARY)
.PHONY: install
install: build
@packer plugins install --path $(BINARY) github.com/torarnv/$(NAME)
# Test
test: check
check: plugin-check acceptance-test
acceptance-test: export PKR_VAR_appledb_test_path = $(PROJECT_DIR)/datasource/test-fixtures/
acceptance-test: export PACKER_ACC = 1
acceptance-test: export PACKER_PLUGIN_PATH = $(PROJECT_DIR)/.install
acceptance-test: install
@go test -count 1 -v $(shell find . | grep _test.go) -timeout=120m
plugin-check: build
@$(PACKER_SDC) plugin-check $(BINARY)
# Clean
.PHONY: clean
clean:
@rm -Rf $(BINARY) $(HCL2_GENERATED) $(DOC_GENERATED) crash.log build/ dist/ docs.zip
# Docs
DOC_SOURCES := $(shell grep -r -l "go:generate.*struct-markdown" **/*.go)
DOC_GENERATED = docs-partials
$(DOC_GENERATED): $(DOC_SOURCES)
@go generate -run="-command|markdown" $(DOC_SOURCES)
.PHONY: docs
docs: $(DOC_GENERATED)
@rm -Rf build/docs/
@$(PACKER_SDC) renderdocs -src docs/ -partials docs-partials/ -dst build/docs/
@cp README.md build/docs/
@./.web-docs/scripts/compile-to-webdocs.sh "." "build/docs/" ".web-docs" "<orgname>"