blob: cfcab921b352f5165d053dc02551dc6746b37def [file] [log] [blame]
Philipp Schrader272e07b2024-03-29 17:26:02 -07001load("@aspect_rules_js//js:defs.bzl", "js_run_binary")
2
3def foxglove_extension(name, **kwargs):
4 """Compiles a foxglove extension into a .foxe file.
5
6 Drag the generated .foxe file onto the foxglove UI in your browser. The
7 extension should then install automatically. If you want to update the
8 extension, drag a new version to the UI.
9
10 Use `tools/foxglove/create-foxglove-extension`. Don't use this rule
11 directly. See `tools/foxglove/README.md` for more details.
12
13 Args:
14 name: The name of the target.
15 **kwargs: The arguments to pass to js_run_binary.
16 """
17
18 # We need to glob all the non-Bazel files because we're going to invoke the
19 # `foxglove-extension` binary directly. That expects to have access to
20 # `package.json` and the like.
21 all_files = native.glob(
22 ["**"],
23 exclude = [
24 "BUILD",
25 "BUILD.bazel",
26 ],
27 )
28
29 # Run the `foxglove-extension` wrapper to create the .foxe file.
30 js_run_binary(
31 name = name,
32 srcs = all_files + [
33 ":node_modules",
34 ],
35 tool = "//tools/foxglove:foxglove_extension_wrapper",
36 outs = ["%s.foxe" % name],
37 args = [
38 "package",
39 "--out",
40 "%s.foxe" % name,
41 ],
42 target_compatible_with = [
43 "@platforms//cpu:x86_64",
44 ],
45 **kwargs
46 )