-
Notifications
You must be signed in to change notification settings - Fork 615
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·101 lines (86 loc) · 3.55 KB
/
Copy pathbootstrap.sh
File metadata and controls
executable file
·101 lines (86 loc) · 3.55 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
#!/usr/bin/env bash
# IPC codegen package.
# Generates IPC bindings from committed JSON schemas under schemas/, in TS, C++,
# Rust and Zig. Zero npm dependencies — runs with just Node.js (v22+).
#
# The build's only direct consumer is its own cross-language test harness under
# echo_example/. Service consumers invoke ipc-codegen from their own build
# scripts with their own schema inputs.
source $(git rev-parse --show-toplevel)/ci3/source_bootstrap
hash=$(cache_content_hash .rebuild_patterns)
function build {
echo_header "ipc-codegen build"
# Service generation is invoked by each service's own build flow. The build
# step here invokes each echo example project's own bootstrap, so every
# project documents and owns its generation/build flow.
(cd echo_example/cpp && ./bootstrap.sh)
(cd echo_example/rust && ./bootstrap.sh)
(cd echo_example/ts && ./bootstrap.sh)
(cd echo_example/ts_package && ./bootstrap.sh)
(cd echo_example/zig && ./bootstrap.sh)
# NB: the golden msgpack fixtures under echo_example/schema/golden/ are
# COMMITTED and FROZEN — they're the binding wire-format contract. Don't
# regenerate them here. If a deliberate wire-format change requires
# refreshing them, run `./bootstrap.sh update_goldens` and commit the diff.
}
function update_goldens {
echo_header "ipc-codegen update_goldens"
# Rebuild the rust generate_golden binary first.
(cd echo_example/rust && cargo build --quiet --bin generate_golden)
echo_example/rust/target/debug/generate_golden --output-dir echo_example/schema/golden
echo ""
echo "Goldens refreshed. Review the diff carefully — these are the wire-format"
echo "contract, and any byte-level change is a breaking change for external"
echo "implementations of the schema."
}
function test_cmds {
local matrix_langs=(rust ts zig cpp)
local prefix="$hash:CPUS=1:TIMEOUT=120s"
local script="ipc-codegen/echo_example/scripts/run_cross_language_test.sh"
# Generator unit tests (schema validation).
echo "$prefix node --experimental-strip-types --no-warnings ipc-codegen/test/schema_visitor.test.ts"
# Golden tests (each language verifies it can deserialize the goldens
# baked by build(), and re-encode them byte-identically).
echo "$prefix $script golden rust"
echo "$prefix $script golden ts"
echo "$prefix $script golden cpp"
echo "$prefix $script golden zig"
echo "$prefix ipc-codegen/echo_example/ts_package/test.sh uds"
echo "$prefix ipc-codegen/echo_example/ts_package/test.sh shm"
# Matrix: one command per (server, client) pair over UDS.
for server in "${matrix_langs[@]}"; do
for client in "${matrix_langs[@]}"; do
echo "$prefix $script matrix $server $client uds"
done
done
# SHM matrix. Argument order is server then client. TS is only covered as a
# client because ipc-runtime/ts has no SHM server.
local shm_server_langs=(rust zig cpp)
local native_shm_client_langs=(rust zig cpp)
for server in "${shm_server_langs[@]}"; do
for client in "${native_shm_client_langs[@]}"; do
echo "$prefix $script matrix $server $client shm"
done
done
# TS SHM client coverage. The NAPI addon is built by ipc-runtime/bootstrap.sh
# during build(); a missing addon should fail these tests loudly rather than
# silently dropping coverage.
for server in "${shm_server_langs[@]}"; do
echo "$prefix $script matrix $server ts shm"
done
}
function test {
echo_header "ipc-codegen test"
test_cmds | filter_test_cmds | parallelize
}
case "$cmd" in
"")
build
;;
"hash")
echo "$hash"
;;
*)
default_cmd_handler "$@"
;;
esac