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

Cherry-pick changes related to new Bazel rules #18339

Merged
merged 13 commits into from
Sep 16, 2024
Merged

Cherry-pick changes related to new Bazel rules #18339

merged 13 commits into from
Sep 16, 2024

Conversation

haberman
Copy link
Member

This PR cherry-picks all commits on main in the bazel/ directory, except for these, which are not related to the new rules:

Cherry-pick command was:

$ git cherry-pick `git log --reverse --pretty=format:"%H" main ^28.x . | grep -Ev "bc394d2c6|a2fd240e0|bc394d2c6|ddb863c38|e4449ba24|8422e9795|e1dbeb0|f72e5ce37"`

There was only one merge conflict that required manual resolution, in WORKSPACE. But the resolution was straightforward.

protobuf-github-bot and others added 13 commits September 16, 2024 17:47
Move toolchain helpers into a separate private file. After the migration those should be removed, so let's not make it a new public APIs. Copybara also handles differences in toolchain type labels.

Remove ProtoLangToolchainInfo from proto_common. Providers need special care when moving and will be moved last.

Read INCOMPATIBLE_ENABLE_PROTO_TOOLCHAIN_RESOLUTION from native proto_common. This is a BuildLanguageConfiguration flag (load time flag) and may only be read through native support. Add a dependency to the latest bazel_features that supports this check. On older Bazel versions fail if ALLOWLIST is configured.

Implement version check for PackageSpecificationInfo. It's only available after Bazel 6.4.0.

The rest of the implementation matches Bazel version. Tests are quite extensive and will be submitted in separate PRs.

PiperOrigin-RevId: 651699412
Rewrite compile tests from BazelProtoCommonTest to Starlark. This is using rules_analysis for testing.

The tests are super fast (cca. 1s for all of the to run).

The tests work either with a redirect (calling native rule) or with actual implementation in the protobuf repository.

PiperOrigin-RevId: 651748083
Enable the Starlark rule only on Bazel versions, that have the Starlark version of ProtoInfo provider. That's needed, because only that exposed _transitive_proto_info field that's used in the rule.

PiperOrigin-RevId: 651753437
Use paths.is_normalized and paths.is_absolute from bazel skylib. Upgrade skylib to latest version that has the implementation.

Use copybara for the differences in STRIC_DEPS_FLAG_TEMPLATE.

Implement native_bool_flag to read native flags and use them in proto_library. Those are implemented in such a way, that they can be replaced in place with starlark bool_flag targets.

Implement version check for PackageSpecificationInfo. It's only available after Bazel 6.4.0.

Tests will be submitted in separate PRs.

PiperOrigin-RevId: 653532601
The change is a no-op. Just reduces code duplication.

PiperOrigin-RevId: 654702701
The toolchain type is consumed by proto_library and produced by proto_toolchain rule. As such it's a private dependency, because both rules are now part of protobuf repo.

There are some early adopters of --incompatible_enable_proto_toolchain_resolution that might be broken from this: grpc, rules_go, rules_ts, rules_rust, rules_lint, because they have implementation that is not using proto_common. Those repositories need to define their own proto_lang_toolchain and consume it with proto_common.compile.

PiperOrigin-RevId: 654897871
PiperOrigin-RevId: 660861340
PiperOrigin-RevId: 667891921
PiperOrigin-RevId: 670152183
PiperOrigin-RevId: 671679277
@haberman haberman requested a review from a team as a code owner September 16, 2024 17:53
@haberman haberman requested review from zhangskz and removed request for a team September 16, 2024 17:53
@haberman haberman merged commit 106f4a6 into 28.x Sep 16, 2024
175 checks passed
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.

6 participants