-
Notifications
You must be signed in to change notification settings - Fork 2
/
justfile
195 lines (164 loc) · 5.02 KB
/
justfile
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
set windows-shell := ["pwsh", "-NoLogo", "-NoProfileLoadTime", "-Command"]
MACH_VERSION := env_var_or_default("MACH_VERSION", "")
profile := env_var_or_default("profile", "debug")
os := env_var_or_default("os", os())
arch := \
if \
env_var_or_default("arch", "") != "" { env_var("arch") } \
else if \
arch() == "x86_64" { "amd64" } \
else if \
arch() == "aarch64" { "arm64" } \
else \
{ arch() }
dylib := \
if \
os == "windows" { "dll" } \
else if \
os == "macos" { "dylib" } \
else if \
os == "linux" { "so" } \
else \
{ os() }
bin := \
if \
os == "windows" { "mach.exe" } \
else \
{ "mach" }
target := \
if \
os + arch == "linuxamd64" { "x86_64-unknown-linux-gnu" } \
else if \
os + arch == "linuxarm64" { "aarch64-unknown-linux-gnu" } \
else if \
os + arch == "macosamd64" { "x86_64-apple-darwin" } \
else if\
os + arch == "macosarm64" { "aarch64-apple-darwin" } \
else if \
os + arch == "windowsamd64" { "x86_64-pc-windows-msvc" } \
else if \
os + arch == "windowsarm64" { "aarch64-pc-windows-msvc" } \
else \
{ env_var_or_default("target", "debug") }
profile_cargo := \
if \
profile != "debug" { "--profile " + profile } \
else \
{ "" }
target_cargo := \
if \
target == "debug" { "" } \
else if \
target == "" { "" } \
else \
{ "--target " + target }
out_dir := join(justfile_directory(), "target", os + "-" + arch, profile)
out_dir_link := join(justfile_directory(), "target", profile)
_default:
@echo "Available Env:"
@echo " profile"
@echo " debug [default]"
@echo " release"
@echo " os"
@echo " auto [default]"
@echo " linux"
@echo " macos"
@echo " windows"
@echo " arch"
@echo " auto [default]"
@echo " arm64"
@echo " amd64"
@just --list --unsorted
[unix]
build:
@# Install npm
@test -d node_modules || npm install
@# Clean dir
@rm -rf "./packages/mach_npm_bin/index.node"
cargo build {{profile_cargo}} {{target_cargo}}
@cp "./target/.cargo/{{target}}/{{profile}}/libmach_bundler_npm_os_arch.{{dylib}}" "./packages/mach_npm_bin/index.node"
[windows]
build:
@# Install npm
if (!(Test-Path 'node_modules')) { npm install }
@# Clean dir
@if (Test-Path ".\packages\mach_npm_bin\_napi\index.node") { Remove-Item -Recurse -Force ".\packages\mach_npm_bin\index.node" | Out-Null }
cargo build {{profile_cargo}} {{target_cargo}}
Copy-Item ".\target\.cargo\{{target}}\{{profile}}\mach_bundler_npm_os_arch.{{dylib}}" -Destination ".\packages\mach_npm_bin\index.node" | Out-Null
build-tsc:
cd "./packages/mach_npm" && npx tsc
[no-cd]
run *ARGS:
just build
env NODE_OPTIONS="--conditions=source --import tsx" npx mach {{ARGS}}
alias test-integration := integration-tests
integration-tests *ARGS:
just build
node --conditions=source --import tsx ./testing/setup.ts {{ARGS}}
alias test-unit := unit-tests
unit-tests:
cargo test
watch:
npx nodemon
fmt:
cargo +nightly fmt
node_modules/.bin/prettier ./packages --write
node_modules/.bin/prettier ./examples --write
bench-micro:
cargo bench
[unix]
build-publish:
npm i
just build-publish-common
just build
just build-tsc
cp "./README.md" "./packages/mach_npm"
cp "./README.md" "./packages/mach_npm_bin"
[windows]
build-publish:
npm i
just build-publish-common
just build
just build-tsc
Copy-Item ".\README.md" -Destination "packages\mach_npm" | Out-Null
Copy-Item ".\README.md" -Destination "packages\mach_npm_bin" | Out-Null
[private]
build-publish-common:
node {{justfile_directory()}}/.github/scripts/ci/string-replace.mjs \
"./packages/mach/Cargo.toml" \
"0.0.0-local" \
{{MACH_VERSION}}
node {{justfile_directory()}}/.github/scripts/ci/string-replace.mjs \
"./packages/mach_npm/package.json" \
"0.0.0-local" \
"{{MACH_VERSION}}"
node {{justfile_directory()}}/.github/scripts/ci/json.mjs \
"./packages/mach_npm_bin/package.json" \
"name" \
"@alshdavid/mach-{{os}}-{{arch}}"
node {{justfile_directory()}}/.github/scripts/ci/json.mjs \
"./packages/mach_npm_bin/package.json" \
"version" \
"{{MACH_VERSION}}"
node {{justfile_directory()}}/.github/scripts/ci/json.mjs \
"./packages/mach_npm_bin/package.json" \
"os.0" \
$(node "{{justfile_directory()}}/.github/scripts/ci/map.mjs" "os" {{os}})
node {{justfile_directory()}}/.github/scripts/ci/json.mjs \
"./packages/mach_npm_bin/package.json" \
"cpu.0" \
$(node "{{justfile_directory()}}/.github/scripts/ci/map.mjs" "arch" {{arch}})
benchmark project="mach" count="50" script="build" *ARGS="":
@just {{ if project == "mach" { "build" } else { "_skip" } }}
just benchmark-generate {{project}} {{count}}
cd benchmarks/{{project}}_{{count}} && \
rm -rf dist && \
CMD="console.log(require(\"./package.json\").scripts[\"build\"])" && \
CMD="$(echo $CMD | node)" && \
echo $CMD && \
mach_profiler=../{{project}}_{{count}}.csv \
time bash -c "$CMD {{ARGS}}"
benchmark-generate project="mach" count="50":
PROJECT={{project}} \
BENCH_COPIES={{count}} \
node .github/scripts/ci/generate_benchmark.mjs