Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fields to FlagInfo in bazel_flags.proto #25006

Open
tempoz opened this issue Jan 21, 2025 · 0 comments
Open

Add fields to FlagInfo in bazel_flags.proto #25006

tempoz opened this issue Jan 21, 2025 · 0 comments

Comments

@tempoz
Copy link

tempoz commented Jan 21, 2025

Description of the feature request:

I would like to add:

  • a repeated field listing acceptable values for enum flags (e.g. "pretty_print" for subcommands)
  • a map field listing the flags/values an expansion argument expands to (e.g. { "test_arg": "--wrapper_script_flag=--debug" "test_output": "streamed", "test_strategy": "exclusive", "test_timeout": "9999", "nocache_test_results": "1" }

Which category does this issue belong to?

CLI

What underlying problem are you trying to solve with this feature?

There is currently no way to determine, using only the flag proto, whether a flag that has_negative_flag is being passed a valid value as its argument, since it is possible such a flag accepts an enum.

There is currently no way to determine, using only the flag proto, whether an enum flag is being passed a valid value, since there is neither any way to determine which flags are enums nor any way to determine what the valid values of such a flag might be.

Currently, expansion flags can be identified using only the flag proto, as they are the only flags for which both the has_negative_flag and requires_value fields are false. However, they cannot be expanded, and thus canonicalization of a set of flags using only the flag proto may include flags that are superseded by later expansion flags, which is not ideal.

For context, my current goal is to use help flags-as-proto output to parse the arguments passed to a bazel command, detect trivial problems, and canonicalize the arguments passed in.

Which operating system are you running Bazel on?

debian trixie

What is the output of bazel info release?

release 8.0.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

Have you found anything relevant by searching the web?

I found that there are boolean-like flags that also accept enum values via BoolOrEnumConverter.

I found that there are currently 21 expansion options in bazel:

noincompatible_genquery_use_graphless_query
incompatible_genquery_use_graphless_query
persistent_android_resource_processor
persistent_multiplex_android_resource_processor
persistent_android_dex_desugar
persistent_multiplex_android_dex_desugar
persistent_multiplex_android_tools
start_app
debug_app
java_debug
remote_download_minimal
remote_download_toplevel
host_jvm_debug
long
short
expunge_async
experimental_spawn_scheduler
experimental_persistent_javac
null
order_results
noorder_results

If the expansions are added to the proto, I can support these 21 manually in order to be compatible with older versions of bazel, and then support any expansion options added in the future dynamically using the proto.

Any other information, logs, or outputs that you want to share?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants