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

Use bzlmod to manage external dependencies #186

Merged
merged 2 commits into from
Feb 1, 2024
Merged

Use bzlmod to manage external dependencies #186

merged 2 commits into from
Feb 1, 2024

Conversation

luangong
Copy link
Contributor

@luangong luangong commented Jan 23, 2024

Bzlmod is the new way to to manage external dependencies. The --enable_bzlmod flag was introduced in Bazel 6 and has been turned on by default since Bazel 7, so declaring external dependencies in WORKSPACE is considered legacy behavior. The old WORKSPACE-system is planned to be disabled in Bazel 8 and to be removed altogether in Bazel 9.

This commit migrates from WORKSPACE to bzlmod.

References:

@luangong luangong changed the title Use Bzlmod Use bzlmod to manage external dependencies Jan 24, 2024
Bzlmod is the new way to to manage external dependencies. The
`--enable_bzlmod` flag was introduced in Bazel 6 and has been turned on
by default since Bazel 7, so declaring external dependencies in
`WORKSPACE` is considered leagcy behavior. The old `WORKSPACE`-system is
planned to be disabled in Bazel 8 and to be removed altogether in Bazel
9.

This commit migrates from `WORKSPACE` to bzlmod.

References:

- https://bazel.build/external/overview
- https://bazel.build/external/migration
- https://blog.bazel.build/2023/12/11/bazel-7-release.html#bzlmod
Copy link
Contributor

@dibenede dibenede left a comment

Choose a reason for hiding this comment

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

Apologies for the delay; I've been trying to dig into our policies on some things.

I have no major objection to accepting this change. However, could you please remove the lock file? While we should add one, it's too large to meaningfully review.

I'm thinking it would be easier for us to just generate it ourselves per https://bazel.build/external/lockfile.

@luangong
Copy link
Contributor Author

luangong commented Feb 1, 2024

The lockfile is already auto-generated. Maybe we should enable --lockfile_mode=error in the CI pipeline?

@dibenede
Copy link
Contributor

dibenede commented Feb 1, 2024

I think it'll be ok for the time being. Thank you the contribution!

@dibenede dibenede merged commit f2c5583 into protocolbuffers:main Feb 1, 2024
4 checks passed
@luangong luangong deleted the bzlmod branch March 12, 2024 12:14
dibenede pushed a commit that referenced this pull request Mar 12, 2024
…194)

* Keep dependency versions in sync for WORKSPACE and MODULE.bazel

As mentioned in the Bazel blog article, the old `WORKSPACE` system is
planned to be disabled by default in Bazel 8, and to be removed
altogether in Bazel 9.  The `WORKSPACE` file will eventually be removed,
but for now, it’s best to keep the dependency versions in both systems
in sync, so that we can build the project with Bzlmod either disabled or
enabled.

Note that there is a compatibility issue that prevents this project from
depending on protobuf v22 and higher.  Until that issue is fixed, v21.7
is the highest version that both systems have.

References:

- https://blog.bazel.build/2023/12/11/bazel-7-release.html#bzlmod
- https://registry.bazel.build/modules/protobuf
- https://github.com/protocolbuffers/protobuf/blob/v21.7/protobuf_deps.bzl#L96-L104
- #186

* Update PROTOC_VERSION to 21.7
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.

2 participants