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

Migrate to bzlmod #950

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7696754
bzlmod
Sayter99 Mar 15, 2024
526e7eb
bzlmod
Sayter99 Mar 15, 2024
81505d1
change module name
Sayter99 Mar 15, 2024
a41c7b2
workspace stuff
Sayter99 Mar 15, 2024
cdd7dbb
nothing in workspace
Sayter99 Mar 15, 2024
7ad2c1b
update doc
Sayter99 Mar 15, 2024
dabc3f6
fix ci
Sayter99 Mar 15, 2024
2bfc76c
include bzlmod changes
Sayter99 Mar 15, 2024
dade7e8
wip
Sayter99 Mar 19, 2024
8a9a563
review feedback
Sayter99 Mar 19, 2024
8f5614c
wip
Sayter99 Mar 19, 2024
662da6a
wip
Sayter99 Mar 19, 2024
3fccdd2
working
Sayter99 Mar 20, 2024
55ef0eb
update docs
Sayter99 Mar 20, 2024
1cbe9c5
fix ci
Sayter99 Mar 20, 2024
b4f0a6e
respect include path
Sayter99 Mar 22, 2024
daa7d14
Merge pull request #1 from Sayter99/workspace-support
Sayter99 Mar 22, 2024
5ae4ef0
try set default
Sayter99 Mar 24, 2024
76544da
use default implicilty
Sayter99 Mar 24, 2024
6c703c1
explicitly set python
Sayter99 Mar 24, 2024
2201e44
set default
Sayter99 Mar 24, 2024
56b46f7
test
Sayter99 Mar 24, 2024
e0f5272
0.31.0
Sayter99 Mar 24, 2024
ba3e0ed
0.31.0
Sayter99 Mar 24, 2024
e05a694
Attempt to add support for nanopb and users with different python ver…
mark64 Mar 26, 2024
27a3086
get rid of warning message
mark64 Mar 26, 2024
0236e88
upgrade CI macos version
Sayter99 Mar 27, 2024
438ecb6
Merge remote-tracking branch 'bzl/master' into bzlmod-testing
mark64 Mar 27, 2024
1bba4e4
remove workspace support
Sayter99 Apr 13, 2024
c1f7ac6
Merge pull request #2 from mark64/bzlmod-testing
Sayter99 Apr 13, 2024
5593871
improve comment
Sayter99 Apr 19, 2024
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
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests/bazel_workspace_support
2 changes: 2 additions & 0 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ jobs:
- name: Build
run: |
bazelisk build //...
cd tests/bazel_workspace_support
bazelisk build //...
10 changes: 9 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,21 @@ proto_library(
deps = ["@com_google_protobuf//:descriptor_proto"],
)

py_proto_library(
name = "descriptor_py_proto",
srcs = [
"generator/proto/google/protobuf/descriptor.proto",
],
include = "generator/proto",
)

py_proto_library(
name = "nanopb_py_proto",
srcs = [
"generator/proto/nanopb.proto",
],
include = "generator/proto",
deps = ["@com_google_protobuf//:protobuf_python"],
deps = [":descriptor_py_proto"],
)

cc_nanopb_proto_library(
Expand Down
32 changes: 32 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module(name = "nanopb", version = "0.4.9")

bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_python", version = "0.24.0")
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")
bazel_dep(name = "protobuf", version = "23.1", repo_name = "com_google_protobuf")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
configure_coverage_tool = True,
python_version = "3.10",
ignore_root_user_error = True,
)

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
use_repo(pip, "nanopb_pypi")
pip.parse(
hub_name = "nanopb_pypi",
requirements_lock = "@nanopb//:extra/requirements_lock.txt",
python_version = "3.10",
)

http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
Copy link
Contributor

Choose a reason for hiding this comment

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

Brief warning: I don't think Bazel will treat http_archive repositories as bzlmod deps. I suspect in this case it's okay because rules_proto_grpc has a working WORKSPACE file, but I can't remember off the top of my head. Just something to keep an eye out for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're right, it is not considered a bazel_dep. I found one release from bcr, switched to use it

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this is still an http archive, did you intend to replace this?

Copy link
Contributor

Choose a reason for hiding this comment

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

If rules_proto_grpc isn't working out-of-the-box with bzlmod, I think the only path to get things working is to manually enumerate the dependencies of rules_proto_grpc, pull it in as a http archive, and hope for the best. The one major drawback is that this instance of rules_proto_grpc becomes unique to nanopb, and any other references to rules_proto_grpc from other dependencies will produce a second source of truth.

I'm not sure if there's a way around this outside of requiring every project that uses nanopb to be hybrid WORKSPACE/blzmod, which isn't a satisfying result. I think you've done the best you can here.

name = "rules_proto_grpc",
sha256 = "c0d718f4d892c524025504e67a5bfe83360b3a982e654bc71fed7514eb8ac8ad",
strip_prefix = "rules_proto_grpc-4.6.0",
urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/archive/4.6.0.tar.gz"],
)

register_toolchains("@rules_proto_grpc//protobuf:protoc_toolchain")
Loading
Loading