-
Notifications
You must be signed in to change notification settings - Fork 864
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
Bazel build #2225
base: main
Are you sure you want to change the base?
Bazel build #2225
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file shouldn't be here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General comment: have you validated that you're passing the same compiler flags for the dependencies as we do for CMake builds?
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
def abseil_cpp_repository(name = "abseil-cpp"): | ||
version = "20240722.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really should have a mechanism to ensure that this is kept in sync with CMakeFiles...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good idea. Let me add that mechanism.
tools/workspace/cereal/BUILD.bazel
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are several libraries that aren't being pulled in for our CMake builds (cereal, spdlog, libglvnd, ...) -- why are these needed for Bazel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are transitive dependencies:
For instance, SdfLib
depends on cereal
and spdlog
, while libglfw3
depends on libglvnd
.
The goal is to avoid using system-installed libraries and instead fetch them with a fixed SHA to ensure hermeticity.
@@ -0,0 +1,94 @@ | |||
workspace(name = "mujoco") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is using the soon-to-be deprecated WORKSPACE system. It might be worth migrating this to use the new Bzlmod setup. I'll take a look at this if I have some extra time in the upcoming days. No guarantees though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I noticed that some dependencies are already in Bazel Central Registry. Let me know how it goes - I’m happy to explore this as well.
I see that some of my changes to the include paths broke the CMake build system. I'll fix this issue. |
Any idea of why this is failing? I only touched generate_functions.py, generate_functions.py, and generate_structs.py, which shouldn't affect the test. |
Thanks for the comment, and sorry for the delayed response. I've added some default copts to match the options in CMake. I know the CMake system has more options to configure GL backends and precision, but I hope this PR serves as a starting point toward that. |
Summary
This PR introduces a Bazel build system that compiles the C library, Python bindings, and
mjx
library. While the original CMake build system supports multiple architectures and configurations, this Bazel build is currently configured only for Ubuntu 22.04 on x86_64.This setup is not yet fully comprehensive. Some functionalities are still lacking, such as a hermetic toolchain, support for multiple OS and architecture builds, and compatibility with various rendering backends. However, this PR aims to initiate a discussion on the best direction for further improvements.
Testing
Build and test using the default Clang compiler:
Run
bazel build //...
andbazel test //...
.Build and test using the GCC compiler:
Run
bazel build --config=linux_gcc_x86_64 //...
andbazel test --config=linux_gcc_x86_64 //...
.Security
This build process fetches third-party dependencies through Bazel's
http_archive
rule, ensuring each dependency includes its license file.