-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
justfile
executable file
·153 lines (130 loc) · 4.95 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
##!/usr/bin/env just --justfile
# Overrides the default Rust toolchain set in `rust-toolchain.toml`.
toolchain := ""
# configures what profile to use for builds.
profile := "dev"
_cargo := "cargo" + if toolchain != "" { " +" + toolchain } else { "" }
_rustflags := env_var_or_default("RUSTFLAGS", "")
_buildstd := "-Z build-std=core,alloc -Z build-std-features=compiler-builtins-mem"
_rustdoc := _cargo + " doc --no-deps --all-features"
# If we're running in Github Actions and cargo-action-fmt is installed, then add
# a command suffix that formats errors.
_fmt_clippy := if env_var_or_default("GITHUB_ACTIONS", "") != "true" { "" } else {
```
if command -v cargo-action-fmt >/dev/null 2>&1; then
echo "--message-format=json -- -Dwarnings | cargo-action-fmt"
fi
```
}
_fmt := if env_var_or_default("GITHUB_ACTIONS", "") != "true" { "" } else {
```
if command -v cargo-action-fmt >/dev/null 2>&1; then
echo "--message-format=json | cargo-action-fmt"
fi
```
}
_docstring := "
justfile for k23
see https://just.systems/man/en/
Available variables:
toolchain # overrides the default Rust toolchain set in the
# rust-toolchain.toml file.
profile # configures what Cargo profile (release or debug) to use
# for builds.
Variables can be set using `just VARIABLE=VALUE ...` or
`just --set VARIABLE VALUE ...`.
"
# env var to set the cargo runner for the riscv64 target
export CARGO_TARGET_RISCV64GC_K23_NONE_KERNEL_RUNNER := "just _run_riscv64"
# default recipe to display help information
_default:
@echo '{{ _docstring }}'
@just --list
# run the OS
run cargo_args *args="":
{{ _cargo }} run \
-p kernel \
--target kernel/riscv64gc-k23-none-kernel.json \
--profile {{ profile }} \
{{ _buildstd }} \
{{ cargo_args }} \
-- {{ args }}
# quick check for development
check crate="" *cargo_args="":
{{ _cargo }} check \
{{ if crate == "" { "--workspace --exclude loader --exclude panic" } else { "-p" } }} {{ crate }} \
--target kernel/riscv64gc-k23-none-kernel.json \
{{ _buildstd }} \
{{ _fmt }} \
{{ cargo_args }}
# run all tests and checks
preflight crate="" *cargo_args="": (lint crate cargo_args)
# run lints (clippy, rustfmt, docs) for a crate or the entire for the workspace.
lint crate="" *cargo_args="": (clippy crate cargo_args) (check-fmt crate cargo_args) (check-docs crate cargo_args)
# run clippy on a crate or the entire workspace.
clippy crate="" *cargo_args="":
{{ _cargo }} clippy \
{{ if crate == "" { "--workspace --exclude loader --exclude panic" } else { "-p" } }} {{ crate }} \
--target kernel/riscv64gc-k23-none-kernel.json \
{{ _buildstd }} \
{{ _fmt_clippy }} \
{{ cargo_args }}
# check formatting for a crate or the entire workspace.
check-fmt crate="" *cargo_args="":
{{ _cargo }} fmt --check \
{{ if crate == "" { "--all" } else { "-p" } }} {{ crate }} \
{{ _fmt }} \
{{ cargo_args }}
# check documentation for a crate or the entire workspace.
check-docs crate="" *cargo_args="": (build-docs crate cargo_args) (test-docs crate cargo_args)
# build documentation for a crate or the entire workspace.
build-docs crate="" *cargo_args="":
{{ _rustdoc }} \
{{ if crate == '' { '--workspace --exclude panic --exclude loader --exclude wast' } else { '--package' } }} {{ crate }} \
--target kernel/riscv64gc-k23-none-kernel.json \
{{ _buildstd }} \
{{ _fmt }} \
{{ cargo_args }}
# test documentation for a crate or the entire workspace.
test-docs crate="" *cargo_args="":
{{ _cargo }} test --doc \
{{ if crate == "" { "--workspace --exclude panic --exclude loader" } else { "--package" } }} {{ crate }} \
--target kernel/riscv64gc-k23-none-kernel.json \
{{ _buildstd }} \
{{ _fmt }} \
{{ cargo_args }}
# run all tests
test cargo_args="" *args="": && (test-docs cargo_args)
{{ _cargo }} test \
-p kernel \
--target kernel/riscv64gc-k23-none-kernel.json \
--profile {{ profile }} \
{{ _buildstd }} \
{{ _fmt }} \
{{ cargo_args }} \
-- {{ args }}
# open the manual in development mode
manual:
cd manual && mdbook serve --open
_run_riscv64 binary *args: (_build_bootimg binary)
@echo Running {{binary}}
qemu-system-riscv64 \
-kernel \
target/riscv64imac-k23-none-loader/{{ if profile == "dev" { "debug" } else { profile } }}/loader \
-machine virt \
-cpu rv64 \
-smp 1 \
-m 512M \
-d guest_errors,int \
-display none \
-serial stdio \
-semihosting-config \
enable=on,target=native \
{{args}}
_build_bootimg $KERNEL:
{{_cargo}} build \
-p loader \
--target loader/riscv64imac-k23-none-loader.json \
--profile {{ profile }} \
{{ _buildstd }} \
{{ _fmt }}