-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBUILD
More file actions
33 lines (30 loc) · 1.2 KB
/
Copy pathBUILD
File metadata and controls
33 lines (30 loc) · 1.2 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
package(default_visibility = ["//visibility:public"])
# Bundle all artifacts into bazel-bin/ztracing/
genrule(
name = "ztracing",
srcs = [
"//src:ztracing_wasm",
"//src:shell.html",
"//src:coi-serviceworker.js",
],
outs = [
"ztracing/index.html",
"ztracing/ztracing.js",
"ztracing/ztracing.wasm",
"ztracing/coi-serviceworker.js",
],
cmd = """
# Generate index.html from shell template, pointing to ztracing.js
sed 's/{{{ SCRIPT }}}/<script src=\"ztracing.js\"><\\/script>/' $(location //src:shell.html) > $(location ztracing/index.html)
# Copy coi-serviceworker.js
cp -f $(location //src:coi-serviceworker.js) $(location ztracing/coi-serviceworker.js)
# Copy artifacts from the wasm_cc_binary target
for f in $(locations //src:ztracing_wasm); do
if [[ $$f == */ztracing_wasm_cc.js ]]; then
sed 's/ztracing_wasm_cc\\.wasm/ztracing.wasm/g' $$f > $(location ztracing/ztracing.js)
elif [[ $$f == */ztracing_wasm_cc.wasm ]] && [[ $$f != *.debug.wasm ]]; then
cp -f $$f $(location ztracing/ztracing.wasm)
fi
done
""",
)