Skip to content

Refactor protobuf flag abstraction layer to custom flag targets#28787

Draft
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_952990495
Draft

Refactor protobuf flag abstraction layer to custom flag targets#28787
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_952990495

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Jul 23, 2026

Copy link
Copy Markdown

Refactor protobuf flag abstraction layer to custom flag targets

Instead of having rules depend on both native and Starlark versions of flags and reconciling them inside the rule implementation, this change moves the resolution logic into custom build setting flag targets (compat_bool_flag and compat_string_list_flag) defined in third_party/protobuf/bazel/private/compat_flag.bzl.

Key details:

  • compat_bool_flag: Defines a string build setting flag target with a "default" sentinel value. When un-set on the command line, it falls back dynamically to reading native options on ctx.fragments.proto or default values, providing a boolean BuildSettingInfo.
  • compat_string_list_flag: Defines a string-list build setting flag target that reconciles explicit Starlark build settings with ctx.fragments.proto and default values.
  • Rules reference the flag targets directly (without separate helper _compat targets or config_setting rules).
  • Replaces native_bool_flag.bzl with compat_flag.bzl.

@copybara-service
copybara-service Bot force-pushed the test_952990495 branch 8 times, most recently from b83ceee to 3ce22da Compare July 24, 2026 18:53
Instead of having rules depend on both native and Starlark versions of flags and reconciling them inside the rule implementation, this change moves the resolution logic into custom build setting flag targets (`compat_bool_flag` and `compat_string_list_flag`) defined in `third_party/protobuf/bazel/private/compat_flag.bzl`.

Key details:
- `compat_bool_flag`: Defines a string build setting flag target with a "default" sentinel value. When un-set on the command line, it falls back dynamically to reading native options on `ctx.fragments.proto` or default values, providing a boolean `BuildSettingInfo`.
- `compat_string_list_flag`: Defines a string-list build setting flag target that reconciles explicit Starlark build settings with `ctx.fragments.proto` and default values.
- Rules reference the flag targets directly (without separate helper `_compat` targets or `config_setting` rules).
- Replaces `native_bool_flag.bzl` with `compat_flag.bzl`.

PiperOrigin-RevId: 952990495
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant