From 8e31abaefe59080125adb1ae3e2f5cbb3e84057e Mon Sep 17 00:00:00 2001 From: Paolo Tranquilli Date: Tue, 15 Oct 2024 14:37:30 +0200 Subject: [PATCH 1/2] Rust: fix codegen to allow `--force` This passes command line arguments to codegen, allowing in particular `--force` to be passed. Also, a convenience `//rust/codegen:py` is added to only run the python based code generation, which will be faster and enough when `ast-generator` is unchanged. --- rust/codegen/BUILD.bazel | 15 +++++++++++++++ rust/codegen/codegen.sh | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/rust/codegen/BUILD.bazel b/rust/codegen/BUILD.bazel index 43e057a6fbf6..ba9f2565b70e 100644 --- a/rust/codegen/BUILD.bazel +++ b/rust/codegen/BUILD.bazel @@ -1,3 +1,5 @@ +load("@bazel_skylib//rules:native_binary.bzl", "native_binary") + _args = [ "//rust/ast-generator", "//rust/ast-generator:manifest", @@ -15,3 +17,16 @@ sh_binary( "//misc/bazel:sh_runfiles", ], ) + +native_binary( + name = "py", + src = "//misc/codegen", + out = "codegen", + args = [ + "--configuration-file=$(location //rust:codegen-conf)", + ], + data = [ + "//rust:codegen-conf", + ], + visibility = ["//rust:__subpackages__"], +) diff --git a/rust/codegen/codegen.sh b/rust/codegen/codegen.sh index cb15c796fd6a..4ab8ad9a5aef 100755 --- a/rust/codegen/codegen.sh +++ b/rust/codegen/codegen.sh @@ -4,10 +4,12 @@ set -eu source misc/bazel/runfiles.sh 2>/dev/null || source external/ql+/misc/bazel/runfiles.sh + ast_generator="$(rlocation "$1")" ast_generator_manifest="$(rlocation "$2")" codegen="$(rlocation "$3")" codegen_conf="$(rlocation "$4")" +shift 4 CARGO_MANIFEST_DIR="$(dirname "$ast_generator_manifest")" "$ast_generator" -"$codegen" --configuration-file="$codegen_conf" +"$codegen" --configuration-file="$codegen_conf" "$@" From 2c970a080d9a57a01b15ea0f3895309d19e18d7a Mon Sep 17 00:00:00 2001 From: Paolo Tranquilli Date: Tue, 15 Oct 2024 16:50:15 +0200 Subject: [PATCH 2/2] Rust: remove useless blank line Co-authored-by: Simon Friis Vindum --- rust/codegen/codegen.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/rust/codegen/codegen.sh b/rust/codegen/codegen.sh index 4ab8ad9a5aef..0d746eeb289a 100755 --- a/rust/codegen/codegen.sh +++ b/rust/codegen/codegen.sh @@ -4,7 +4,6 @@ set -eu source misc/bazel/runfiles.sh 2>/dev/null || source external/ql+/misc/bazel/runfiles.sh - ast_generator="$(rlocation "$1")" ast_generator_manifest="$(rlocation "$2")" codegen="$(rlocation "$3")"