Skip to content
File

Blob: src/workerd/tools/BUILD.bazel

2.7 KB
1load("@bazel_skylib//rules:run_binary.bzl", "run_binary")
2load("@rules_rust//rust:defs.bzl", "rust_binary")
3load("//:build/cc_ast_dump.bzl", "cc_ast_dump")
4 
5# ========================================================================================
6# Parameter Name Extractor
7#
8# Extracts the parameter names of functions, methods, etc. of the runtime API,
9# since they're not encoded in the type information generated by the RTTI dump
10 
11cc_ast_dump(
12 name = "dump_api_ast",
13 src = "param-names-ast.c++",
14 out = "api.ast.json.gz",
15 tags = ["no-downstream"],
16 target_compatible_with = select({
17 "@platforms//os:windows": ["@platforms//:incompatible"],
18 "//conditions:default": [],
19 }),
20 deps = [
21 "//src/cloudflare",
22 "//src/node",
23 "//src/workerd/api:analytics-engine",
24 "//src/workerd/api:base64",
25 "//src/workerd/api:html-rewriter",
26 "//src/workerd/api:hyperdrive",
27 "//src/workerd/api:kv",
28 "//src/workerd/api:memory-cache",
29 "//src/workerd/api:r2",
30 "//src/workerd/api:streams",
31 "//src/workerd/api:urlpattern",
32 "//src/workerd/api:urlpattern-standard",
33 "//src/workerd/api:worker-loader",
34 "//src/workerd/api:workers-module",
35 "//src/workerd/api/node",
36 "//src/workerd/io",
37 "//src/workerd/jsg",
38 "@capnp-cpp//src/capnp",
39 ],
40)
41 
42rust_binary(
43 name = "param_extractor_bin",
44 srcs = ["param-extractor.rs"],
45 tags = ["no-downstream"],
46 target_compatible_with = select({
47 "@platforms//os:windows": ["@platforms//:incompatible"],
48 "//conditions:default": [],
49 }),
50 deps = [
51 "@crates_vendor//:anyhow",
52 "@crates_vendor//:clang-ast",
53 "@crates_vendor//:flate2",
54 "@crates_vendor//:pico-args",
55 "@crates_vendor//:serde",
56 "@crates_vendor//:serde_json",
57 ],
58)
59 
60# Deliberately not marking this run_binary_target(): The exec configuration compiles with
61# optimization by default, causing it to run markedly faster than the (non-opt) target
62# configuration, where param_extractor would otherwise take several minutes to run. A different
63# approach would be to set -Copt-level=3 globally, but that's not helpful for debug builds.
64run_binary(
65 name = "param_extractor",
66 srcs = [
67 ":dump_api_ast",
68 ],
69 outs = ["param-names.json"],
70 args = [
71 "--input",
72 "$(location dump_api_ast)",
73 "--output",
74 "$(location param-names.json)",
75 ],
76 tags = ["no-downstream"],
77 target_compatible_with = select({
78 "@platforms//os:windows": ["@platforms//:incompatible"],
79 "//conditions:default": [],
80 }),
81 tool = "param_extractor_bin",
82 visibility = ["//visibility:public"],
83)