-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathMakefile
More file actions
210 lines (169 loc) · 5.52 KB
/
Makefile
File metadata and controls
210 lines (169 loc) · 5.52 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
.PHONY: all
all: check test-unit
###############################################################################
# INSTALL
ifeq ($(OS),Windows_NT)
export WINDOWS := true
ifndef MSYSTEM
export POWERSHELL := true
endif
endif
ifdef WINDOWS
PLATFORM := Windows
else
PLATFORM := $(shell uname -s)
ifeq ($(PLATFORM),Linux)
export LINUX := true
endif
ifeq ($(PLATFORM),Darwin)
export MACOS := true
endif
endif
ifdef WINDOWS
WASM_PACK ?= $(USERPROFILE)/.cargo/bin/wasm-pack.exe
else
WASM_PACK ?= $(shell which wasm-pack || echo ~/.cargo/bin/wasm-pack)
endif
.PHONY: bootstrap
ifdef WINDOWS
bootstrap:
npm run install:rust:windows
else
bootstrap: ~/.asdfrc
asdf plugin add just
asdf plugin add nodejs
asdf plugin add python
@ echo
asdf install
npm run install:rust
endif
.PHONY: install
install: node_modules/.package-lock.json $(WASM_PACK) ## Install dependencies
node_modules/.package-lock.json: package.json package-lock.json
npm prune
npm install
$(WASM_PACK):
npm run install:wasm-pack:cargo
###############################################################################
# BUILD
CARGO_SOURCES := rust/.cargo/config.toml $(wildcard rust/Cargo.*) $(wildcard rust/*/Cargo.*)
KCL_SOURCES := $(wildcard public/kcl-samples/*/*.kcl)
RUST_SOURCES := $(wildcard rust/*.rs rust/*/*.rs rust/*/*/*.rs rust/*/*/*/*.rs rust/*/*/*/*/*.rs)
REACT_SOURCES := $(wildcard src/*.tsx src/*/*.tsx src/*/*/*.tsx src/*/*/*/*.tsx)
E2E_SOURCES := $(wildcard e2e/*.spec.ts e2e/*/*.spec.ts e2e/*/*/*.spec.ts e2e/*/*/*/*.spec.ts)
TYPESCRIPT_SOURCES := tsconfig.* $(wildcard src/*.ts src/*/*.ts src/*/*/*.ts src/*/*/*/*.ts)
VITE_SOURCES := .env* $(wildcard vite.*)
.PHONY: build
build: install public/kcl_wasm_lib_bg.wasm public/kcl-samples/manifest.json .vite/build/main.js
public/kcl_wasm_lib_bg.wasm: $(CARGO_SOURCES) $(RUST_SOURCES)
ifdef WINDOWS
npm run build:wasm:dev:windows
else
npm run build:wasm:dev
endif
public/kcl-samples/manifest.json: $(KCL_SOURCES)
ifndef WINDOWS
cd rust/kcl-lib && EXPECTORATE=overwrite cargo test generate_manifest
@ touch $@
endif
.vite/build/main.js: $(REACT_SOURCES) $(TYPESCRIPT_SOURCES) $(VITE_SOURCES) $(E2E_SOURCES)
npm run tronb:vite:dev
###############################################################################
# CHECK
.PHONY: check
check: format lint
.PHONY: format
format: install ## Format the code
npm run fmt
.PHONY: lint
lint: install public/kcl_wasm_lib_bg.wasm ## Lint the code
npm run tsc
npm run lint
###############################################################################
# RUN
TARGET ?= desktop
.PHONY: run
run: run-$(TARGET)
.PHONY: run-web
run-web: install build ## Start the web app
npm run start
.PHONY: run-desktop
run-desktop: install build ## Start the desktop app
npm run tron:start
###############################################################################
# TEST
PW_ARGS ?=
E2E_GREP ?=
E2E_WORKERS ?=
E2E_FAILURES ?= 1
ifdef MACOS
E2E_MODE ?= changed
else
E2E_MODE ?= none
endif
.PHONY: test
test: test-unit test-integration test-e2e-web
.PHONY: test-unit
test-unit: install ## Run the unit tests
npm run test:unit
.PHONY: test-integration
test-integration: install public/kcl_wasm_lib_bg.wasm ## Run the integration tests
npm run test:integration
.PHONY: test-e2e
test-e2e: test-e2e-$(TARGET)
ifndef E2E_GREP
npm run test:e2e:kcl
endif
.PHONY: test-e2e-web
test-e2e-web: install build ## Run the web e2e tests
ifdef E2E_GREP
npm run test:e2e:web -- --headed --grep="$(E2E_GREP)" --max-failures=$(E2E_FAILURES) "$(PW_ARGS)"
else
npm run test:e2e:web -- --workers='100%' "$(PW_ARGS)"
endif
.PHONY: test-e2e-desktop
test-e2e-desktop: install build ## Run the desktop e2e tests
ifdef E2E_GREP
npm run test:e2e:desktop -- --grep="$(E2E_GREP)" --max-failures=$(E2E_FAILURES) "$(PW_ARGS)"
else
npm run test:e2e:desktop -- --workers='100%' "$(PW_ARGS)"
endif
.PHONY: test-snapshots
test-snapshots: install build ## Run the snapshot tests
ifndef MACOS
@ echo "NOTE: Snapshots cannot be updated on $(PLATFORM)"
endif
ifdef E2E_GREP
npm run test:snapshots -- --headed --update-snapshots=$(E2E_MODE) --grep="$(E2E_GREP)"
else
npm run test:snapshots -- --update-snapshots=$(E2E_MODE)
endif
###############################################################################
# CLEAN
.PHONY: clean
clean: ## Delete all artifacts
ifdef POWERSHELL
git clean --force -d -x --exclude=.env* --exclude=**/*.env
else
rm -rf .vite/ build/ out/
rm -rf trace.zip playwright-report/ test-results/ e2e/playwright/temp*.png
rm -rf public/kcl_wasm_lib_bg.wasm
rm -rf rust/*/bindings/ rust/*/pkg/ rust/target/
rm -rf node_modules/ packages/*/node_modules/ rust/*/node_modules/
endif
.PHONY: help
help: install
ifdef POWERSHELL
@ powershell -Command "Get-Content $(MAKEFILE_LIST) | Select-String -Pattern '^[^\s]+:.*##\s.*$$' | ForEach-Object { $$line = $$_.Line -split ':.*?##\s+'; Write-Host -NoNewline $$line[0].PadRight(30) -ForegroundColor Cyan; Write-Host $$line[1] }"
else
@ grep -E '^[^[:space:]]+:.*## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
endif
.DEFAULT_GOAL := help
###############################################################################
# I'm sorry this is so specific to my setup you may as well ignore this.
# This is so you don't have to deal with electron windows popping up constantly.
# It should work for you other Linux users.
lee-electron-test:
Xephyr -br -ac -noreset -screen 1200x500 :2 &
DISPLAY=:2 NODE_ENV=development PW_TEST_CONNECT_WS_ENDPOINT=ws://127.0.0.1:4444/ npm run tron:test -g "when using the file tree"
killall Xephyr