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

Improve backwards compatibility #255

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ tasks:
EXP_USE_CQUERY: 1 # Don't build incompatible targets
build_targets: *build_targets_bazel_6
test_targets: *test_targets_bazel_6
ubuntu2004_bazel_6_bzlmod:
name: Ubuntu 20.04 (Bazel 6, Bzlmod)
bazel: 6.5.0
platform: ubuntu2004
environment:
EXP_USE_CQUERY: 1 # Don't build incompatible targets
build_flags:
- "--enable_bzlmod"
- "--ignore_dev_dependency"
build_targets: *build_targets_bazel_6
test_targets: *test_targets_bazel_6

ubuntu_rule_based_toolchains:
name: Ubuntu rule-based toolchains
Expand Down
3 changes: 2 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ module(
compatibility_level = 1,
)

bazel_dep(name = "bazel_features", version = "1.18.0")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "protobuf", version = "27.0")
bazel_dep(name = "protobuf", version = "27.0", repo_name = "com_google_protobuf")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going backwards. We'd like to stop calling com_google_protobuf and use Protobuf only. In case of bzlmod, this should be possible. WORKSPACE files might be more problematic. It'd probably be better to just remove Protobuf dependency. It seems that keeping it creates more problems than needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, removing it would be better. Is that possible though?

I don't see much of a downside to using com_google_protobuf here for as long as the module supports WORKSPACE. The name is entirely internal to this module with Bzlmod and quite breaking when changed with WORKSPACE.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing it wouldn't break too many people. There are 2 levels. 1 to remove cc_proto_library. I only found 1 project on GitHub using it. 2 is to also remove cc_proto toolchain_type, without introducing an alias back to Protobuf (which I can't introduce until protobuf 29.0 is released)


cc_configure = use_extension("//cc:extensions.bzl", "cc_configure_extension")
use_repo(cc_configure, "local_config_cc", "local_config_cc_toolchains")
Expand Down
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ http_archive(
)

http_archive(
name = "protobuf",
name = "com_google_protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
strip_prefix = "protobuf-27.0",
url = "https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz",
Expand Down
2 changes: 1 addition & 1 deletion cc/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
"""Starlark rules for building C++ projects."""

load("@protobuf//bazel:cc_proto_library.bzl", _cc_proto_library = "cc_proto_library")
load("@com_google_protobuf//bazel:cc_proto_library.bzl", _cc_proto_library = "cc_proto_library")
load("//cc:cc_binary.bzl", _cc_binary = "cc_binary")
load("//cc:cc_import.bzl", _cc_import = "cc_import")
load("//cc:cc_library.bzl", _cc_library = "cc_library")
Expand Down
5 changes: 4 additions & 1 deletion cc/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
# limitations under the License.
"""Module extension for cc auto configuration."""

load("@bazel_features//:features.bzl", "bazel_features")
load("//cc/private/toolchain:cc_configure.bzl", "cc_autoconf", "cc_autoconf_toolchains")

def _cc_configure_extension_impl(ctx):
cc_autoconf_toolchains(name = "local_config_cc_toolchains")
cc_autoconf(name = "local_config_cc")
return ctx.extension_metadata(reproducible = True)
if bazel_features.external_deps.extension_metadata_has_reproducible:
fmeum marked this conversation as resolved.
Show resolved Hide resolved
return ctx.extension_metadata(reproducible = True)
return None

cc_configure_extension = module_extension(implementation = _cc_configure_extension_impl)