-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
155 lines (133 loc) · 8.3 KB
/
Makefile
File metadata and controls
155 lines (133 loc) · 8.3 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
SHELL := /bin/sh
CARGO ?= cargo
VERSION_FILE ?= VERSION
BUILD_FILE ?= BUILD
DIST_DIR ?= dist
RELEASE_BIN_DIR := target/release
DIST_HOST_TRIPLE ?= $(shell $(CARGO) -vV 2>/dev/null | awk '/^host:/ { print $$2 }')
DIST_ARCH_DIR ?= $(if $(DIST_HOST_TRIPLE),$(DIST_HOST_TRIPLE),$(shell uname -m))
DIST_BIN_DIR := $(DIST_DIR)/bin/$(DIST_ARCH_DIR)
DIST_DOC_DIR := $(DIST_DIR)/docs
DIST_GUIDE_DIR := $(DIST_DOC_DIR)/docs
DIST_SPEC_DIR := $(DIST_DOC_DIR)/specs
DIST_EXAMPLES_DIR := $(DIST_DIR)/examples
DIST_LIB_DIR := $(DIST_DIR)/lib
DIST_ARCHIVE_EXCLUDES := \
--exclude=.DS_Store \
--exclude='*/.DS_Store' \
--exclude=.observer \
--exclude='*/.observer' \
--exclude='*/.observer/*' \
--exclude=out \
--exclude='*/out' \
--exclude='*/out/*'
DIST_SPEC_FILES := \
00-architecture.md \
10-provider.md \
11-provider-resolution.md \
13-provider-authoring.md \
20-inventory.md \
25-normalization.md \
30-suite.md \
40-reporting.md \
41-analytics.md \
50-workflow-verification.md \
90-examples.md \
95-reference-implementation.md
DIST_BINARIES := observer observer-selftest-host
OBSERVER := $(CARGO) run -q --manifest-path $(CURDIR)/Cargo.toml -p frogfish-observer --
SELF_PRODUCT_FILE := product.json
SELFTEST_DIR := tests/selftest/observer
CLI_CONFORMANCE_DIR := tests/cli-conformance/observer
RUST_STARTER_DIR := tests/rust-starter/observer
CMAKE_MODEL_DIR := tests/cmake-model/observer
PRODUCT_EXPECT_DIR := tests/product
.PHONY: bump dist clean-dist self-certify-build self-certify-selftest-inventory self-certify-selftest-report self-certify-selftest-verify self-certify-cli-report self-certify-cli-verify self-certify-rust-starter-report self-certify-rust-starter-verify self-certify-cmake-model-report self-certify-cmake-model-verify self-certify-hash self-certify self-certify-verify self-certify-cube self-certify-view self-certify-clean
bump:
@version=`tr -d '[:space:]' < "$(VERSION_FILE)"`; \
new_version=`printf '%s\n' "$$version" | awk -F. 'NF != 3 { exit 1 } { $$NF += 1; printf "%d.%d.%d", $$1, $$2, $$3 }'`; \
if [ -z "$$new_version" ]; then \
echo "VERSION must be semantic version x.y.z" >&2; \
exit 1; \
fi; \
printf '%s\n' "$$new_version" > "$(VERSION_FILE)"; \
echo "version -> $$new_version"
dist:
@build=`tr -d '[:space:]' < "$(BUILD_FILE)"`; \
new_build=`printf '%s\n' "$$build" | awk '/^[0-9]+$$/ { print $$1 + 1 }'`; \
if [ -z "$$new_build" ]; then \
echo "BUILD must be an integer" >&2; \
exit 1; \
fi; \
printf '%s\n' "$$new_build" > "$(BUILD_FILE)"; \
echo "build -> $$new_build"; \
echo "dist host -> $(DIST_ARCH_DIR)"; \
rm -rf "$(DIST_DIR)"; \
mkdir -p "$(DIST_BIN_DIR)" "$(DIST_DOC_DIR)" "$(DIST_GUIDE_DIR)" "$(DIST_SPEC_DIR)"; \
"$(CARGO)" build --release --bin observer --bin observer-selftest-host; \
for bin in $(DIST_BINARIES); do \
cp "$(RELEASE_BIN_DIR)/$$bin" "$(DIST_BIN_DIR)/$$bin"; \
done; \
cp -R lib "$(DIST_LIB_DIR)"; \
tar -C . -cf - $(DIST_ARCHIVE_EXCLUDES) examples | tar -C "$(DIST_DIR)" -xf -; \
cp README.md OBSERVER.md LICENSE VERSION BUILD "$(DIST_DOC_DIR)/"; \
cp docs/USER_GUIDE.md "$(DIST_GUIDE_DIR)/USER_GUIDE.md"; \
for spec in $(DIST_SPEC_FILES); do \
cp "specs/$$spec" "$(DIST_SPEC_DIR)/$$spec"; \
done
clean-dist:
rm -rf "$(DIST_DIR)"
self-certify-build:
$(CARGO) build --quiet --manifest-path Cargo.toml --bin observer-selftest-host
self-certify-selftest-inventory: self-certify-build
@rm -rf $(SELFTEST_DIR)/.observer
@mkdir -p $(SELFTEST_DIR)/.observer
cd $(SELFTEST_DIR) && $(OBSERVER) derive-inventory --config observer.toml --provider rust > .observer/current.tests.inv
cmp -s $(SELFTEST_DIR)/tests.inv $(SELFTEST_DIR)/.observer/current.tests.inv || diff -u $(SELFTEST_DIR)/tests.inv $(SELFTEST_DIR)/.observer/current.tests.inv
self-certify-selftest-report: self-certify-build
@rm -rf $(SELFTEST_DIR)/.observer
@mkdir -p $(SELFTEST_DIR)/.observer
cd $(SELFTEST_DIR) && $(OBSERVER) run --inventory tests.inv --suite tests.obs --config observer.toml --surface simple --mode default --ui off --report jsonl > .observer/current.default.jsonl
self-certify-selftest-verify: self-certify-selftest-inventory self-certify-selftest-report
cd $(SELFTEST_DIR) && $(OBSERVER) hash-inventory --inventory tests.inv > .observer/current.inventory.sha256
cd $(SELFTEST_DIR) && $(OBSERVER) hash-suite --suite tests.obs --surface simple > .observer/current.suite.sha256
cmp -s $(SELFTEST_DIR)/expected.inventory.sha256 $(SELFTEST_DIR)/.observer/current.inventory.sha256 || diff -u $(SELFTEST_DIR)/expected.inventory.sha256 $(SELFTEST_DIR)/.observer/current.inventory.sha256
cmp -s $(SELFTEST_DIR)/expected.suite.sha256 $(SELFTEST_DIR)/.observer/current.suite.sha256 || diff -u $(SELFTEST_DIR)/expected.suite.sha256 $(SELFTEST_DIR)/.observer/current.suite.sha256
cmp -s $(SELFTEST_DIR)/expected.default.jsonl $(SELFTEST_DIR)/.observer/current.default.jsonl || diff -u $(SELFTEST_DIR)/expected.default.jsonl $(SELFTEST_DIR)/.observer/current.default.jsonl
self-certify-cli-report:
@rm -rf $(CLI_CONFORMANCE_DIR)/.observer
@mkdir -p $(CLI_CONFORMANCE_DIR)/.observer
cd $(CLI_CONFORMANCE_DIR) && $(OBSERVER) run --suite tests.obs --surface full --mode default --ui off --report jsonl > .observer/current.default.jsonl
self-certify-cli-verify: self-certify-cli-report
cd $(CLI_CONFORMANCE_DIR) && $(OBSERVER) hash-suite --suite tests.obs --surface full > .observer/current.suite.sha256
cmp -s $(CLI_CONFORMANCE_DIR)/expected.suite.sha256 $(CLI_CONFORMANCE_DIR)/.observer/current.suite.sha256 || diff -u $(CLI_CONFORMANCE_DIR)/expected.suite.sha256 $(CLI_CONFORMANCE_DIR)/.observer/current.suite.sha256
cmp -s $(CLI_CONFORMANCE_DIR)/expected.default.jsonl $(CLI_CONFORMANCE_DIR)/.observer/current.default.jsonl || diff -u $(CLI_CONFORMANCE_DIR)/expected.default.jsonl $(CLI_CONFORMANCE_DIR)/.observer/current.default.jsonl
self-certify-rust-starter-report:
@rm -rf $(RUST_STARTER_DIR)/.observer
@mkdir -p $(RUST_STARTER_DIR)/.observer
cd $(RUST_STARTER_DIR) && $(OBSERVER) run --suite tests.obs --surface full --mode default --ui off --report jsonl > .observer/current.default.jsonl
self-certify-rust-starter-verify: self-certify-rust-starter-report
cd $(RUST_STARTER_DIR) && $(OBSERVER) hash-suite --suite tests.obs --surface full > .observer/current.suite.sha256
cmp -s $(RUST_STARTER_DIR)/expected.suite.sha256 $(RUST_STARTER_DIR)/.observer/current.suite.sha256 || diff -u $(RUST_STARTER_DIR)/expected.suite.sha256 $(RUST_STARTER_DIR)/.observer/current.suite.sha256
cmp -s $(RUST_STARTER_DIR)/expected.default.jsonl $(RUST_STARTER_DIR)/.observer/current.default.jsonl || diff -u $(RUST_STARTER_DIR)/expected.default.jsonl $(RUST_STARTER_DIR)/.observer/current.default.jsonl
self-certify-cmake-model-report:
cd $(CMAKE_MODEL_DIR) && ./bin/verify-cmake-model --write-current
self-certify-cmake-model-verify:
cd $(CMAKE_MODEL_DIR) && ./bin/verify-cmake-model --verify
self-certify-hash:
$(OBSERVER) hash-product --product $(SELF_PRODUCT_FILE) > $(PRODUCT_EXPECT_DIR)/.current.product.sha256
cmp -s $(PRODUCT_EXPECT_DIR)/expected.product.sha256 $(PRODUCT_EXPECT_DIR)/.current.product.sha256 || diff -u $(PRODUCT_EXPECT_DIR)/expected.product.sha256 $(PRODUCT_EXPECT_DIR)/.current.product.sha256
self-certify: self-certify-build self-certify-cmake-model-verify
@rm -rf .observer
@mkdir -p .observer
$(OBSERVER) certify --product $(SELF_PRODUCT_FILE) --ui compact > .observer/product.default.jsonl
self-certify-verify: self-certify-selftest-verify self-certify-cli-verify self-certify-rust-starter-verify self-certify-cmake-model-verify self-certify
cmp -s $(PRODUCT_EXPECT_DIR)/expected.default.jsonl .observer/product.default.jsonl || diff -u $(PRODUCT_EXPECT_DIR)/expected.default.jsonl .observer/product.default.jsonl
$(OBSERVER) hash-product --product $(SELF_PRODUCT_FILE) > .observer/product.sha256
cmp -s $(PRODUCT_EXPECT_DIR)/expected.product.sha256 .observer/product.sha256 || diff -u $(PRODUCT_EXPECT_DIR)/expected.product.sha256 .observer/product.sha256
self-certify-cube: self-certify
$(OBSERVER) cube-product --report .observer/product.default.jsonl --root . --out .observer/analytics-product
self-certify-view: self-certify-cube
$(OBSERVER) view --compare-index .observer/analytics-product/product.compare-index.json --out .observer/product.html
self-certify-clean:
rm -rf .observer $(SELFTEST_DIR)/.observer $(CLI_CONFORMANCE_DIR)/.observer $(RUST_STARTER_DIR)/.observer $(CMAKE_MODEL_DIR)/.observer $(PRODUCT_EXPECT_DIR)/.current.product.sha256