Add support for Zenoh in Bazel builds - #937
Conversation
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
|
Discussed at Gazebo Asia community meeting that this seems to be OK and shouldn't break anything |
| ], | ||
| defines = select({ | ||
| ":zenoh_enabled": [ | ||
| 'GZ_TRANSPORT_DEFAULT_IMPLEMENTATION=\\"zenoh\\"', |
There was a problem hiding this comment.
This makes a Bazel build with enable_zenoh=true default to zenoh at runtime, while a CMake build with zenoh enabled still defaults to zeromq (GZ_TRANSPORT_DEFAULT_IMPLEMENTATION is an independent cache variable there). I'd keep zeromq as the default in both build systems so they behave the same, and run the zenoh CI job with --test_env=GZ_TRANSPORT_IMPLEMENTATION=zenoh instead. Same test coverage, less code.
There was a problem hiding this comment.
I just realized actually, is the purpose of the HAVE_ZENOH just to make gz-transport work regardless of whether zenoh is available or not and, in the future, if Zenoh is widely distributed we can just remove it and compile the support altogether?
If so, I just reverted this change, removed the zenoh_enabled condition altogether in 5a17f7b and did your suggestion of using test_env to set the environment variable, since Zenoh is already available in BCR it will always be built (hardcode HAVE_ZENOH to true in Bazel builds) and users just need to specify the environment variable to choose their transport implementation.
This will cause generally longer build times for gz-transport but at least users don't need to mess with build flags (it can be a bit tricky to keep track of all the build flags needed for every downstream dependency when building large projects).
| bazel_dep(name = "sqlite3", version = "3.53.2") | ||
| bazel_dep(name = "rules_cc", version = "0.1.2") | ||
| bazel_dep(name = "bazel_skylib", version = "1.7.1") | ||
| bazel_dep(name = "zenoh-cpp", version = "1.7.2.bcr.1") |
There was a problem hiding this comment.
How about a small comment to keep all Zenoh min versions in sync:
| bazel_dep(name = "zenoh-cpp", version = "1.7.2.bcr.1") | |
| # Minimum version (bzlmod may resolve higher). Keep in sync with | |
| # GZ_TRANSPORT_ZENOH_MIN_VERSION in CMakeLists.txt (see #868). | |
| bazel_dep(name = "zenoh-cpp", version = "1.7.2.bcr.1") |
| bazel_test_command: "bazel test -c opt --test_output=errors //..." | ||
| bazel_test_command: "bazel test -c opt --//:enable_zenoh=false --test_output=errors //..." | ||
|
|
||
| test-zenoh: |
There was a problem hiding this comment.
Optional: both jobs only differ in the flag value. A strategy.matrix over enable_zenoh would avoid the duplication.
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
🎉 New feature
Summary
As per title, there was no Zenoh support for Bazel builds, also adds a CI job to verify that unit tests pass.
The most important (and potentially controversial) change is that the added dependency to zenoh is to 1.7.2 while the codebase was (I believe) targeting 1.5.0.
I tried this out and it seems to work (also can reference green CI in this PR), I referenced the
rmw_zenohbump PRs where indeed going from 1.5.0 to 1.7.1 (there was no 1.7.2 bump) was very straightforward and involved no code change:By contrast the 1.8.0 bump was a lot trickier, so tricky that it had to be reverted and done twice!
A rough overview of other changes:
enable_zenohbazel flag to the build.enable_zenohactually changes the value of theGZ_TRANSPORT_DEFAULT_IMPLEMENTATIONvariable. This might not be strictly necessary but it's a bit confusing when users build gz-transport withenable_zenoh:=trueand it doesn't actually use Zenoh unless they also set an environment variable.Backport Policy
Test it
In CI, or locally with:
Checklist
codecheckpassed (See contributing)Assisted-by: Gemini
Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-byandGenerated-bymessages.Backports: If this is a backport, please use Rebase and Merge instead.