load("@bazel_skylib//rules:run_binary.bzl", "run_binary") load("@rules_rust//rust:defs.bzl", "rust_binary") load("//:build/cc_ast_dump.bzl", "cc_ast_dump") # ======================================================================================== # Parameter Name Extractor # # Extracts the parameter names of functions, methods, etc. of the runtime API, # since they're not encoded in the type information generated by the RTTI dump cc_ast_dump( name = "dump_api_ast", src = "param-names-ast.c++", out = "api.ast.json.gz", tags = ["no-downstream"], target_compatible_with = select({ "@platforms//os:windows": ["@platforms//:incompatible"], "//conditions:default": [], }), deps = [ "//src/cloudflare", "//src/node", "//src/workerd/api:analytics-engine", "//src/workerd/api:base64", "//src/workerd/api:html-rewriter", "//src/workerd/api:hyperdrive", "//src/workerd/api:kv", "//src/workerd/api:memory-cache", "//src/workerd/api:r2", "//src/workerd/api:streams", "//src/workerd/api:urlpattern", "//src/workerd/api:urlpattern-standard", "//src/workerd/api:worker-loader", "//src/workerd/api:workers-module", "//src/workerd/api/node", "//src/workerd/io", "//src/workerd/jsg", "@capnp-cpp//src/capnp", ], ) rust_binary( name = "param_extractor_bin", srcs = ["param-extractor.rs"], tags = ["no-downstream"], target_compatible_with = select({ "@platforms//os:windows": ["@platforms//:incompatible"], "//conditions:default": [], }), deps = [ "@crates_vendor//:anyhow", "@crates_vendor//:clang-ast", "@crates_vendor//:flate2", "@crates_vendor//:pico-args", "@crates_vendor//:serde", "@crates_vendor//:serde_json", ], ) # Deliberately not marking this run_binary_target(): The exec configuration compiles with # optimization by default, causing it to run markedly faster than the (non-opt) target # configuration, where param_extractor would otherwise take several minutes to run. A different # approach would be to set -Copt-level=3 globally, but that's not helpful for debug builds. run_binary( name = "param_extractor", srcs = [ ":dump_api_ast", ], outs = ["param-names.json"], args = [ "--input", "$(location dump_api_ast)", "--output", "$(location param-names.json)", ], tags = ["no-downstream"], target_compatible_with = select({ "@platforms//os:windows": ["@platforms//:incompatible"], "//conditions:default": [], }), tool = "param_extractor_bin", visibility = ["//visibility:public"], )