Rust: add local copy of rust.ungrammar

This copy is injected by the existing `//rust/ast-generator:inject-sources`
target, and is useful for development.
This commit is contained in:
Paolo Tranquilli
2025-03-21 09:48:29 +01:00
parent 04f9694f89
commit 7d312feffe
3 changed files with 17 additions and 7 deletions

View File

@@ -2,3 +2,4 @@
/.idea
/src/codegen/grammar.rs
/src/codegen/grammar/
/rust.ungram

View File

@@ -11,7 +11,7 @@ load("//misc/bazel/3rdparty/tree_sitter_extractors_deps:defs.bzl", "aliases", "a
ra_ap_syntax_workspace, _, _ = str(ra_ap_syntax_label).partition("//")
alias(
name = "ungram",
name = "rust.ungram",
actual = "%s//:rust.ungram" % ra_ap_syntax_workspace,
visibility = ["//rust/codegen:__pkg__"],
)
@@ -45,9 +45,9 @@ codeql_rust_binary(
exclude = ["src/codegen/**"],
) + [":codegen"],
aliases = aliases(),
args = ["$(rlocationpath :ungram)"],
args = ["$(rlocationpath :rust.ungram)"],
compile_data = glob(["src/templates/*.mustache"]),
data = [":ungram"],
data = [":rust.ungram"],
proc_macro_deps = all_crate_deps(
proc_macro = True,
),
@@ -69,7 +69,10 @@ write_file(
# using cat instead of cp to honor default umask
# (also, macOS does not support `cp --no-preserve=mode`)
'cat "$(rlocation "$%s")" > "$DST_DIR/%s"' % item
for item in enumerate(_codegen_outs, 2)
for item in enumerate(
["rust.ungram"] + _codegen_outs,
2,
)
],
is_executable = True,
)
@@ -77,8 +80,14 @@ write_file(
sh_binary(
name = "inject-sources",
srcs = [":update"],
args = ["$(rlocationpath Cargo.toml)"] + ["$(rlocationpath %s)" % f for f in _codegen_outs],
data = ["Cargo.toml"] + _codegen_outs,
args = ["$(rlocationpath %s)" % f for f in [
"Cargo.toml",
":rust.ungram",
] + _codegen_outs],
data = [
"Cargo.toml",
":rust.ungram",
] + _codegen_outs,
deps = ["//misc/bazel:sh_runfiles"],
)