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

[6.5.0] Proto toolchainisation cherrypicks #20925

Merged

Commits on Jan 17, 2024

  1. Implement incompatible_enable_proto_toolchain_resolution

    The flag also make proto toolchain related flags a no-op when enabled.
    
    PiperOrigin-RevId: 566186339
    Change-Id: If4ddafa4e8ba4cdf9e7b3d564c5fc72ab764c7ac
    comius committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    b47d436 View commit details
    Browse the repository at this point in the history
  2. Use MockProtoSupport.setup where protos are used

    Update MockProtoSupport.setup to always create rules_proto (setupWorskpace call)
    
    PiperOrigin-RevId: 566643341
    Change-Id: I755044233652597296ddcfd0c8a9ceae2e079efc
    comius committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    2053317 View commit details
    Browse the repository at this point in the history
  3. Remove protoc from proto_lang_toolchain rule

    The protoc should be provided with a new proto_toolchain rule.
    
    Issue: bazelbuild/rules_proto#179
    
    RELNOTES[INC]: proto_compiler attribute removed from proto_lang_toolchain
    (it was recently introduced, and there is no evidence of use)
    
    PiperOrigin-RevId: 566937038
    Change-Id: I7133be4d5cbcc816764c0ba35607329ea50d2406
    comius committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    e95f116 View commit details
    Browse the repository at this point in the history
  4. Use proto_toolchain in proto_library

    Change --incompatible_enable_proto_toolchain_resolution flag to a loading time flag. This is partial revert of bazelbuild@11cf1b7. We need a load time flag, because toolchain type might not exist at current versions of rules repos users use.
    
    When the flag is set, proto_library defines the toolchain and doesn't use an implicit dependency at the same time.
    
    In Bazel the flag may only be flipped after all the rules_* repo are upgraded to define toolchain type and protobuf repository registers the toolchains.
    
    Issue: bazelbuild/rules_proto#179
    PiperOrigin-RevId: 567296665
    Change-Id: Ib3fc27751dd14589fa403f45d2cbbad22537b9a3
    comius committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    d114f24 View commit details
    Browse the repository at this point in the history
  5. Use proto compiler from proto_toolchain rule

    Issue: bazelbuild/rules_proto#179
    PiperOrigin-RevId: 567570286
    Change-Id: Ia7e1ff08a0123a325f1df00f56b81212c01e2588
    comius committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    36394f9 View commit details
    Browse the repository at this point in the history
  6. Refactor proto toolchainsation support utilities

    Implement reusable utils as part of proto_common and move out of semantics. Define toolchains that will be needed for lang_proto_libraries.
    
    Because there are so many toolchains this will make the future code more readable.
    
    Issue: bazelbuild/rules_proto#179
    PiperOrigin-RevId: 570019432
    Change-Id: Ie1675f1d847872bab3a250270eaa451ef4816ed8
    comius committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    0895719 View commit details
    Browse the repository at this point in the history
  7. Decouple java_lite_proto_library from java_proto_library

    Remove call to java_proto_library_impl from java_proto_library.
    
    Remove hasattr from java_proto_library_impl, which handled java_lite_proto_library.
    
    Code reuse in this case made little sense, and it incurrent more maintenance cost than benefit.
    
    Issue: bazelbuild/rules_proto#179
    PiperOrigin-RevId: 570053518
    Change-Id: Ie43cadfd1fc324b6aaad08acaca8eea7df1a3669
    comius committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    8ea74cd View commit details
    Browse the repository at this point in the history
  8. Use proto toolchains in java_proto_library

    Retrieve proto_lang_toolchain using toolchains in java_proto_library when proto toolchain resolution is enabled.
    Add mocks for proto_lang_toolchain from rules_proto.
    Return ToolchainInfo from proto_lang_toolchain rule. That's needed in the resolution. Also returning ProtoLangToolchainInfo directly, to support legacy mechanism.
    
    Issue: bazelbuild/rules_proto#179
    PiperOrigin-RevId: 570055332
    Change-Id: Ieb0510d48778900b8576a71ddb20abfdcda220be
    comius committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    514b3e4 View commit details
    Browse the repository at this point in the history
  9. Use proto toolchains in java_lite_proto_library

    Retrieve proto_lang_toolchain using toolchains in java_lite_proto_library when proto toolchain resolution is enabled.
    
    Issue: bazelbuild/rules_proto#179
    PiperOrigin-RevId: 570056144
    Change-Id: Ia952003017d18baca71d4e0ba75fc3134b972817
    comius committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    9524dac View commit details
    Browse the repository at this point in the history
  10. Use proto toolchains in cc_proto_library

    Retrieve proto_lang_toolchain using toolchains in cc_proto_library when proto toolchain resolution is enabled.
    
    Issue: bazelbuild/rules_proto#179
    PiperOrigin-RevId: 570334276
    Change-Id: If7b7e25254bf3036fdcad67d36474b8fe64a8ffd
    comius committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    f30e59a View commit details
    Browse the repository at this point in the history
  11. Support automatic exec groups in proto_common.compile

    Pass toolchain_type through ProtoLangToolchainInfo into proto_common.compile and use it on ctx.actions.run. Automatic exec groups require that toolchain type is set on the `ctx.actions.run`. This information is used to select correct execution platform.
    
    Expose INCOMPATIBLE_ENABLE_PROTO_TOOLCHAIN_RESOLUTION in proto_common. This will be needed to support lang_proto_libraries that are not part of Bazel. For example py_proto_library. Other methods in `toolchains` struct in proto_common.bzl, are both temporary and can be written in Starlark, so don't expose them. It's possible to access the value in backward compatible manner (that is with `getattr(proto_common, ...)`).
    
    Expose INCOMPATIBLE_PASS_TOOLCHAIN_TYPE in proto_common. Second "flag" is here to mark, that builtin `proto_lang_toolchain` rule has a `toolchain_type` attribute. This way `proto_lang_toolchain` macro can pass the value in a compatible fashion with older Bazel. This should make toolchainisation work with older versions of Bazel that don't know about automatic exec groups and don't need to pass in the value.
    
    Issue: bazelbuild/rules_proto#179
    PiperOrigin-RevId: 571876657
    Change-Id: I543ab862b318c9062d40430160e33ad197973094
    comius committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    29b1f95 View commit details
    Browse the repository at this point in the history