-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmakefile
More file actions
177 lines (144 loc) · 5.87 KB
/
Copy pathmakefile
File metadata and controls
177 lines (144 loc) · 5.87 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
173
174
175
176
177
.PHONY: help
help: makefile
@tail -n +4 makefile | grep ".PHONY"
.PHONY: format
format:
cargo clippy --fix --allow-dirty
cargo fmt
# nix fmt # TODO: Reactivate when it's faster
.PHONY: lint
lint:
cargo fmt --all --check
cargo clippy --workspace --all-targets -- --deny warnings
.PHONY: lint-lua
lint-lua:
cargo run --package luacad -- lint examples/
.PHONY: test-units
test-units:
cargo test --lib --bins -- --show-output
@echo "✅ All unit tests passed!\n\n"
.PHONY: build
build:
cargo build
.PHONY: test
test:
cargo test
# Regenerate the rasterized and path-traced image next to every example's
# entry point (literal_openscad has none: it only emits OpenSCAD code)
.PHONY: example-images
example-images:
cargo build --package luacad --release
@for entry in examples/*/*.lua examples/*/*.scad; do \
case $$entry in examples/literal_openscad/*) continue;; esac; \
base=$${entry%.*}; \
echo "→ $$base.png"; \
target/release/luacad render "$$entry" "$$base.png"; \
echo "→ $${base}_raytraced.png"; \
target/release/luacad render --raytrace "$$entry" \
"$${base}_raytraced.png"; \
done
# Regenerates website/examples.html — every example's source, the OpenSCAD it
# exports to and a preview — from the examples themselves. The page is checked
# in because GitHub Pages deploys `website/` as it stands, so it has to be
# rebuilt whenever an example changes.
.PHONY: website-examples
website-examples:
@command -v lua > /dev/null \
|| (echo "No lua interpreter on this shell" && exit 1)
cargo build --package luacad --release
cd website-src \
&& LUACAD=../target/release/luacad lua build_examples.lua
# The browser build behind https://luacad.ad-si.com/playground.
#
# Needs Emscripten on the shell: `nix develop` provides it, as does sourcing
# an emsdk's `emsdk_env.sh`. The per-target compiler variables are set because
# a `CC` inherited from the environment — a Nix dev shell sets one, for
# instance — otherwise wins over the `emcc` the `cc` crate would pick for this
# target on its own.
.PHONY: wasm
wasm:
@command -v emcc > /dev/null \
|| (echo "No emcc on this shell: run \`nix develop\`," \
"or source <emsdk>/emsdk_env.sh" && exit 1)
CC_wasm32_unknown_emscripten=emcc \
CXX_wasm32_unknown_emscripten=em++ \
AR_wasm32_unknown_emscripten=emar \
cargo build --package luacad-wasm --release \
--target wasm32-unknown-emscripten
cp target/wasm32-unknown-emscripten/release/luacad-wasm.js \
target/wasm32-unknown-emscripten/release/luacad_wasm.wasm \
website/playground/
# An activated emsdk puts its own root on `PATH`, and that root holds a
# `node` *directory* — which shadows the real interpreter and fails with
# "Permission denied". Emscripten names the node it installed in
# `EMSDK_NODE`, so prefer that whenever it is set.
NODE ?= $(if $(EMSDK_NODE),$(EMSDK_NODE),node)
.PHONY: test-wasm
test-wasm: wasm
$(NODE) crates/luacad-wasm/smoke_test.mjs website/playground
# Serves the website exactly as GitHub Pages does, so the playground can be
# tried out locally. The wasm module needs a real HTTP server; opening the
# file directly does not work.
.PHONY: serve-website
serve-website: wasm
@echo "→ http://localhost:8000/playground/"
cd website && python3 -m http.server 8000
.PHONY: run
run:
cargo run --package luacad-studio
.PHONY: dev
dev:
watchexec --restart --exts rs,toml -- cargo run --package luacad-studio
.PHONY: package
package:
cargo package --workspace
.PHONY: release
release:
@echo '1. `cai changelog <first-commit-hash>`, then give the'
@echo ' `## Unreleased` heading its version and date, as in'
@echo ' `## 2026-08-22 - 1.2.0`.'
@echo '2. Bump the version in the root `Cargo.toml`: `workspace.package`'
@echo ' and every entry of `workspace.dependencies`. No member manifest'
@echo ' names a version, so those are all of them. A `cargo check`'
@echo ' writes the new versions into `Cargo.lock`.'
@echo '3. Regenerate what is derived from the sources, in case a change'
@echo ' since the last release did not:'
@echo ' make example-images # the images next to every example'
@echo ' make website-examples # website/examples.html'
@echo '4. `git add -u && git commit -m "Release <version>"`'
@echo '5. Check CI is green on main — the `package` job verifies every'
@echo ' crate builds from its tarball. `make package` does the same'
@echo ' locally, but reuses cached builds of the local registry and can'
@echo ' pass or fail against stale artifacts; trust CI over it.'
@echo '6. Publish in dependency order — each must be live on crates.io'
@echo ' before the next one can resolve it:'
@echo ' cargo publish -p luacad-manifold-sys'
@echo ' cargo publish -p luacad-prime-core'
@echo ' cargo publish -p luacad-scad-syntax'
@echo ' cargo publish -p luacad-scad-ir'
@echo ' cargo publish -p luacad-scad-eval'
@echo ' cargo publish -p opencsg-sys'
@echo ' cargo publish -p luacad'
@echo ' cargo publish -p luacad-studio'
@echo '7. Push a `v*` tag, or create the release at' \
'https://github.com/ad-si/LuaCAD/releases/new'
@echo ' The `release` job attaches the binaries of every platform and'
@echo ' their checksums; a bare tag gets a draft release to publish.'
@echo '8. Point the Homebrew tap at the new release:'
@echo ' https://github.com/ad-si/homebrew-tap'
@echo ' `brew install ad-si/tap/luacad` hands out the prebuilt binaries'
@echo ' attached in step 7, so the formula needs their new URLs and the'
@echo ' checksums from the `SHA256SUMS.txt` next to them.'
@echo -e \
"9. Announce release on \n" \
" - https://x.com \n" \
" - https://bsky.app \n" \
" - https://this-week-in-rust.org \n" \
" - https://news.ycombinator.com \n" \
" - https://lobste.rs \n" \
" - Reddit \n" \
" - https://reddit.com/r/rust \n"
.PHONY: install
install:
cargo install --path crates/luacad
cargo install --path crates/luacad-studio