-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
110 lines (89 loc) · 2.68 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
set windows-shell := ["pwsh", "-NoLogo", "-NoProfileLoadTime", "-Command"]
project_name := "http-server"
profile := env_var_or_default("profile", "debug")
os := \
if \
env_var_or_default("os", "") == "Windows_NT" { "windows" } \
else if \
env_var_or_default("os", "") != "" { env_var("os") } \
else \
{ os() }
arch := \
if \
env_var_or_default("arch", "") != "" { env_var("arch") } \
else if \
arch() == "x86_64" { "amd64" } \
else if \
arch() == "aarch64" { "arm64" } \
else \
{ arch() }
target := \
if \
os + arch == "linuxamd64" { "x86_64-unknown-linux-musl" } \
else if \
os + arch == "linuxarm64" { "aarch64-unknown-linux-musl" } \
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)
[unix]
build:
@rm -rf "{{out_dir}}"
@rm -rf "{{out_dir_link}}"
@mkdir -p "{{out_dir}}"
cargo build {{profile_cargo}} {{target_cargo}}
@cp "./target/.cargo/{{target}}/{{profile}}/{{project_name}}" "{{out_dir}}"
@# ln -rs "{{out_dir}}" "{{out_dir_link}}"
[windows]
build:
@if (Test-Path {{out_dir}}) { Remove-Item -Recurse -Force {{out_dir}} | Out-Null }
@if (Test-Path {{out_dir_link}}) { Remove-Item -Recurse -Force {{out_dir_link}} | Out-Null }
@New-Item -ItemType "directory" -Force -Path "{{out_dir}}" | Out-Null
cargo build {{profile_cargo}} {{target_cargo}}
Copy-Item ".\target\.cargo\{{target}}\{{profile}}\{{project_name}}.exe" -Destination "{{out_dir}}" | Out-Null
@# New-Item -Path "{{out_dir}}" -ItemType SymbolicLink -Value "{{out_dir_link}}"
[unix]
run *ARGS:
just build
{{out_dir}}/{{project_name}} {{ARGS}}
[windows]
run *ARGS:
just build
{{out_dir}}/{{project_name}}.exe {{ARGS}}
test:
cargo test
lint:
cargo +nightly clippy -- --deny "warnings"
lint_fix *ARGS:
cargo +nightly clippy --fix --allow-staged -- --deny "warnings"
fmt:
cargo +nightly fmt --check
fmt_fix *ARGS:
cargo +nightly fmt
watch *ARGS:
cargo watch --watch src -- just run {{ARGS}}
watch-silent *ARGS:
cargo watch -- bash -c "just build && clear; {{out_dir}}/http-server {{ARGS}}"
reinstall:
just build
cp {{out_dir}}/{{project_name}} $(which http-server-rs)