-
Notifications
You must be signed in to change notification settings - Fork 558
Expand file tree
/
Copy pathjustfile
More file actions
163 lines (123 loc) · 5.1 KB
/
justfile
File metadata and controls
163 lines (123 loc) · 5.1 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
alias b := build
alias t := test
alias f := format
alias st := stream-test
alias c := coverage
alias w := watch
default:
@just --list
pwd := `pwd`
prepare:
@if [ "{{os()}}" = "macos" ]; then just prepare-macos; elif [ "{{os()}}" = "linux" ]; then just prepare-ubuntu; else echo "Unsupported OS: {{os()}}"; exit 1; fi
cargo install gen-compile-commands watchexec-cli
just create-external
just compile-commands
just prepare-rust
prepare-rust:
rustup install 1.91.0
rustup component add rust-analyzer --toolchain 1.91.0
prepare-ubuntu:
sudo apt-get install -y --no-install-recommends libc++abi1-19 libc++1-19 libc++-19-dev lld-19 bazelisk python3 lcov fd-find
prepare-macos:
brew install --quiet bazelisk python3 lcov fd
compile-commands:
rm -f compile_commands.json
gen-compile-commands --root {{pwd}} --compile-flags compile_flags.txt --out compile_commands.json --src-dir {{pwd}}/src
clean:
rm -f compile_commands.json
build *args="//...":
bazel build {{args}}
# example: just watch run -- serve $(pwd)/samples/helloworld/config.capnp
run *args="-- --help":
bazel run //src/workerd/server:workerd -- {{args}} --watch --verbose --experimental
build-asan *args="//...":
just build {{args}} --config=asan
test *args="//...":
bazel test {{args}}
test-asan *args="//...":
just test {{args}} --config=asan
# e.g. just stream-test //src/cloudflare:cloudflare.capnp@eslint
stream-test *args:
bazel test {{args}} --test_output=streamed --nocache_test_results --test_tag_filters= --test_size_filters=
# e.g. just node-test zlib
node-test test_name *args:
just stream-test //src/workerd/api/node/tests:{{test_name}}-nodejs-test@ {{args}}
# e.g. just wpt-test urlpattern
wpt-test test_name:
just stream-test //src/wpt:{{test_name}}
lldb-wpt-test test_name: build
cd bazel-bin/src/wpt/{{test_name}}.runfiles/workerd/src/wpt; lldb ../workerd/server/workerd -- test {{test_name}}.wd-test --experimental --directory-path=TEST_TMPDIR=/tmp
asan-wpt-test test_name:
bazel test //src/workerd/api/wpt:{{test_name}} --config=asan
new-wpt-test test_name:
mkdir -p src/wpt/$(dirname {{test_name}})
echo "export default {};" > src/wpt/{{test_name}}-test.ts
git add src/wpt/{{test_name}}-test.ts
echo >> src/wpt/BUILD.bazel
echo 'wpt_test(name = "{{test_name}}", config = "{{test_name}}-test.ts", wpt_directory = "@wpt//:{{test_name}}@module")' >> src/wpt/BUILD.bazel
./tools/cross/format.py
bazel test //src/wpt:{{test_name}}@ --test_env=GEN_TEST_CONFIG=1 --test_output=streamed
# Specify the full Bazel target name for the test to be created.
# e.g. just new-test //src/workerd/api/tests:v8-temporal-test
new-test test_name:
./tools/unix/new-test.sh {{test_name}}
format: rustfmt
python3 tools/cross/format.py
internal-pr:
./tools/unix/create-internal-pr.sh
# update dependencies with a given prefix (all by default)
update-deps prefix="":
./build/deps/update-deps.py {{prefix}}
# equivalent to `cargo update`; use `workspace` or <package> to limit update scope
update-rust package="full":
bazel run //deps/rust:crates_vendor -- --repin {{package}}
rustfmt:
bazel run @rules_rust//:rustfmt
# example: just bench mimetype
bench path:
bazel run //src/workerd/tests:bench-{{path}} --config=benchmark
# example: just clippy dns
clippy package="...":
bazel build //src/rust/{{package}} --config=lint
# example: just clang-tidy //src/rust/jsg:ffi
clang-tidy target="//...":
bazel build {{target}} --config=clang-tidy
generate-types:
bazel build //types
cp -r bazel-bin/types/definitions/latest types/generated-snapshot/
cp -r bazel-bin/types/definitions/experimental types/generated-snapshot/
update-reported-node-version:
python3 tools/update_node_version.py src/workerd/api/node/node-version.h
# called by rust-analyzer discoverConfig (quiet recipe with no output)
# rust-analyzer doesn't like stderr output, redirect it to /dev/null
@_rust-analyzer:
rm -rf ./rust-project.json
bazel run @rules_rust//tools/rust_analyzer:discover_bazel_rust_project 2>/dev/null
create-external:
tools/unix/create-external.sh
bench-all:
bazel query 'attr(tags, "[\[ ]google_benchmark[,\]]", //... + @capnp-cpp//...)' --output=label | xargs -I {} bazel run --config=benchmark {}
lint: eslint
eslint:
just stream-test \
//src/cloudflare:cloudflare@eslint \
//src/node:node@eslint \
//src/pyodide:pyodide_static@eslint \
//src/wpt:wpt-all@tsproject@eslint \
//types:types_lib@eslint
# Generate code coverage report (Linux only)
coverage path="//...":
bazel coverage --config=coverage {{path}}
genhtml --branch-coverage --ignore-errors category --output coverage "$(bazel info output_path)/_coverage/_coverage_report.dat"
open coverage/index.html
profile path:
bazel run //src/workerd/tests:bench-{{path}} --config=benchmark --run_under="perf record -F max --call-graph lbr"
PERF_FILE=$(fdfind perf.data bazel-bin | grep "{{path}}" | head -1); \
if [ -n "$PERF_FILE" ] && [ -s "$PERF_FILE" ]; then \
cp $PERF_FILE perf.data; \
perf report --input=$PERF_FILE; \
else \
echo "No valid perf.data file found for {{path}}"; \
fi
watch *args="build":
watchexec -rc -w src -w build just {{args}}