Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
172 lines (143 loc) · 5.81 KB
/
Copy pathMakefile
File metadata and controls
172 lines (143 loc) · 5.81 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
PROJECT_NAME := $(shell sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml | head -n 1)
CURRENT_VERSION := $(shell grep '^version = ' Cargo.toml | sed -E 's/version = "(.*)"/\1/')
TOP_DIR := $(CURDIR)
BUILD_DIR := $(TOP_DIR)/target
ifeq ($(PROJECT_NAME),)
$(error Error: project name not found in Cargo.toml)
endif
$(info ------------------------------------------)
$(info Project: $(PROJECT_NAME))
$(info Version: $(CURRENT_VERSION))
$(info ------------------------------------------)
.PHONY: build b compile c fmt fmt-check lint lint-fix check-features test t test-contract test-contract-system test-package test-system docs-check verify release-check help h clean docs
SHELL := /bin/bash
build:
@cargo build --release
b: build
compile:
@cargo clean
@make build
c: compile
test:
@CPATH= C_INCLUDE_PATH= cargo test --all-targets --features repo-tests
@CPATH= C_INCLUDE_PATH= cargo test --doc --features repo-tests
t: test
fmt:
@cargo fmt
fmt-check:
@cargo fmt -- --check
lint:
@cargo clippy --no-deps --all-targets --all-features -- -D warnings
lint-fix:
@cargo clippy --fix --allow-dirty --allow-staged --no-deps --all-targets --all-features
check-features:
@cargo check --all-targets
@cargo check --all-targets --all-features
@cargo check --all-targets --no-default-features
test-contract:
@CPATH= C_INCLUDE_PATH= cargo test --lib contract
test-contract-system:
@PARC_SYSTEM_TEST_MODE="$(SYSTEM_TEST_MODE)" bash tools/run-filtered-test.sh cargo test --lib --features system-tests contract_preservation_gcc_enum_representation -- --nocapture
@PARC_SYSTEM_TEST_MODE="$(SYSTEM_TEST_MODE)" bash tools/run-filtered-test.sh cargo test --lib --features system-tests certified_builtin_and_gcc_clang_external_scans_agree_or_report_exact_differences -- --nocapture
test-package:
@CPATH= C_INCLUDE_PATH= tools/test-package.sh follang-parc parc
SYSTEM_TEST_MODE ?= optional
test-system:
@$(MAKE) test-contract-system SYSTEM_TEST_MODE="$(SYSTEM_TEST_MODE)"
@PARC_SYSTEM_TEST_MODE="$(SYSTEM_TEST_MODE)" bash tools/run-filtered-test.sh cargo test --lib --features system-tests refresh_script_ -- --nocapture
@PARC_SYSTEM_TEST_MODE="$(SYSTEM_TEST_MODE)" bash tools/run-filtered-test.sh cargo test --lib --features system-tests full_app_main -- --nocapture
docs-check:
@command -v mdbook >/dev/null 2>&1 || { echo "mdbook is required"; exit 1; }
@mdbook build $(TOP_DIR)/book --dest-dir $(BUILD_DIR)/book
@cargo doc --no-deps --all-features
VERIFY_ALLOW_DIRTY ?= 0
verify:
@set -eu; \
before="$$(mktemp "$${TMPDIR:-/tmp}/parc-verify-before.XXXXXX")"; \
after="$$(mktemp "$${TMPDIR:-/tmp}/parc-verify-after.XXXXXX")"; \
trap 'rm -f "$$before" "$$after"' EXIT; \
git status --porcelain=v1 --untracked-files=all >"$$before"; \
if test -s "$$before" && test "$(VERIFY_ALLOW_DIRTY)" != 1; then \
echo "verification requires a clean worktree (or VERIFY_ALLOW_DIRTY=1)"; \
cat "$$before"; \
exit 1; \
fi; \
$(MAKE) fmt-check; \
$(MAKE) lint; \
$(MAKE) check-features; \
$(MAKE) test; \
$(MAKE) test-contract; \
$(MAKE) test-package; \
$(MAKE) test-system SYSTEM_TEST_MODE=required; \
$(MAKE) docs-check; \
git status --porcelain=v1 --untracked-files=all >"$$after"; \
diff -u "$$before" "$$after"
help:
@echo
@echo "Usage: make [target]"
@echo
@echo "Available targets:"
@echo " build Build project"
@echo " compile Configure and generate build files"
@echo " fmt Format this package"
@echo " fmt-check Check Rust formatting"
@echo " lint Run Clippy with warnings denied"
@echo " lint-fix Apply Clippy's machine-applicable fixes"
@echo " check-features Check default, all, and no-default features"
@echo " test Run tests"
@echo " test-contract Run contract tests"
@echo " test-contract-system Verify compiler-dependent contract evidence"
@echo " test-package Test the package archive and clean consumer"
@echo " test-system Run prerequisite-dependent system tests"
@echo " docs-check Build Rust and mdBook documentation"
@echo " verify Run the complete non-mutating gate"
@echo " release-check Verify clean, upstream-synchronized release eligibility"
@echo " docs Build documentation (TYPE=mdbook|doxygen)"
@echo
h : help
clean:
@echo "Cleaning build directory..."
@rm -rf $(BUILD_DIR)
@echo "Build directory cleaned."
docs:
ifeq ($(TYPE),mdbook)
@$(MAKE) docs-check
else ifeq ($(TYPE),doxygen)
@command -v doxygen >/dev/null 2>&1 || { echo "doxygen is not installed. Please install it first."; exit 1; }
else
$(error Invalid documentation type. Use 'make docs TYPE=mdbook' or 'make docs TYPE=doxygen')
endif
release-check:
@set -eu; \
branch="$$(git symbolic-ref --quiet --short HEAD)" || { \
echo "release check requires a branch checkout, not detached HEAD"; \
exit 1; \
}; \
upstream="$$(git rev-parse --abbrev-ref --symbolic-full-name '@{upstream}' 2>/dev/null)" || { \
echo "release check requires an upstream for $$branch"; \
exit 1; \
}; \
test -z "$$(git status --porcelain=v1 --untracked-files=all)" || { \
echo "release check requires a clean worktree"; \
exit 1; \
}; \
head="$$(git rev-parse HEAD)"; \
upstream_head="$$(git rev-parse "$$upstream")"; \
test "$$head" = "$$upstream_head" || { \
echo "release check requires HEAD to equal $$upstream"; \
echo "HEAD: $$head"; \
echo "upstream: $$upstream_head"; \
exit 1; \
}; \
tag="follang-parc-v$(CURRENT_VERSION)"; \
! git rev-parse --quiet --verify "refs/tags/$$tag" >/dev/null || { \
echo "release tag already exists: $$tag"; \
exit 1; \
}; \
grep -Fqx 'publish = false' Cargo.toml || { \
echo "registry publication must remain disabled"; \
exit 1; \
}; \
$(MAKE) verify; \
echo "release candidate is eligible: $$tag at $$head"; \
echo "release-check is non-mutating; follow RELEASE.md to create an archive/tag"