From 526ae9802b2bb5e8ebdaebb8782f1d0d55540944 Mon Sep 17 00:00:00 2001 From: junhyeokahn Date: Mon, 11 Nov 2024 11:23:12 -0500 Subject: [PATCH 1/7] Bazel Build for v3.2.2 --- .bazelrc | 58 ++ .gitignore | 7 + BUILD.bazel | 174 +++++ WORKSPACE | 94 +++ devtools/bbcp/builddefs/BUILD.bazel | 0 devtools/bbcp/builddefs/build_defs.bzl | 18 + devtools/python/blaze/BUILD.bazel | 0 devtools/python/blaze/pybind.bzl | 55 ++ mjx/mujoco/mjx/BUILD.bazel | 617 ++++++++++++++++++ mjx/mujoco/mjx/test_data/BUILD.bazel | 13 + model/BUILD.bazel | 10 + plugin/actuator/BUILD.bazel | 36 + plugin/elasticity/BUILD.bazel | 118 ++++ plugin/sdf/BUILD.bazel | 155 +++++ plugin/sensor/BUILD.bazel | 27 + python/BUILD.bazel | 13 + python/mujoco/BUILD.bazel | 461 +++++++++++++ python/mujoco/__init__.py | 2 + python/mujoco/cgl/BUILD.bazel | 7 + python/mujoco/codegen/BUILD.bazel | 33 + python/mujoco/egl/BUILD.bazel | 13 + python/mujoco/enums.cc | 4 +- python/mujoco/functions.cc | 2 +- python/mujoco/glfw/BUILD.bazel | 12 + python/mujoco/indexers.h | 2 +- python/mujoco/introspect/BUILD.bazel | 31 + python/mujoco/introspect/codegen/BUILD.bazel | 107 +++ .../introspect/codegen/generate_enums.py | 2 +- .../introspect/codegen/generate_functions.py | 2 +- .../introspect/codegen/generate_structs.py | 2 +- python/mujoco/osmesa/BUILD.bazel | 12 + python/mujoco/render.cc | 2 +- python/mujoco/specs.cc | 2 +- python/mujoco/structs.cc | 2 +- python/mujoco/structs.h | 2 +- python/mujoco/testdata/BUILD.bazel | 10 + python/mujoco/util/BUILD.bazel | 39 ++ python/pip_requirements.in | 12 + python/pip_requirements.txt | 45 ++ sample/BUILD.bazel | 7 + simulate/BUILD.bazel | 67 ++ src/cc/BUILD.bazel | 7 + src/engine/BUILD.bazel | 556 ++++++++++++++++ src/engine/engine_setconst.c | 19 +- src/engine/helper.bzl | 9 + src/render/BUILD.bazel | 103 +++ src/thread/BUILD.bazel | 40 ++ src/ui/BUILD.bazel | 16 + src/user/BUILD.bazel | 166 +++++ src/xml/BUILD.bazel | 186 ++++++ test/BUILD.bazel | 58 ++ test/benchmark/BUILD.bazel | 34 + test/benchmark/testdata/BUILD.bazel | 6 + test/engine/BUILD.bazel | 59 ++ test/engine/testdata/BUILD.bazel | 9 + test/fixture.cc | 8 +- test/helper.bzl | 3 + test/plugin/actuator/BUILD.bazel | 15 + test/plugin/elasticity/BUILD.bazel | 20 + test/plugin/sensor/BUILD.bazel | 13 + test/plugin/sensor/testdata/BUILD.bazel | 6 + test/testdata/BUILD.bazel | 6 + test/thread/BUILD.bazel | 16 + test/user/BUILD.bazel | 40 ++ test/user/testdata/BUILD.bazel | 12 + test/user/user_cache_test.cc | 6 +- test/user/user_util_test.cc | 2 +- test/xml/BUILD.bazel | 37 ++ test/xml/testdata/BUILD.bazel | 6 + tools/BUILD.bazel | 34 + tools/symlink_files.bzl | 36 + tools/workspace/BUILD.bazel | 0 tools/workspace/MarchingCubeCpp/BUILD.bazel | 1 + tools/workspace/MarchingCubeCpp/LICENSE | 21 + .../MarchingCubeCpp/package.BUILD.bazel | 19 + .../workspace/MarchingCubeCpp/repository.bzl | 11 + tools/workspace/SdfLib/BUILD.bazel | 0 tools/workspace/SdfLib/package.BUILD.bazel | 42 ++ tools/workspace/SdfLib/repository.bzl | 11 + tools/workspace/abseil-cpp/BUILD.bazel | 0 tools/workspace/abseil-cpp/repository.bzl | 10 + tools/workspace/aspect_bazel_lib/BUILD.bazel | 0 .../workspace/aspect_bazel_lib/repository.bzl | 10 + tools/workspace/cereal/BUILD.bazel | 0 tools/workspace/cereal/package.BUILD.bazel | 23 + tools/workspace/cereal/repository.bzl | 11 + tools/workspace/deb_archive.bzl | 71 ++ tools/workspace/default_dependencies.bzl | 8 + tools/workspace/default_repositories.bzl | 62 ++ tools/workspace/eigen/BUILD.bazel | 0 tools/workspace/eigen/package.BUILD.bazel | 20 + tools/workspace/eigen/repository.bzl | 11 + tools/workspace/fmt/BUILD.bazel | 0 tools/workspace/fmt/package.BUILD | 35 + tools/workspace/fmt/repository.bzl | 11 + tools/workspace/glm/BUILD.bazel | 0 tools/workspace/glm/package.BUILD.bazel | 29 + tools/workspace/glm/repository.bzl | 11 + tools/workspace/google_benchmark/BUILD.bazel | 0 .../workspace/google_benchmark/repository.bzl | 10 + tools/workspace/googletest/BUILD.bazel | 0 tools/workspace/googletest/repository.bzl | 10 + tools/workspace/libccd/BUILD.bazel | 0 tools/workspace/libccd/package.BUILD.bazel | 57 ++ tools/workspace/libccd/repository.bzl | 11 + tools/workspace/libglfw3/BUILD.bazel | 0 tools/workspace/libglfw3/package.BUILD.bazel | 24 + tools/workspace/libglfw3/repository.bzl | 19 + tools/workspace/libglvnd/BUILD.bazel | 0 tools/workspace/libglvnd/package.BUILD.bazel | 16 + tools/workspace/libglvnd/repository.bzl | 10 + tools/workspace/lodepng/BUILD.bazel | 0 tools/workspace/lodepng/package.BUILD.bazel | 19 + tools/workspace/lodepng/repository.bzl | 11 + tools/workspace/pybind11/BUILD.bazel | 0 tools/workspace/pybind11/package.BUILD.bazel | 15 + tools/workspace/pybind11/repository.bzl | 11 + tools/workspace/qhull/BUILD.bazel | 0 tools/workspace/qhull/package.BUILD.bazel | 93 +++ tools/workspace/qhull/repository.bzl | 11 + tools/workspace/rules_python/BUILD.bazel | 0 tools/workspace/rules_python/repository.bzl | 10 + tools/workspace/spdlog/BUILD.bazel | 0 tools/workspace/spdlog/package.BUILD.bazel | 32 + tools/workspace/spdlog/repository.bzl | 11 + tools/workspace/tinyobjloader/BUILD.bazel | 0 .../tinyobjloader/package.BUILD.bazel | 14 + tools/workspace/tinyobjloader/repository.bzl | 11 + tools/workspace/tinyxml2/BUILD.bazel | 0 tools/workspace/tinyxml2/package.BUILD.bazel | 15 + tools/workspace/tinyxml2/repository.bzl | 11 + 131 files changed, 4618 insertions(+), 23 deletions(-) create mode 100644 .bazelrc create mode 100644 BUILD.bazel create mode 100644 WORKSPACE create mode 100644 devtools/bbcp/builddefs/BUILD.bazel create mode 100644 devtools/bbcp/builddefs/build_defs.bzl create mode 100644 devtools/python/blaze/BUILD.bazel create mode 100644 devtools/python/blaze/pybind.bzl create mode 100644 mjx/mujoco/mjx/BUILD.bazel create mode 100644 mjx/mujoco/mjx/test_data/BUILD.bazel create mode 100644 model/BUILD.bazel create mode 100644 plugin/actuator/BUILD.bazel create mode 100644 plugin/elasticity/BUILD.bazel create mode 100644 plugin/sdf/BUILD.bazel create mode 100644 plugin/sensor/BUILD.bazel create mode 100644 python/BUILD.bazel create mode 100644 python/mujoco/BUILD.bazel create mode 100644 python/mujoco/cgl/BUILD.bazel create mode 100644 python/mujoco/codegen/BUILD.bazel create mode 100644 python/mujoco/egl/BUILD.bazel create mode 100644 python/mujoco/glfw/BUILD.bazel create mode 100644 python/mujoco/introspect/BUILD.bazel create mode 100644 python/mujoco/introspect/codegen/BUILD.bazel create mode 100644 python/mujoco/osmesa/BUILD.bazel create mode 100644 python/mujoco/testdata/BUILD.bazel create mode 100644 python/mujoco/util/BUILD.bazel create mode 100644 python/pip_requirements.in create mode 100644 python/pip_requirements.txt create mode 100644 sample/BUILD.bazel create mode 100644 simulate/BUILD.bazel create mode 100644 src/cc/BUILD.bazel create mode 100644 src/engine/BUILD.bazel create mode 100644 src/engine/helper.bzl create mode 100644 src/render/BUILD.bazel create mode 100644 src/thread/BUILD.bazel create mode 100644 src/ui/BUILD.bazel create mode 100644 src/user/BUILD.bazel create mode 100644 src/xml/BUILD.bazel create mode 100644 test/BUILD.bazel create mode 100644 test/benchmark/BUILD.bazel create mode 100644 test/benchmark/testdata/BUILD.bazel create mode 100644 test/engine/BUILD.bazel create mode 100644 test/engine/testdata/BUILD.bazel create mode 100644 test/helper.bzl create mode 100644 test/plugin/actuator/BUILD.bazel create mode 100644 test/plugin/elasticity/BUILD.bazel create mode 100644 test/plugin/sensor/BUILD.bazel create mode 100644 test/plugin/sensor/testdata/BUILD.bazel create mode 100644 test/testdata/BUILD.bazel create mode 100644 test/thread/BUILD.bazel create mode 100644 test/user/BUILD.bazel create mode 100644 test/user/testdata/BUILD.bazel create mode 100644 test/xml/BUILD.bazel create mode 100644 test/xml/testdata/BUILD.bazel create mode 100644 tools/BUILD.bazel create mode 100644 tools/symlink_files.bzl create mode 100644 tools/workspace/BUILD.bazel create mode 100644 tools/workspace/MarchingCubeCpp/BUILD.bazel create mode 100644 tools/workspace/MarchingCubeCpp/LICENSE create mode 100644 tools/workspace/MarchingCubeCpp/package.BUILD.bazel create mode 100644 tools/workspace/MarchingCubeCpp/repository.bzl create mode 100644 tools/workspace/SdfLib/BUILD.bazel create mode 100644 tools/workspace/SdfLib/package.BUILD.bazel create mode 100644 tools/workspace/SdfLib/repository.bzl create mode 100644 tools/workspace/abseil-cpp/BUILD.bazel create mode 100644 tools/workspace/abseil-cpp/repository.bzl create mode 100644 tools/workspace/aspect_bazel_lib/BUILD.bazel create mode 100644 tools/workspace/aspect_bazel_lib/repository.bzl create mode 100644 tools/workspace/cereal/BUILD.bazel create mode 100644 tools/workspace/cereal/package.BUILD.bazel create mode 100644 tools/workspace/cereal/repository.bzl create mode 100644 tools/workspace/deb_archive.bzl create mode 100644 tools/workspace/default_dependencies.bzl create mode 100644 tools/workspace/default_repositories.bzl create mode 100644 tools/workspace/eigen/BUILD.bazel create mode 100644 tools/workspace/eigen/package.BUILD.bazel create mode 100644 tools/workspace/eigen/repository.bzl create mode 100644 tools/workspace/fmt/BUILD.bazel create mode 100644 tools/workspace/fmt/package.BUILD create mode 100644 tools/workspace/fmt/repository.bzl create mode 100644 tools/workspace/glm/BUILD.bazel create mode 100644 tools/workspace/glm/package.BUILD.bazel create mode 100644 tools/workspace/glm/repository.bzl create mode 100644 tools/workspace/google_benchmark/BUILD.bazel create mode 100644 tools/workspace/google_benchmark/repository.bzl create mode 100644 tools/workspace/googletest/BUILD.bazel create mode 100644 tools/workspace/googletest/repository.bzl create mode 100644 tools/workspace/libccd/BUILD.bazel create mode 100644 tools/workspace/libccd/package.BUILD.bazel create mode 100644 tools/workspace/libccd/repository.bzl create mode 100644 tools/workspace/libglfw3/BUILD.bazel create mode 100644 tools/workspace/libglfw3/package.BUILD.bazel create mode 100644 tools/workspace/libglfw3/repository.bzl create mode 100644 tools/workspace/libglvnd/BUILD.bazel create mode 100644 tools/workspace/libglvnd/package.BUILD.bazel create mode 100644 tools/workspace/libglvnd/repository.bzl create mode 100644 tools/workspace/lodepng/BUILD.bazel create mode 100644 tools/workspace/lodepng/package.BUILD.bazel create mode 100644 tools/workspace/lodepng/repository.bzl create mode 100644 tools/workspace/pybind11/BUILD.bazel create mode 100644 tools/workspace/pybind11/package.BUILD.bazel create mode 100644 tools/workspace/pybind11/repository.bzl create mode 100644 tools/workspace/qhull/BUILD.bazel create mode 100644 tools/workspace/qhull/package.BUILD.bazel create mode 100644 tools/workspace/qhull/repository.bzl create mode 100644 tools/workspace/rules_python/BUILD.bazel create mode 100644 tools/workspace/rules_python/repository.bzl create mode 100644 tools/workspace/spdlog/BUILD.bazel create mode 100644 tools/workspace/spdlog/package.BUILD.bazel create mode 100644 tools/workspace/spdlog/repository.bzl create mode 100644 tools/workspace/tinyobjloader/BUILD.bazel create mode 100644 tools/workspace/tinyobjloader/package.BUILD.bazel create mode 100644 tools/workspace/tinyobjloader/repository.bzl create mode 100644 tools/workspace/tinyxml2/BUILD.bazel create mode 100644 tools/workspace/tinyxml2/package.BUILD.bazel create mode 100644 tools/workspace/tinyxml2/repository.bzl diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 0000000000..c53f4e8d29 --- /dev/null +++ b/.bazelrc @@ -0,0 +1,58 @@ +# don't use bzlmod yet. +common --enable_workspace=true +common --enable_bzlmod=false + +# use c++20 by default +build --cxxopt=-std=c++20 + +# remove this when https://github.com/abseil/abseil-cpp/issues/740 is resolved +build --copt=-Iexternal/abseil-cpp + +# Due to the repetitive directory names (e.g., `mujoco/mjx/mujoco/mjx`), `__init__.py` should not +# be automatically created. Otherwise, importing with `import mujoco.mjx` will reference +# `mujoco/mjx` instead of `mujoco/mjx/mujoco/mjx`. +build --incompatible_default_to_explicit_init_py + +# Compiler configuration. +# Note that the current configuration relies on system-installed toolchains, which may cause +# non-hermetic behavior in builds. This could be improved by defining a `cc_toolchain` with +# self-contained toolchains. +# See https://docs.bazel.build/versions/1.2.0/tutorial/cc-toolchain-config.html#configuring-the-c-toolchain + +# clang by default +build --platforms=@mujoco//tools:linux_clang_x86_64 +build --action_env=CC=clang + +# gcc +build:linux_gcc_x86_64 --platforms=@mujoco//tools:linux_gcc_x86_64 +build:linux_gcc_x86_64 --action_env=CC=gcc + +# ASan Build +build:asan --build_tests_only +build:asan --features=asan +# This flag effectively tells Bazel to avoid using certain hardware-dependent features that may +# cause ASan or TSan to fail unexpectedly or produce inaccurate results. +build:asan --incompatible_use_host_features + +# LSan is run with ASan by default +build:asan --test_tag_filters=-no_asan,-no_lsan +build:asan --test_lang_filters=-sh +# Typical slowdown introduced by AddressSanitizer is 2x. +# See https://clang.llvm.org/docs/AddressSanitizer.html +build:asan --test_timeout=150,750,2250,9000 + +# TSan Build +build:tsan --build_tests_only +build:tsan --features=tsan +# This flag effectively tells Bazel to avoid using certain hardware-dependent features that may +# cause ASan or TSan to fail unexpectedly or produce inaccurate results. +build:tsan --incompatible_use_host_features + +# We assume anything that didn't want asan doesn't want tsan +build:tsan --test_tag_filters=-no_asan,-no_tsan +build:tsan --test_lang_filters=-sh +# Typical slowdown introduced by ThreadSanitizer is about 5x-15x +# See https://clang.llvm.org/docs/ThreadSanitizer.html +build:tsan --test_timeout=150,750,2250,9000 + +try-import %workspace%/user.bazelrc diff --git a/.gitignore b/.gitignore index ba97a7c9b2..c0b6d9f82d 100644 --- a/.gitignore +++ b/.gitignore @@ -32,8 +32,15 @@ __pycache__/ *.py[cod] *$py.class +<<<<<<< HEAD # MuJoCo's default log file MUJOCO_LOG.TXT # Clang cache .cache/ +======= +# Bazel build artifacts (symlinks) +/bazel-* + +.cache +>>>>>>> 3dabc6bf (Bazel Build for v3.2.2) diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 0000000000..dd2a680bb5 --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,174 @@ +load("@mujoco//tools:symlink_files.bzl", "symlink_files") +load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier") + +package(default_visibility = ["@mujoco//:__subpackages__"]) + +filegroup( + name = "license_filegroup", + srcs = [ + "LICENSE", + ], + tags = ["license_filegroup"], +) + +cc_library( + name = "mujoco_hdrs", + hdrs = [":mujoco_headers"], + includes = [ + "include", + ], + target_compatible_with = ["@platforms//os:linux"], + visibility = ["//visibility:public"], +) + +cc_library( + name = "_core", + linkopts = ["-Wl,--gc-sections"], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + "//src/engine", + "//src/thread:thread_pool", + "//src/xml:xml_api", + ], +) + +cc_library( + name = "_graphics_native", + linkopts = ["-Wl,--gc-sections"], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + "//src/render", + "//src/ui:ui_main", + ], +) + +# The headers are needed to generate ctypes Python bindings. +filegroup( + name = "mujoco_headers", + srcs = [ + "include/mujoco/mjdata.h", + "include/mujoco/mjexport.h", + "include/mujoco/mjmacro.h", + "include/mujoco/mjmodel.h", + "include/mujoco/mjplugin.h", + "include/mujoco/mjrender.h", + "include/mujoco/mjspec.h", + "include/mujoco/mjthread.h", + "include/mujoco/mjtnum.h", + "include/mujoco/mjui.h", + "include/mujoco/mjvisualize.h", + "include/mujoco/mjxmacro.h", + "include/mujoco/mujoco.h", + ], +) + +cc_library( + name = "mujoco", + hdrs = [":mujoco_headers"], + data = [ + ":license_filegroup", + ], + includes = [ + "include", + ], + target_compatible_with = ["@platforms//os:linux"], + visibility = ["//visibility:public"], + deps = [ + ":_core", + ":_graphics_native", + ], +) + +cc_shared_library( + name = "mujoco_shared", + shared_lib_name = "libmujoco.so.3.2.2", + target_compatible_with = ["@platforms//os:linux"], + visibility = ["//visibility:public"], + deps = [ + ":mujoco", + ], +) + +alias( + name = "simulate", + actual = "//simulate:main", + visibility = ["//visibility:public"], +) + +alias( + name = "mujoco-py", + actual = "//python/mujoco:mujoco-py", + target_compatible_with = ["@platforms//os:linux"], + visibility = ["//visibility:public"], +) + +alias( + name = "mujoco-mjx", + actual = "//mjx/mujoco/mjx:mjx", + target_compatible_with = ["@platforms//os:linux"], + visibility = ["//visibility:public"], +) + +# Symlink data for the test. Note that Bazel tests look for data in the `TEST.runfiles/mujoco` +# directory, so we create proper symlinks for the files instead of altering paths within the test. +symlink_files( + name = "model_data", + srcs = ["//model"], +) + +# The reason we have `test_data` and `test_data_stripped` is that some tests (e.g., `spec_test.py`) +# reads `test/testdata/model.xml` while `pipeline_test.cc` reads `testdata/model.xml`. +symlink_files( + name = "test_data", + srcs = ["//test/testdata:model"], +) + +symlink_files( + name = "test_data_stripped", + srcs = ["//test/testdata:model"], + strip_prefix = "test/", +) + +symlink_files( + name = "test_engine_data", + srcs = ["//test/engine/testdata:model"], +) + +symlink_files( + name = "test_engine_data_stripped", + srcs = ["//test/engine/testdata:model"], + strip_prefix = "test/", +) + +symlink_files( + name = "test_plugin_data", + srcs = ["//test/plugin/sensor/testdata:model"], + strip_prefix = "test/", +) + +symlink_files( + name = "test_user_data", + srcs = ["//test/user/testdata:model"], + strip_prefix = "test/", +) + +symlink_files( + name = "test_xml_data", + srcs = ["//test/xml/testdata:model"], + strip_prefix = "test/", +) + +symlink_files( + name = "test_benchmark_data", + srcs = ["//test/benchmark/testdata:model"], +) + +symlink_files( + name = "test_benchmark_data_stripped", + srcs = ["//test/benchmark/testdata:model"], + strip_prefix = "test/", +) + +buildifier( + name = "buildifier", +) diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000000..a953adbae3 --- /dev/null +++ b/WORKSPACE @@ -0,0 +1,94 @@ +workspace(name = "mujoco") + +""" +Download dependencies. Note that the functions below could potentially be called from a larger +Bazel project that fetches MuJoCo. +""" + +load("@mujoco//tools/workspace:default_repositories.bzl", "add_default_repositories") + +add_default_repositories() + +load("@mujoco//tools/workspace:default_dependencies.bzl", "add_default_dependencies") + +add_default_dependencies() + +""" +Configure a Python toolchain and Buildifier (a formatting tool for BUILD.bazel files). Note that the functions below are in a local scope and won’t be called from a larger Bazel project that fetches MuJoCo. +""" + +# Python +load("@rules_python//python:repositories.bzl", "python_register_toolchains") + +python_register_toolchains( + name = "python_3_11", + python_version = "3.11", +) + +load("@rules_python//python:pip.bzl", "pip_parse") +load("@python_3_11//:defs.bzl", "interpreter") + +pip_parse( + name = "pip_deps", + python_interpreter_target = interpreter, + requirements_lock = "@mujoco//python:pip_requirements.txt", +) + +load("@pip_deps//:requirements.bzl", install_pip_deps = "install_deps") + +install_pip_deps() + +# Buildifier to format BUILD.bazel files +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "io_bazel_rules_go", + sha256 = "6dc2da7ab4cf5d7bfc7c949776b1b7c733f05e56edc4bcd9022bb249d2e2a996", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip", + "https://github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip", + ], +) + +load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies") + +go_rules_dependencies() + +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains") + +go_register_toolchains(version = "1.20.3") + +http_archive( + name = "bazel_gazelle", + sha256 = "727f3e4edd96ea20c29e8c2ca9e8d2af724d8c7778e7923a854b2c80952bc405", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz", + ], +) + +load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") + +gazelle_dependencies() + +http_archive( + name = "com_google_protobuf", + sha256 = "3bd7828aa5af4b13b99c191e8b1e884ebfa9ad371b0ce264605d347f135d2568", + strip_prefix = "protobuf-3.19.4", + urls = [ + "https://github.com/protocolbuffers/protobuf/archive/v3.19.4.tar.gz", + ], +) + +load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") + +protobuf_deps() + +http_archive( + name = "com_github_bazelbuild_buildtools", + sha256 = "ae34c344514e08c23e90da0e2d6cb700fcd28e80c02e23e4d5715dddcb42f7b3", + strip_prefix = "buildtools-4.2.2", + urls = [ + "https://github.com/bazelbuild/buildtools/archive/refs/tags/4.2.2.tar.gz", + ], +) diff --git a/devtools/bbcp/builddefs/BUILD.bazel b/devtools/bbcp/builddefs/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/devtools/bbcp/builddefs/build_defs.bzl b/devtools/bbcp/builddefs/build_defs.bzl new file mode 100644 index 0000000000..450e03e137 --- /dev/null +++ b/devtools/bbcp/builddefs/build_defs.bzl @@ -0,0 +1,18 @@ +#Copied from https://github.com/taylor-bsg/xls/blob/7afd772753d95078cdd513566de438d8fcc2cfbd/xls/build_rules/xls_oss_config_rules.bzl#L25 + +def generated_file( + name = None, + wrapped_target = None, + tags = None, + testonly = None): + """The function is a placeholder for generated_file. + + The function is intended to be empty. + + Args: + name: Optional name of the marker rule created by this macro. + wrapped_target: The target to wrap. + tags: A list of tags to set on the artifacts. + testonly: Optional standard testonly attribute. + """ + pass diff --git a/devtools/python/blaze/BUILD.bazel b/devtools/python/blaze/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/devtools/python/blaze/pybind.bzl b/devtools/python/blaze/pybind.bzl new file mode 100644 index 0000000000..dba44162bf --- /dev/null +++ b/devtools/python/blaze/pybind.bzl @@ -0,0 +1,55 @@ +# Copied from https://github.com/pybind/pybind11_bazel/blob/v2.11.1.bzl.1/build_defs.bzl and +# modified. + +PYBIND_COPTS = ["-fexceptions"] + +PYBIND_FEATURES = [ + "-use_header_modules", # Required for pybind11. + "-parse_headers", +] + +PYBIND_DEPS = [ + "@pybind11", +] + +def pybind_extension( + name, + copts = [], + features = [], + linkopts = [], + tags = [], + deps = [], + **kwargs): + # Mark common dependencies as required for build_cleaner. + tags = tags + ["req_dep=%s" % dep for dep in PYBIND_DEPS] + + native.cc_binary( + name = name + ".so", + copts = copts + PYBIND_COPTS + ["-fvisibility=hidden"], + features = features + PYBIND_FEATURES, + linkopts = linkopts, + linkshared = 1, + tags = tags, + deps = deps + PYBIND_DEPS, + **kwargs + ) + +# Builds a pybind11 compatible library. This can be linked to a pybind_extension. +def pybind_library( + name, + copts = [], + features = [], + tags = [], + deps = [], + **kwargs): + # Mark common dependencies as required for build_cleaner. + tags = tags + ["req_dep=%s" % dep for dep in PYBIND_DEPS] + + native.cc_library( + name = name, + copts = copts + PYBIND_COPTS, + features = features + PYBIND_FEATURES, + tags = tags, + deps = deps + PYBIND_DEPS, + **kwargs + ) diff --git a/mjx/mujoco/mjx/BUILD.bazel b/mjx/mujoco/mjx/BUILD.bazel new file mode 100644 index 0000000000..62195f6b9a --- /dev/null +++ b/mjx/mujoco/mjx/BUILD.bazel @@ -0,0 +1,617 @@ +load("@pip_deps//:requirements.bzl", "requirement") + +package(default_visibility = ["@mujoco//:__subpackages__"]) + +py_library( + name = "collision_convex", + srcs = [ + "_src/collision_convex.py", + ], + imports = ["../.."], + deps = [ + ":collision_types", + ":math", + ":mesh", + ":types", + requirement("jax"), + ], +) + +py_library( + name = "collision_driver", + srcs = [ + "_src/collision_driver.py", + ], + imports = ["../.."], + deps = [ + ":collision_convex", + ":collision_primitive", + ":collision_sdf", + ":collision_types", + ":support", + ":types", + "//:mujoco-py", + requirement("jax"), + requirement("numpy"), + ], +) + +py_library( + name = "collision_sdf", + srcs = [ + "_src/collision_sdf.py", + ], + imports = ["../.."], + deps = [ + ":collision_types", + ":dataclasses", + ":math", + ":types", + requirement("jax"), + ], +) + +py_library( + name = "collision_primitive", + srcs = [ + "_src/collision_primitive.py", + ], + imports = ["../.."], + deps = [ + ":collision_types", + ":math", + ":types", + requirement("jax"), + ], +) + +py_library( + name = "collision_types", + srcs = [ + "_src/collision_types.py", + ], + imports = ["../.."], + deps = [ + ":dataclasses", + "//:mujoco-py", + requirement("jax"), + requirement("numpy"), + ], +) + +py_library( + name = "constraint", + srcs = [ + "_src/constraint.py", + ], + imports = ["../.."], + deps = [ + ":collision_driver", + ":dataclasses", + ":math", + ":support", + ":types", + "//:mujoco-py", + requirement("jax"), + requirement("numpy"), + ], +) + +py_library( + name = "dataclasses", + srcs = [ + "_src/dataclasses.py", + ], + imports = ["../.."], + deps = [ + requirement("jax"), + requirement("numpy"), + ], +) + +py_library( + name = "forward", + srcs = [ + "_src/forward.py", + ], + imports = ["../.."], + deps = [ + ":collision_driver", + ":constraint", + ":math", + ":passive", + ":scan", + ":smooth", + ":solver", + ":support", + ":types", + "//:mujoco-py", + requirement("jax"), + requirement("numpy"), + ], +) + +py_library( + name = "io", + srcs = [ + "_src/io.py", + ], + imports = ["../.."], + deps = [ + ":collision_driver", + ":constraint", + ":mesh", + ":support", + ":types", + "//:mujoco-py", + requirement("jax"), + requirement("numpy"), + requirement("scipy"), + ], +) + +py_library( + name = "math", + srcs = [ + "_src/math.py", + ], + imports = ["../.."], + deps = [ + requirement("jax"), + ], +) + +py_library( + name = "mesh", + srcs = [ + "_src/mesh.py", + ], + imports = ["../.."], + deps = [ + ":collision_types", + ":math", + ":types", + "//:mujoco-py", + requirement("jax"), + requirement("numpy"), + requirement("scipy"), + requirement("trimesh"), + ], +) + +py_library( + name = "passive", + srcs = [ + "_src/passive.py", + ], + imports = ["../.."], + deps = [ + ":math", + ":scan", + ":support", + ":types", + requirement("jax"), + ], +) + +py_library( + name = "ray", + srcs = [ + "_src/ray.py", + ], + imports = ["../.."], + deps = [ + ":math", + ":types", + "//:mujoco-py", + requirement("jax"), + requirement("numpy"), + ], +) + +py_library( + name = "scan", + srcs = [ + "_src/scan.py", + ], + imports = ["../.."], + deps = [ + ":types", + requirement("jax"), + requirement("numpy"), + ], +) + +py_library( + name = "smooth", + srcs = [ + "_src/smooth.py", + ], + imports = ["../.."], + deps = [ + ":math", + ":scan", + ":support", + ":types", + "//:mujoco-py", + requirement("jax"), + requirement("numpy"), + ], +) + +py_library( + name = "solver", + srcs = [ + "_src/solver.py", + ], + imports = ["../.."], + deps = [ + ":dataclasses", + ":math", + ":smooth", + ":support", + ":types", + "//:mujoco-py", + requirement("jax"), + ], +) + +py_library( + name = "support", + srcs = [ + "_src/support.py", + ], + imports = ["../.."], + deps = [ + ":math", + ":scan", + ":types", + "//:mujoco-py", + requirement("jax"), + requirement("numpy"), + ], +) + +py_library( + name = "types", + srcs = [ + "_src/types.py", + ], + imports = ["../.."], + deps = [ + ":dataclasses", + "//:mujoco-py", + requirement("jax"), + requirement("numpy"), + ], +) + +py_library( + name = "mjx", + srcs = [ + "__init__.py", + ], + data = [ + "//:license_filegroup", + ], + imports = ["../.."], + visibility = ["//visibility:public"], + deps = [ + ":collision_driver", + ":constraint", + ":forward", + ":io", + ":passive", + ":ray", + ":smooth", + ":solver", + ":support", + ":test_util", + ":types", + ], +) + +py_library( + name = "test_util", + srcs = [ + "_src/test_util.py", + ], + deps = [ + ":forward", + ":io", + ":types", + "//:mujoco-py", + requirement("etils"), + requirement("jax"), + requirement("numpy"), + ], +) + +py_test( + name = "collision_driver_test", + size = "medium", + srcs = [ + "_src/collision_driver_test.py", + ], + data = [ + "//mjx/mujoco/mjx/test_data:model", + ], + deps = [ + ":collision_driver", + ":mjx", + ":test_util", + ":types", + "//:mujoco-py", + requirement("absl-py"), + requirement("etils"), + requirement("jax"), + requirement("numpy"), + requirement("typing_extensions"), + requirement("importlib_resources"), + ], +) + +py_test( + name = "constraint_test", + size = "small", + srcs = [ + "_src/constraint_test.py", + ], + data = [ + "//mjx/mujoco/mjx/test_data:model", + ], + shard_count = 5, + deps = [ + ":constraint", + ":mjx", + ":test_util", + requirement("absl-py"), + requirement("jax"), + requirement("numpy"), + requirement("typing_extensions"), + requirement("importlib_resources"), + ], +) + +py_test( + name = "io_test", + size = "small", + srcs = [ + "_src/io_test.py", + ], + data = [ + "//mjx/mujoco/mjx/test_data:model", + ], + shard_count = 5, + deps = [ + ":mjx", + requirement("absl-py"), + requirement("jax"), + requirement("numpy"), + requirement("typing_extensions"), + requirement("importlib_resources"), + ], +) + +py_test( + name = "forward_test", + size = "small", + srcs = [ + "_src/forward_test.py", + ], + data = [ + "//mjx/mujoco/mjx/test_data:model", + ], + shard_count = 4, + deps = [ + ":mjx", + ":test_util", + requirement("absl-py"), + requirement("jax"), + requirement("numpy"), + requirement("typing_extensions"), + requirement("importlib_resources"), + ], +) + +py_test( + name = "math_test", + size = "small", + srcs = [ + "_src/math_test.py", + ], + shard_count = 20, + deps = [ + ":math", + requirement("absl-py"), + requirement("jax"), + requirement("numpy"), + requirement("typing_extensions"), + requirement("importlib_resources"), + ], +) + +py_test( + name = "mesh_test", + size = "small", + srcs = [ + "_src/mesh_test.py", + ], + deps = [ + ":mesh", + requirement("absl-py"), + requirement("numpy"), + requirement("trimesh"), + ], +) + +py_test( + name = "passive_test", + size = "small", + srcs = [ + "_src/passive_test.py", + ], + data = [ + "//mjx/mujoco/mjx/test_data:model", + ], + deps = [ + ":mjx", + ":test_util", + "//:mujoco-py", + requirement("absl-py"), + requirement("jax"), + requirement("numpy"), + requirement("typing_extensions"), + requirement("importlib_resources"), + ], +) + +py_test( + name = "ray_test", + size = "small", + srcs = [ + "_src/ray_test.py", + ], + data = [ + "//mjx/mujoco/mjx/test_data:model", + ], + deps = [ + ":mjx", + ":test_util", + "//:mujoco-py", + requirement("absl-py"), + requirement("jax"), + requirement("numpy"), + requirement("typing_extensions"), + requirement("importlib_resources"), + ], +) + +py_test( + name = "scan_test", + size = "small", + srcs = [ + "_src/scan_test.py", + ], + deps = [ + ":mjx", + ":scan", + ":types", + "//:mujoco-py", + requirement("absl-py"), + requirement("jax"), + requirement("numpy"), + requirement("typing_extensions"), + requirement("importlib_resources"), + ], +) + +py_test( + name = "smooth_test", + size = "small", + srcs = [ + "_src/smooth_test.py", + ], + data = [ + "//mjx/mujoco/mjx/test_data:model", + ], + shard_count = 3, + deps = [ + ":mjx", + ":test_util", + "//:mujoco-py", + requirement("absl-py"), + requirement("jax"), + requirement("numpy"), + requirement("typing_extensions"), + requirement("importlib_resources"), + ], +) + +py_test( + name = "solver_test", + size = "small", + srcs = [ + "_src/solver_test.py", + ], + data = [ + "//mjx/mujoco/mjx/test_data:model", + ], + deps = [ + ":mjx", + ":solver", + ":test_util", + "//:mujoco-py", + requirement("absl-py"), + requirement("jax"), + requirement("numpy"), + requirement("typing_extensions"), + requirement("importlib_resources"), + ], +) + +py_test( + name = "support_test", + size = "small", + srcs = [ + "_src/support_test.py", + ], + data = [ + "//mjx/mujoco/mjx/test_data:model", + ], + deps = [ + ":mjx", + ":support", + ":test_util", + "//:mujoco-py", + requirement("absl-py"), + requirement("jax"), + requirement("numpy"), + requirement("typing_extensions"), + requirement("importlib_resources"), + ], +) + +BENCHMARKS = ( + ("barkour", "barkour_v0/assets/barkour_v0_mjx.xml", "4", "cg", "4", "6"), + ("barkour", "barkour_v0/assets/barkour_v0_mjx.xml", "4", "newton", "1", "4"), +) + +[py_test( + name = "testspeed_%s_%s" % (model, solver), + size = "large", + srcs = [ + "testspeed.py", + ], + args = [ + "--mjcf=%s" % mjcf, + "--nstep=4", + "--batch_size=2", + "--unroll=%s" % unroll, + "--solver=%s" % solver, + "--iterations=%s" % iterations, + "--ls_iterations=%s" % ls_iterations, + "--output=tsv", + ], + data = [ + "//mjx/mujoco/mjx/test_data:model", + ], + main = "testspeed.py", + tags = ["manual"], + deps = [ + ":mjx", + "//:mujoco-py", + requirement("absl-py"), + requirement("jax"), + requirement("numpy"), + requirement("typing_extensions"), + requirement("importlib_resources"), + requirement("etils"), + ], +) for model, mjcf, unroll, solver, iterations, ls_iterations in BENCHMARKS] + +test_suite( + name = "benchmark_tests", + tags = ["manual"], + tests = ["testspeed_%s_%s" % (model, solver) for model, mjcf, unroll, solver, iterations, ls_iterations in BENCHMARKS], +) diff --git a/mjx/mujoco/mjx/test_data/BUILD.bazel b/mjx/mujoco/mjx/test_data/BUILD.bazel new file mode 100644 index 0000000000..04e22ff7d0 --- /dev/null +++ b/mjx/mujoco/mjx/test_data/BUILD.bazel @@ -0,0 +1,13 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +filegroup( + name = "model", + srcs = glob([ + "**/*.xml", + "**/*.msh", + "**/*.usda", + "**/*.stl", + "**/*.obj", + "**/*.png", + ]), +) diff --git a/model/BUILD.bazel b/model/BUILD.bazel new file mode 100644 index 0000000000..a36e17f143 --- /dev/null +++ b/model/BUILD.bazel @@ -0,0 +1,10 @@ +package(default_visibility = ["//visibility:public"]) + +filegroup( + name = "model", + srcs = glob([ + "**/*.xml", + "**/*.png", + "**/*.obj", + ]), +) diff --git a/plugin/actuator/BUILD.bazel b/plugin/actuator/BUILD.bazel new file mode 100644 index 0000000000..f310388b1e --- /dev/null +++ b/plugin/actuator/BUILD.bazel @@ -0,0 +1,36 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +cc_library( + name = "pid", + srcs = ["pid.cc"], + hdrs = ["pid.h"], + copts = [ + "-Wno-sign-compare", + ], + deps = [ + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "register", + srcs = [ + "register.cc", + ], + deps = [ + ":pid", + "//:mujoco_hdrs", + ], + alwayslink = True, +) + +cc_shared_library( + name = "actuator", + dynamic_deps = [ + "//:mujoco_shared", + ], + visibility = ["//visibility:public"], + deps = [ + "register", + ], +) diff --git a/plugin/elasticity/BUILD.bazel b/plugin/elasticity/BUILD.bazel new file mode 100644 index 0000000000..c057e67682 --- /dev/null +++ b/plugin/elasticity/BUILD.bazel @@ -0,0 +1,118 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +cc_library( + name = "elasticity_impl", + srcs = [ + "elasticity.cc", + ], + hdrs = [ + "elasticity.h", + ], + copts = [ + "-Wno-sign-compare", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "cable", + srcs = [ + "cable.cc", + ], + hdrs = [ + "cable.h", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":elasticity_impl", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "solid", + srcs = [ + "solid.cc", + ], + hdrs = [ + "solid.h", + ], + copts = [ + "-Wno-sign-compare", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":elasticity_impl", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "shell", + srcs = [ + "shell.cc", + ], + hdrs = [ + "shell.h", + ], + copts = [ + "-Wno-sign-compare", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":elasticity_impl", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "membrane", + srcs = [ + "membrane.cc", + ], + hdrs = [ + "membrane.h", + ], + copts = [ + "-Wno-sign-compare", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":elasticity_impl", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "register", + srcs = [ + "register.cc", + ], + copts = [ + "-Wno-sign-compare", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":cable", + ":membrane", + ":shell", + ":solid", + "//:mujoco_hdrs", + ], + alwayslink = True, +) + +cc_shared_library( + name = "elasticity", + dynamic_deps = [ + "//:mujoco_shared", + ], + target_compatible_with = ["@platforms//os:linux"], + visibility = ["//visibility:public"], + deps = [ + "register", + ], +) diff --git a/plugin/sdf/BUILD.bazel b/plugin/sdf/BUILD.bazel new file mode 100644 index 0000000000..c94b4056fa --- /dev/null +++ b/plugin/sdf/BUILD.bazel @@ -0,0 +1,155 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +cc_library( + name = "sdf_impl", + srcs = [ + "sdf.cc", + ], + hdrs = [ + "sdf.h", + ], + copts = [ + "-Wno-sign-compare", + ], + deps = [ + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "torus", + srcs = [ + "torus.cc", + ], + hdrs = [ + "torus.h", + ], + copts = [ + "-Wno-sign-compare", + ], + deps = [ + ":sdf_impl", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "bolt", + srcs = [ + "bolt.cc", + ], + hdrs = [ + "bolt.h", + ], + copts = [ + "-Wno-sign-compare", + ], + deps = [ + ":sdf_impl", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "bowl", + srcs = [ + "bowl.cc", + ], + hdrs = [ + "bowl.h", + ], + copts = [ + "-Wno-sign-compare", + ], + deps = [ + ":sdf_impl", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "nut", + srcs = [ + "nut.cc", + ], + hdrs = [ + "nut.h", + ], + copts = [ + "-Wno-sign-compare", + ], + deps = [ + ":sdf_impl", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "gear", + srcs = [ + "gear.cc", + ], + hdrs = [ + "gear.h", + ], + copts = [ + "-Wno-sign-compare", + ], + deps = [ + ":sdf_impl", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "sdflib", + srcs = [ + "sdflib.cc", + ], + hdrs = [ + "sdflib.h", + ], + deps = [ + ":sdf_impl", + "//:mujoco_hdrs", + "@SdfLib", + ], +) + +cc_library( + name = "register", + srcs = [ + "register.cc", + ], + hdrs = [ + "bolt.h", + "bowl.h", + "gear.h", + "nut.h", + "sdf.h", + "sdflib.h", + "torus.h", + ], + deps = [ + ":bolt", + ":bowl", + ":gear", + ":nut", + ":sdflib", + ":torus", + "//:mujoco_hdrs", + "@SdfLib", + ], + alwayslink = True, +) + +cc_shared_library( + name = "sdf", + dynamic_deps = [ + "//:mujoco_shared", + ], + visibility = ["//visibility:public"], + deps = [ + "register", + ], +) diff --git a/plugin/sensor/BUILD.bazel b/plugin/sensor/BUILD.bazel new file mode 100644 index 0000000000..a225256ab7 --- /dev/null +++ b/plugin/sensor/BUILD.bazel @@ -0,0 +1,27 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +cc_library( + name = "touch_grid", + srcs = [ + "sensor.cc", + "touch_grid.cc", + ], + hdrs = [ + "touch_grid.h", + ], + deps = [ + "//:mujoco_hdrs", + ], + alwayslink = True, +) + +cc_shared_library( + name = "sensor", + dynamic_deps = [ + "//:mujoco_shared", + ], + visibility = ["//visibility:public"], + deps = [ + "touch_grid", + ], +) diff --git a/python/BUILD.bazel b/python/BUILD.bazel new file mode 100644 index 0000000000..0941e139bf --- /dev/null +++ b/python/BUILD.bazel @@ -0,0 +1,13 @@ +load("@rules_python//python:pip.bzl", "compile_pip_requirements") + +exports_files([ + "pip_requirements.in", + "pip_requirements.txt", +]) + +compile_pip_requirements( + name = "pip_requirements", + generate_hashes = False, + requirements_in = "pip_requirements.in", + requirements_txt = "pip_requirements.txt", +) diff --git a/python/mujoco/BUILD.bazel b/python/mujoco/BUILD.bazel new file mode 100644 index 0000000000..5ee0b5228a --- /dev/null +++ b/python/mujoco/BUILD.bazel @@ -0,0 +1,461 @@ +load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") +load("//devtools/bbcp/builddefs:build_defs.bzl", "generated_file") +load("//devtools/python/blaze:pybind.bzl", "pybind_extension", "pybind_library") +load("@pip_deps//:requirements.bzl", "requirement") +load("@mujoco//tools:symlink_files.bzl", "symlink_files") + +package(default_visibility = ["@mujoco//:__subpackages__"]) + +py_library( + name = "mujoco-py", + srcs = [ + "__init__.py", + "gl_context.py", + "minimize.py", + "renderer.py", + "rollout.py", + "viewer.py", + ], + data = [ + "//:license_filegroup", + "//:mujoco_shared", + ], + imports = [".."], + visibility = ["//visibility:public"], + deps = [ + ":_callbacks.so", + ":_constants.so", + ":_enums.so", + ":_errors.so", + ":_functions.so", + ":_render.so", + ":_rollout.so", + ":_simulate.so", + ":_specs.so", + ":_structs.so", + "//python/mujoco/glfw", + requirement("numpy"), + ], +) + +genrule( + name = "_genrule_enum_traits.h", + outs = ["enum_traits.h"], + cmd = "$(location //python/mujoco/codegen:generate_enum_traits) > $@", + tools = ["//python/mujoco/codegen:generate_enum_traits"], +) + +generated_file( + tags = ["mujoco_codegen"], + wrapped_target = ":_genrule_enum_traits.h", +) + +cc_library( + name = "mujoco_private_api_header", + hdrs = ["private.h"], + deps = ["//:mujoco_hdrs"], +) + +pybind_extension( + name = "_callbacks", + srcs = ["callbacks.cc"], + dynamic_deps = [ + "//:mujoco_shared", + ], + deps = [ + ":errors_header", + ":raw", + ":structs_header", + "//:mujoco_hdrs", + ], +) + +pybind_extension( + name = "_constants", + srcs = ["constants.cc"], + copts = [ + "-Werror=redundant-move", + "-Wno-redundant-move", + ], + dynamic_deps = [ + "//:mujoco_shared", + ], + deps = [ + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "enum_traits", + hdrs = ["enum_traits.h"], + deps = ["//:mujoco_hdrs"], +) + +pybind_extension( + name = "_enums", + srcs = ["enums.cc"], + copts = [ + "-Wno-deprecated-enum-float-conversion", + ], + deps = [ + ":enum_traits", + "//:mujoco_hdrs", + "//python/mujoco/util:crossplatform", + "//python/mujoco/util:tuple_tools", + ], +) + +genrule( + name = "_genrule_function_traits.h", + outs = ["function_traits.h"], + cmd = "$(location //python/mujoco/codegen:generate_function_traits) > $@", + tools = ["//python/mujoco/codegen:generate_function_traits"], +) + +generated_file( + tags = ["mujoco_codegen"], + wrapped_target = ":_genrule_function_traits.h", +) + +cc_library( + name = "function_traits", + hdrs = ["function_traits.h"], + deps = [ + "//:mujoco_hdrs", + "//python/mujoco/util:crossplatform", + ], +) + +pybind_library( + name = "errors_header", + hdrs = ["errors.h"], + deps = [ + ":mujoco_private_api_header", + "//:mujoco_hdrs", + "//python/mujoco/util:crossplatform", + "//python/mujoco/util:func_wrap", + ], +) + +pybind_extension( + name = "_errors", + srcs = ["errors.cc"], + deps = [":errors_header"], +) + +pybind_library( + name = "functions_header", + hdrs = ["functions.h"], + deps = [ + ":errors_header", + ":structs_header", + "//:mujoco_hdrs", + "//python/mujoco/util:array_traits", + "//python/mujoco/util:crossplatform", + "//python/mujoco/util:func_wrap", + "//python/mujoco/util:tuple_tools", + "@eigen", + ], +) + +pybind_extension( + name = "_functions", + srcs = ["functions.cc"], + copts = [ + "-Ipython/mujoco", + ], + dynamic_deps = [ + "//:mujoco_shared", + ], + deps = [ + ":errors_header", + ":function_traits", + ":functions_header", + ":mujoco_private_api_header", + ":raw", + ":structs_header", + "//:mujoco_hdrs", + "@eigen", + ], +) + +cc_library( + name = "raw", + hdrs = ["raw.h"], + deps = ["//:mujoco_hdrs"], +) + +pybind_extension( + name = "_render", + srcs = ["render.cc"], + copts = [ + "-Ipython/mujoco", + ], + dynamic_deps = [ + "//:mujoco_shared", + ], + deps = [ + ":errors_header", + ":function_traits", + ":functions_header", + ":raw", + ":structs_header", + "//:mujoco_hdrs", + "@eigen", + ], +) + +pybind_library( + name = "structs_header", + hdrs = [ + "indexer_xmacro.h", + "indexers.h", + "structs.h", + ], + copts = [ + "-Wno-sign-compare", + ], + deps = [ + ":raw", + "//:mujoco_hdrs", + "@abseil-cpp//absl/container:flat_hash_map", + "@abseil-cpp//absl/types:span", + ], +) + +pybind_extension( + name = "_structs", + srcs = [ + "indexers.cc", + "serialization.h", + "structs.cc", + ], + copts = [ + "-Wno-sign-compare", + "-Werror=redundant-move", + "-Wno-redundant-move", + "-Wno-type-limits", + "-Wno-error", + "-Wno-int-in-bool-context", + "-Ipython/mujoco", + ], + dynamic_deps = [ + "//:mujoco_shared", + ], + deps = [ + ":errors_header", + ":function_traits", + ":mujoco_private_api_header", + ":raw", + ":structs_header", + "//:mujoco_hdrs", + "//python/mujoco/util:crossplatform", + "@abseil-cpp//absl/container:flat_hash_map", + ], +) + +pybind_extension( + name = "_rollout", + srcs = ["rollout.cc"], + dynamic_deps = [ + "//:mujoco_shared", + ], + deps = [ + ":errors_header", + ":raw", + ":structs_header", + "//:mujoco_hdrs", + ], +) + +# This genrule is non-hermetic and uses the system-installed clang-format. +genrule( + name = "_genrule_specs.cc.inc", + outs = ["specs.cc.inc"], + cmd = """ + GENERATE_SPEC_BINDING=$(location //python/mujoco/codegen:generate_spec_bindings) + CLANG_FORMAT=$$(which clang-format) + $${GENERATE_SPEC_BINDING} | $${CLANG_FORMAT} - > $@ + """, + tools = [ + "//python/mujoco/codegen:generate_spec_bindings", + ], +) + +pybind_extension( + name = "_simulate", + srcs = [ + "simulate.cc", + ], + copts = [ + "-Werror=redundant-move", + "-Wno-redundant-move", + "-Wno-type-limits", + "-Wno-error", + "-Ipython/mujoco", + "-Isimulate", + ], + deps = [ + ":errors_header", + ":structs_header", + "//simulate:simulate_lib", + "@libglfw3//:lib", + ], +) + +pybind_extension( + name = "_specs", + srcs = [ + "specs.cc", + "specs.cc.inc", + ], + dynamic_deps = [ + "//:mujoco_shared", + ], + deps = [ + ":errors_header", + ":raw", + ":structs_header", + "//:mujoco_hdrs", + "@eigen", + ], +) + +exports_files( + srcs = [ + "mjpython/mjpython.mm", + "mjpython/mjpython.py", + ], +) + +# symlink plugins for test +symlink_files( + name = "symlinked_plugins", + srcs = [ + "//plugin/actuator", + "//plugin/elasticity", + "//plugin/sdf", + "//plugin/sensor", + ], +) + +# symlink plugins for test +symlink_files( + name = "symlinked_mujoco_so", + srcs = [ + "//:mujoco_shared", + ], +) + +py_test( + name = "bindings_test", + size = "small", + srcs = ["bindings_test.py"], + data = [ + ":symlinked_mujoco_so", + ":symlinked_plugins", + ], + deps = [ + ":mujoco-py", + requirement("absl-py"), + requirement("numpy"), + ], +) + +# This test should be running with xvfb. (e.g., xvfb-run -s "-screen 0 1024x768x24" bazel run //python/mujoco:renderer_test) +py_binary( + name = "renderer_test", + srcs = ["renderer_test.py"], + deps = [ + ":mujoco-py", + requirement("absl-py"), + requirement("numpy"), + ], +) + +# This test should be running with xvfb. (e.g., xvfb-run -s "-screen 0 1024x768x24" bazel run //python/mujoco:render_test) +py_binary( + name = "render_test", + srcs = ["render_test.py"], + main = "render_test.py", + deps = [ + ":mujoco-py", + "//python/mujoco/glfw", + requirement("absl-py"), + requirement("numpy"), + ], +) + +py_test( + name = "rollout_test", + size = "small", + srcs = ["rollout_test.py"], + deps = [ + ":mujoco-py", + requirement("absl-py"), + requirement("numpy"), + ], +) + +# This fails due to the missing pystub +# py_test( +# name = "specs_test", +# srcs = ["specs_test.py"], +# data = [ +# "//:test_data", +# ], +# deps = [ +# ":mujoco-py", +# requirement("absl-py"), +# requirement("numpy"), +# ], +# ) + +py_test( + name = "minimize_test", + size = "small", + srcs = ["minimize_test.py"], + deps = [ + ":mujoco-py", + requirement("absl-py"), + requirement("numpy"), + ], +) + +py_library( + name = "msh2obj", + srcs = [ + "msh2obj.py", + ], + deps = [ + requirement("numpy"), + ], +) + +py_test( + name = "msh2obj_test", + size = "small", + srcs = ["msh2obj_test.py"], + data = [ + "//python/mujoco/testdata:model", + ], + deps = [ + ":msh2obj", + ":mujoco-py", + requirement("absl-py"), + requirement("numpy"), + requirement("etils"), + requirement("typing-extensions"), + requirement("importlib-resources"), + ], +) + +py_test( + name = "memory_leak_test", + size = "small", + srcs = ["memory_leak_test.py"], + deps = [ + ":mujoco-py", + requirement("absl-py"), + ], +) diff --git a/python/mujoco/__init__.py b/python/mujoco/__init__.py index ca77a1a0a9..c2720f1614 100644 --- a/python/mujoco/__init__.py +++ b/python/mujoco/__init__.py @@ -14,6 +14,8 @@ # ============================================================================== """Python bindings for MuJoCo.""" +__path__ = __import__('pkgutil').extend_path(__path__, __name__) + import ctypes import ctypes.util import os diff --git a/python/mujoco/cgl/BUILD.bazel b/python/mujoco/cgl/BUILD.bazel new file mode 100644 index 0000000000..956eb21c69 --- /dev/null +++ b/python/mujoco/cgl/BUILD.bazel @@ -0,0 +1,7 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +filegroup( + name = "cgl", + srcs = glob(["**"]), + tags = ["ignore_srcs"], +) diff --git a/python/mujoco/codegen/BUILD.bazel b/python/mujoco/codegen/BUILD.bazel new file mode 100644 index 0000000000..3a7fca3d0c --- /dev/null +++ b/python/mujoco/codegen/BUILD.bazel @@ -0,0 +1,33 @@ +load("@pip_deps//:requirements.bzl", "requirement") + +package(default_visibility = ["@mujoco//:__subpackages__"]) + +py_binary( + name = "generate_enum_traits", + srcs = ["generate_enum_traits.py"], + deps = [ + "//introspect:ast_nodes", + "//introspect:enums", + requirement("absl-py"), + ], +) + +py_binary( + name = "generate_function_traits", + srcs = ["generate_function_traits.py"], + deps = [ + "//introspect:ast_nodes", + "//introspect:functions", + requirement("absl-py"), + ], +) + +py_binary( + name = "generate_spec_bindings", + srcs = ["generate_spec_bindings.py"], + deps = [ + "//introspect:ast_nodes", + "//introspect:structs", + requirement("absl-py"), + ], +) diff --git a/python/mujoco/egl/BUILD.bazel b/python/mujoco/egl/BUILD.bazel new file mode 100644 index 0000000000..a5756a3785 --- /dev/null +++ b/python/mujoco/egl/BUILD.bazel @@ -0,0 +1,13 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +py_library( + name = "egl", + srcs = [ + "__init__.py", + "egl_ext.py", + ], + tags = ["keep_dep"], + deps = [ + "@libglfw3//:lib", + ], +) diff --git a/python/mujoco/enums.cc b/python/mujoco/enums.cc index 640e7c0c30..417f056c86 100644 --- a/python/mujoco/enums.cc +++ b/python/mujoco/enums.cc @@ -20,7 +20,7 @@ #include #include "util/crossplatform.h" -#include "enum_traits.h" +#include "python/mujoco/enum_traits.h" #include "util/tuple_tools.h" #include #include @@ -44,7 +44,7 @@ inline T FloorDiv(T a, T b) { template void DefEnum(py::module_& m) { - py::enum_ e(m, Trait::name); + py::enum_ e(m, Trait::name, py::module_local()); for (const auto& [name, enumerator] : Trait::values) { e.value(name, enumerator); } diff --git a/python/mujoco/functions.cc b/python/mujoco/functions.cc index 7fed04f7c9..7b8e93f4d6 100644 --- a/python/mujoco/functions.cc +++ b/python/mujoco/functions.cc @@ -24,7 +24,7 @@ #include #include #include "errors.h" -#include "function_traits.h" +#include "python/mujoco/function_traits.h" #include "functions.h" #include "private.h" #include "raw.h" diff --git a/python/mujoco/glfw/BUILD.bazel b/python/mujoco/glfw/BUILD.bazel new file mode 100644 index 0000000000..46179f874e --- /dev/null +++ b/python/mujoco/glfw/BUILD.bazel @@ -0,0 +1,12 @@ +load("@pip_deps//:requirements.bzl", "requirement") + +package(default_visibility = ["@mujoco//:__subpackages__"]) + +py_library( + name = "glfw", + srcs = ["__init__.py"], + tags = ["keep_dep"], + deps = [ + requirement("glfw"), + ], +) diff --git a/python/mujoco/indexers.h b/python/mujoco/indexers.h index 2b9defadfe..6a249cafcd 100644 --- a/python/mujoco/indexers.h +++ b/python/mujoco/indexers.h @@ -22,7 +22,7 @@ #include #include -#include +#include "absl/container/flat_hash_map.h" #include #include "indexer_xmacro.h" #include "raw.h" diff --git a/python/mujoco/introspect/BUILD.bazel b/python/mujoco/introspect/BUILD.bazel new file mode 100644 index 0000000000..535f009031 --- /dev/null +++ b/python/mujoco/introspect/BUILD.bazel @@ -0,0 +1,31 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +py_library( + name = "ast_nodes", + srcs = ["ast_nodes.py"], + imports = [".."], +) + +py_library( + name = "type_parsing", + srcs = ["type_parsing.py"], + deps = [":ast_nodes"], +) + +py_library( + name = "enums", + srcs = ["enums.py"], + deps = [":ast_nodes"], +) + +py_library( + name = "functions", + srcs = ["functions.py"], + deps = [":ast_nodes"], +) + +py_library( + name = "structs", + srcs = ["structs.py"], + deps = [":ast_nodes"], +) diff --git a/python/mujoco/introspect/codegen/BUILD.bazel b/python/mujoco/introspect/codegen/BUILD.bazel new file mode 100644 index 0000000000..27a5f57d71 --- /dev/null +++ b/python/mujoco/introspect/codegen/BUILD.bazel @@ -0,0 +1,107 @@ +load("@pip_deps//:requirements.bzl", "requirement") + +# This genrule is non-hermetic and uses the system-installed clang. +genrule( + name = "_genrule_mujoco.h.json", + srcs = ["//:mujoco_headers"], + outs = ["mujoco.h.json"], + cmd = """ + CLANG=$$(which clang) + CLANG_INCLUDE=$$($${CLANG} --print-resource-dir)/include + MUJOCO_H=$$(find $(locations //:mujoco_headers) -name mujoco.h) + MUJOCO_INCLUDE=$$(dirname $$(dirname $${MUJOCO_H})) + $${CLANG} \ + -isystem$${CLANG_INCLUDE} \ + -I$${PWD} \ + -I$${MUJOCO_INCLUDE} \ + -Xclang -ast-dump=json -fsyntax-only -fparse-all-comments -x c \ + $${MUJOCO_H} > $@ + """, +) + +py_binary( + name = "generate_enums", + srcs = ["generate_enums.py"], + deps = [ + ":formatter", + "//introspect:ast_nodes", + requirement("absl-py"), + "@abseil-cpp//absl/flags:flag", + ], +) + +genrule( + name = "_genrule_enums.py", + srcs = [ + "mujoco.h.json", + "//:mujoco_headers", + ], + outs = ["enums.py"], + cmd = """ + MUJOCO_H=$$(find $(locations //:mujoco_headers) -name mujoco.h) + $(location :generate_enums) \ + --json_path=$(location mujoco.h.json) > $@ + """, + tools = [":generate_enums"], +) + +py_binary( + name = "generate_functions", + srcs = ["generate_functions.py"], + deps = [ + ":formatter", + "//introspect:ast_nodes", + "//introspect:type_parsing", + requirement("absl-py"), + "@abseil-cpp//absl/flags:flag", + ], +) + +genrule( + name = "_genrule_functions.py", + srcs = [ + "mujoco.h.json", + "//:mujoco_headers", + ], + outs = ["functions.py"], + cmd = """ + MUJOCO_H=$$(find $(locations //:mujoco_headers) -name mujoco.h) + $(location :generate_functions) \ + --header_path=$${MUJOCO_H} \ + --json_path=$(location mujoco.h.json) > $@ + """, + tools = [":generate_functions"], +) + +py_binary( + name = "generate_structs", + srcs = ["generate_structs.py"], + deps = [ + ":formatter", + "//introspect:ast_nodes", + "//introspect:type_parsing", + requirement("absl-py"), + "@abseil-cpp//absl/flags:flag", + ], +) + +genrule( + name = "_genrule_structs.py", + srcs = [ + "mujoco.h.json", + "//:mujoco_headers", + ], + outs = ["structs.py"], + cmd = """ + MUJOCO_H=$$(find $(locations //:mujoco_headers) -name mujoco.h) + $(location :generate_structs) \ + --json_path=$(location mujoco.h.json) > $@ + """, + tools = [":generate_structs"], +) + +py_library( + name = "formatter", + srcs = ["formatter.py"], + imports = ["."], +) diff --git a/python/mujoco/introspect/codegen/generate_enums.py b/python/mujoco/introspect/codegen/generate_enums.py index 59d7ff3b60..ffaa8afee5 100644 --- a/python/mujoco/introspect/codegen/generate_enums.py +++ b/python/mujoco/introspect/codegen/generate_enums.py @@ -25,7 +25,7 @@ from absl import flags from introspect import ast_nodes -from . import formatter +from introspect.codegen import formatter _JSON_PATH = flags.DEFINE_string( 'json_path', None, diff --git a/python/mujoco/introspect/codegen/generate_functions.py b/python/mujoco/introspect/codegen/generate_functions.py index 1966e32895..94f660d6ee 100644 --- a/python/mujoco/introspect/codegen/generate_functions.py +++ b/python/mujoco/introspect/codegen/generate_functions.py @@ -26,7 +26,7 @@ from introspect import ast_nodes from introspect import type_parsing -from . import formatter +from introspect.codegen import formatter _HEADER_PATH = flags.DEFINE_string( 'header_path', None, 'Path to the original mujoco.h') diff --git a/python/mujoco/introspect/codegen/generate_structs.py b/python/mujoco/introspect/codegen/generate_structs.py index 1c50db22fd..2837ccf2b5 100644 --- a/python/mujoco/introspect/codegen/generate_structs.py +++ b/python/mujoco/introspect/codegen/generate_structs.py @@ -29,7 +29,7 @@ from introspect import ast_nodes from introspect import type_parsing -from . import formatter +from introspect.codegen import formatter _JSON_PATH = flags.DEFINE_string( 'json_path', None, diff --git a/python/mujoco/osmesa/BUILD.bazel b/python/mujoco/osmesa/BUILD.bazel new file mode 100644 index 0000000000..1e30def958 --- /dev/null +++ b/python/mujoco/osmesa/BUILD.bazel @@ -0,0 +1,12 @@ +load("@pip_deps//:requirements.bzl", "requirement") + +package(default_visibility = ["@mujoco//:__subpackages__"]) + +py_library( + name = "osmesa", + srcs = ["__init__.py"], + deps = [ + requirement("pyopengl"), + requirement("pyopengl_accelerate"), + ], +) diff --git a/python/mujoco/render.cc b/python/mujoco/render.cc index c621cd0e2d..15c06689f1 100644 --- a/python/mujoco/render.cc +++ b/python/mujoco/render.cc @@ -21,7 +21,7 @@ #include #include #include "errors.h" -#include "function_traits.h" +#include "python/mujoco/function_traits.h" #include "functions.h" #include "raw.h" #include "structs.h" diff --git a/python/mujoco/specs.cc b/python/mujoco/specs.cc index 2869483e27..a16e99df05 100644 --- a/python/mujoco/specs.cc +++ b/python/mujoco/specs.cc @@ -1092,6 +1092,6 @@ PYBIND11_MODULE(_specs, m) { self.global = value; }); -#include "specs.cc.inc" +#include "python/mujoco/specs.cc.inc" } // PYBIND11_MODULE // NOLINT } // namespace mujoco::python diff --git a/python/mujoco/structs.cc b/python/mujoco/structs.cc index 90b73d2410..c52caa3c48 100644 --- a/python/mujoco/structs.cc +++ b/python/mujoco/structs.cc @@ -36,7 +36,7 @@ #include #include -#include +#include "absl/container/flat_hash_map.h" #include #include #include "errors.h" diff --git a/python/mujoco/structs.h b/python/mujoco/structs.h index da8c283a2f..2bc196fdc0 100644 --- a/python/mujoco/structs.h +++ b/python/mujoco/structs.h @@ -32,7 +32,7 @@ #include #include -#include +#include "absl/types/span.h" #include #include #include "indexers.h" diff --git a/python/mujoco/testdata/BUILD.bazel b/python/mujoco/testdata/BUILD.bazel new file mode 100644 index 0000000000..4f7bb5e091 --- /dev/null +++ b/python/mujoco/testdata/BUILD.bazel @@ -0,0 +1,10 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +filegroup( + name = "model", + srcs = glob([ + "**/*.xml", + "**/*.msh", + "**/*.usda", + ]), +) diff --git a/python/mujoco/util/BUILD.bazel b/python/mujoco/util/BUILD.bazel new file mode 100644 index 0000000000..ce019d9059 --- /dev/null +++ b/python/mujoco/util/BUILD.bazel @@ -0,0 +1,39 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +cc_library( + name = "array_traits", + hdrs = ["array_traits.h"], + deps = [ + ":crossplatform", + "@eigen", + ], +) + +cc_library( + name = "crossplatform", + hdrs = ["crossplatform.h"], +) + +cc_library( + name = "func_traits", + hdrs = ["func_traits.h"], +) + +cc_library( + name = "func_wrap", + hdrs = ["func_wrap.h"], + deps = [ + ":array_traits", + ":crossplatform", + ":func_traits", + "@eigen", + ], +) + +cc_library( + name = "tuple_tools", + hdrs = ["tuple_tools.h"], + deps = [ + ":crossplatform", + ], +) diff --git a/python/pip_requirements.in b/python/pip_requirements.in new file mode 100644 index 0000000000..8ad859d4f5 --- /dev/null +++ b/python/pip_requirements.in @@ -0,0 +1,12 @@ +absl-py +numpy +jax +glfw +trimesh +scipy +pyopengl +pyopengl_accelerate +etils +typing-extensions +importlib-resources +trimesh diff --git a/python/pip_requirements.txt b/python/pip_requirements.txt new file mode 100644 index 0000000000..b34f00b24b --- /dev/null +++ b/python/pip_requirements.txt @@ -0,0 +1,45 @@ +# +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: +# +# bazel run //python:pip_requirements.update +# +absl-py==2.1.0 + # via -r python/pip_requirements.in +etils==1.10.0 + # via -r python/pip_requirements.in +glfw==2.7.0 + # via -r python/pip_requirements.in +importlib-resources==6.4.5 + # via -r python/pip_requirements.in +jax==0.4.34 + # via -r python/pip_requirements.in +jaxlib==0.4.34 + # via jax +ml-dtypes==0.5.0 + # via + # jax + # jaxlib +numpy==2.1.2 + # via + # -r python/pip_requirements.in + # jax + # jaxlib + # ml-dtypes + # scipy + # trimesh +opt-einsum==3.4.0 + # via jax +pyopengl==3.1.7 + # via -r python/pip_requirements.in +pyopengl-accelerate==3.1.7 + # via -r python/pip_requirements.in +scipy==1.14.1 + # via + # -r python/pip_requirements.in + # jax + # jaxlib +trimesh==4.5.0 + # via -r python/pip_requirements.in +typing-extensions==4.12.2 + # via -r python/pip_requirements.in diff --git a/sample/BUILD.bazel b/sample/BUILD.bazel new file mode 100644 index 0000000000..d5228439e3 --- /dev/null +++ b/sample/BUILD.bazel @@ -0,0 +1,7 @@ +cc_binary( + name = "testspeed", + srcs = ["testspeed.cc"], + deps = [ + "//:mujoco", + ], +) diff --git a/simulate/BUILD.bazel b/simulate/BUILD.bazel new file mode 100644 index 0000000000..496b190b6b --- /dev/null +++ b/simulate/BUILD.bazel @@ -0,0 +1,67 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +cc_library( + name = "platform_ui_adapter", + srcs = [ + "glfw_adapter.cc", + "glfw_dispatch.cc", + "platform_ui_adapter.cc", + ], + hdrs = [ + "glfw_adapter.h", + "glfw_dispatch.h", + "platform_ui_adapter.h", + ], + data = [ + "//:license_filegroup", + ], + linkstatic = True, + target_compatible_with = ["@platforms//os:linux"], + deps = [ + "//:mujoco", + "@libglfw3//:lib", + ], +) + +cc_library( + name = "simulate_lib", + srcs = [ + "array_safety.h", + "simulate.cc", + ], + hdrs = [ + "simulate.h", + ], + copts = [ + "-Wno-sign-compare", + ], + data = [ + "//:license_filegroup", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":platform_ui_adapter", + "@lodepng", + ], +) + +cc_binary( + name = "main", + srcs = [ + "main.cc", + ], + copts = [ + "-Wno-sign-compare", + ], + data = [ + "//:license_filegroup", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":simulate_lib", + "//plugin/actuator:register", + "//plugin/elasticity:register", + "//plugin/sdf:register", + "//plugin/sensor:touch_grid", + ], +) diff --git a/src/cc/BUILD.bazel b/src/cc/BUILD.bazel new file mode 100644 index 0000000000..886701112e --- /dev/null +++ b/src/cc/BUILD.bazel @@ -0,0 +1,7 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +cc_library( + name = "array_safety", + hdrs = ["array_safety.h"], + target_compatible_with = ["@platforms//os:linux"], +) diff --git a/src/engine/BUILD.bazel b/src/engine/BUILD.bazel new file mode 100644 index 0000000000..e320cc0651 --- /dev/null +++ b/src/engine/BUILD.bazel @@ -0,0 +1,556 @@ +load("//src/engine:helper.bzl", "THIN_LTO_FEATURE_IF_CLANG", "THIN_LTO_LINKOPTS_IF_CLANG") + +package(default_visibility = ["@mujoco//:__subpackages__"]) + +cc_library( + name = "engine", + srcs = [ + "engine_collision_driver.c", + "engine_collision_sdf.c", + "engine_core_constraint.c", + "engine_core_smooth.c", + "engine_derivative.c", + "engine_derivative_fd.c", + "engine_forward.c", + "engine_inverse.c", + "engine_island.c", + "engine_passive.c", + "engine_print.c", + "engine_sensor.c", + "engine_setconst.c", + "engine_solver.c", + "engine_support.c", + "engine_vis_interact.c", + "engine_vis_state.c", + "engine_vis_visualize.c", + ], + hdrs = [ + "engine_collision_driver.h", + "engine_collision_sdf.h", + "engine_core_constraint.h", + "engine_core_smooth.h", + "engine_derivative.h", + "engine_derivative_fd.h", + "engine_forward.h", + "engine_inverse.h", + "engine_island.h", + "engine_passive.h", + "engine_print.h", + "engine_sensor.h", + "engine_setconst.h", + "engine_solver.h", + "engine_support.h", + "engine_vis_interact.h", + "engine_vis_state.h", + "engine_vis_visualize.h", + ], + copts = [ + "-Wno-unknown-pragmas", + "-Wno-error=unknown-pragmas", + "-Wshadow", + "-Isrc", + ] + select({ + "//tools:clang": [ + "-Wno-unused-command-line-argument", + ], + "//tools:gcc": [ + "-Wno-format-overflow", + ], + "//conditions:default": [], + }), + features = THIN_LTO_FEATURE_IF_CLANG, + linkopts = THIN_LTO_LINKOPTS_IF_CLANG, + local_defines = [ + "_GNU_SOURCE", + "mjUSEPLATFORMSIMD", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":engine_array_safety", + ":engine_callback", + ":engine_collision_box", + ":engine_collision_convex", + ":engine_collision_primitive", + ":engine_crossplatform", + ":engine_io", + ":engine_macro", + ":engine_name", + ":engine_plugin", + ":engine_ray", + ":engine_util_blas", + ":engine_util_errmem", + ":engine_util_misc", + ":engine_util_solve", + ":engine_util_sparse", + ":engine_util_spatial", + ":engine_vis_init", + "//:mujoco_hdrs", + "//src/thread:thread_pool", + "//src/thread:thread_task", + "@libccd", + ], +) + +cc_library( + name = "engine_array_safety", + copts = ["-Wshadow"], + features = THIN_LTO_FEATURE_IF_CLANG, + linkopts = THIN_LTO_LINKOPTS_IF_CLANG, + target_compatible_with = ["@platforms//os:linux"], + textual_hdrs = ["engine_array_safety.h"], +) + +cc_library( + name = "engine_callback", + srcs = ["engine_callback.c"], + hdrs = ["engine_callback.h"], + copts = [ + "-Wshadow", + "-Isrc", + ] + select({ + "//tools:clang": [ + "-Wno-unused-command-line-argument", + ], + "//conditions:default": [], + }), + features = THIN_LTO_FEATURE_IF_CLANG, + linkopts = THIN_LTO_LINKOPTS_IF_CLANG, + target_compatible_with = ["@platforms//os:linux"], + deps = [ + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "engine_collision_box", + srcs = [ + "engine_collision_box.c", + ], + copts = [ + "-Wshadow", + "-Isrc", + ] + select({ + "//tools:clang": [ + "-Wno-unused-command-line-argument", + ], + "//conditions:default": [], + }), + features = THIN_LTO_FEATURE_IF_CLANG, + linkopts = THIN_LTO_LINKOPTS_IF_CLANG, + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":engine_collision_primitive", + ":engine_util_blas", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "engine_collision_convex", + srcs = [ + "engine_collision_convex.c", + "engine_collision_gjk.c", + ], + hdrs = [ + "engine_collision_convex.h", + "engine_collision_gjk.h", + ], + copts = [ + "-Wno-unknown-pragmas", + "-Wno-error=unknown-pragmas", + "-Wshadow", + "-Isrc", + ] + select({ + "//tools:clang": [ + "-Wno-unused-command-line-argument", + ], + "//conditions:default": [], + }), + features = THIN_LTO_FEATURE_IF_CLANG, + linkopts = THIN_LTO_LINKOPTS_IF_CLANG, + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":engine_collision_primitive", + ":engine_util_blas", + ":engine_util_errmem", + ":engine_util_misc", + ":engine_util_spatial", + "//:mujoco_hdrs", + "@libccd", + ], +) + +cc_library( + name = "engine_collision_primitive", + srcs = ["engine_collision_primitive.c"], + hdrs = ["engine_collision_primitive.h"], + copts = [ + "-Wshadow", + "-Isrc", + ] + select({ + "//tools:clang": [ + "-Wno-unused-command-line-argument", + ], + "//conditions:default": [], + }), + features = THIN_LTO_FEATURE_IF_CLANG, + linkopts = THIN_LTO_LINKOPTS_IF_CLANG, + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":engine_util_blas", + ":engine_util_misc", + ":engine_util_spatial", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "engine_crossplatform", + srcs = ["engine_crossplatform.cc"], + hdrs = ["engine_crossplatform.h"], + copts = [ + "-Wshadow", + "-Isrc", + ] + select({ + "//tools:clang": [ + "-Wno-unused-command-line-argument", + ], + "//conditions:default": [], + }), + features = THIN_LTO_FEATURE_IF_CLANG, + linkopts = THIN_LTO_LINKOPTS_IF_CLANG, + target_compatible_with = ["@platforms//os:linux"], +) + +cc_library( + name = "engine_io", + srcs = ["engine_io.c"], + hdrs = ["engine_io.h"], + copts = [ + "-Wno-unknown-pragmas", + "-Wno-error=unknown-pragmas", + "-Wno-type-limits", + "-Wshadow", + "-Isrc", + ] + select({ + "//tools:clang": [ + "-Wno-unused-command-line-argument", + ], + "//conditions:default": [], + }), + features = THIN_LTO_FEATURE_IF_CLANG, + linkopts = THIN_LTO_LINKOPTS_IF_CLANG, + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":engine_crossplatform", + ":engine_macro", + ":engine_plugin", + ":engine_util_blas", + ":engine_util_errmem", + ":engine_util_misc", + "//:mujoco_hdrs", + "//src/thread:thread_pool", + ], +) + +cc_library( + name = "engine_macro", + hdrs = ["engine_macro.h"], + copts = ["-Wshadow"], + features = THIN_LTO_FEATURE_IF_CLANG, + linkopts = THIN_LTO_LINKOPTS_IF_CLANG, + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":engine_callback", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "engine_name", + srcs = ["engine_name.c"], + hdrs = ["engine_name.h"], + copts = [ + "-Wshadow", + "-Isrc", + ] + select({ + "//tools:clang": [ + "-Wno-unused-command-line-argument", + ], + "//conditions:default": [], + }), + features = THIN_LTO_FEATURE_IF_CLANG, + linkopts = THIN_LTO_LINKOPTS_IF_CLANG, + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":engine_crossplatform", + ":engine_io", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "engine_plugin", + srcs = ["engine_plugin.cc"], + hdrs = [ + "engine_global_table.h", + "engine_plugin.h", + ], + copts = [ + "-Wno-unknown-pragmas", + "-Wno-error=unknown-pragmas", + "-Wshadow", + "-Isrc", + ] + select({ + "//tools:clang": [ + "-Wno-unused-command-line-argument", + ], + "//conditions:default": [], + }), + features = THIN_LTO_FEATURE_IF_CLANG, + linkopts = ["-ldl"] + THIN_LTO_LINKOPTS_IF_CLANG, + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":engine_util_errmem", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "engine_ray", + srcs = ["engine_ray.c"], + hdrs = ["engine_ray.h"], + copts = [ + "-Wno-unknown-pragmas", + "-Wno-error=unknown-pragmas", + "-Wshadow", + "-Isrc", + ] + select({ + "//tools:clang": [ + "-Wno-unused-command-line-argument", + ], + "//conditions:default": [], + }), + features = THIN_LTO_FEATURE_IF_CLANG, + linkopts = THIN_LTO_LINKOPTS_IF_CLANG, + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":engine_io", + ":engine_plugin", + ":engine_util_blas", + ":engine_util_errmem", + ":engine_util_misc", + ":engine_util_spatial", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "engine_util_blas", + srcs = ["engine_util_blas.c"], + hdrs = ["engine_util_blas.h"], + copts = [ + "-Wshadow", + "-Isrc", + ] + select({ + "//tools:clang": [ + "-Wno-unused-command-line-argument", + ], + "//conditions:default": [], + }), + features = THIN_LTO_FEATURE_IF_CLANG, + linkopts = THIN_LTO_LINKOPTS_IF_CLANG, + local_defines = [ + "mjUSEPLATFORMSIMD", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "engine_util_container", + srcs = ["engine_util_container.c"], + hdrs = ["engine_util_container.h"], + copts = [ + "-Isrc", + ] + select({ + "//tools:clang": [ + "-Wno-unused-command-line-argument", + ], + "//conditions:default": [], + }), + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":engine_crossplatform", + ":engine_io", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "engine_util_errmem", + srcs = ["engine_util_errmem.c"], + hdrs = ["engine_util_errmem.h"], + copts = [ + "-Wno-unknown-pragmas", + "-Wno-error=unknown-pragmas", + "-Wshadow", + "-Isrc", + ] + select({ + "//tools:clang": [ + "-Wno-unused-command-line-argument", + ], + "//conditions:default": [], + }), + features = THIN_LTO_FEATURE_IF_CLANG, + linkopts = THIN_LTO_LINKOPTS_IF_CLANG, + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":engine_array_safety", + ":engine_macro", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "engine_util_misc", + srcs = ["engine_util_misc.c"], + hdrs = ["engine_util_misc.h"], + copts = [ + "-Wno-unknown-pragmas", + "-Wno-error=unknown-pragmas", + "-Wshadow", + "-Isrc", + ] + select({ + "//tools:clang": [ + "-Wno-unused-command-line-argument", + ], + "//conditions:default": [], + }), + features = THIN_LTO_FEATURE_IF_CLANG, + linkopts = THIN_LTO_LINKOPTS_IF_CLANG, + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":engine_array_safety", + ":engine_macro", + ":engine_util_blas", + ":engine_util_errmem", + ":engine_util_spatial", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "engine_util_sparse", + srcs = [ + "engine_util_sparse.c", + ], + hdrs = [ + "engine_util_sparse.h", + "engine_util_sparse_avx.h", + ], + copts = [ + "-Wshadow", + "-Isrc", + ] + select({ + "//tools:clang": [ + "-Wno-unused-command-line-argument", + ], + "//conditions:default": [], + }), + features = THIN_LTO_FEATURE_IF_CLANG, + linkopts = THIN_LTO_LINKOPTS_IF_CLANG, + local_defines = [ + "mjUSEPLATFORMSIMD", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":engine_io", + ":engine_macro", + ":engine_util_blas", + ":engine_util_misc", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "engine_util_spatial", + srcs = ["engine_util_spatial.c"], + hdrs = ["engine_util_spatial.h"], + copts = [ + "-Wno-unknown-pragmas", + "-Wno-error=unknown-pragmas", + "-Wshadow", + "-Isrc", + ] + select({ + "//tools:clang": [ + "-Wno-unused-command-line-argument", + ], + "//conditions:default": [], + }), + features = THIN_LTO_FEATURE_IF_CLANG, + linkopts = THIN_LTO_LINKOPTS_IF_CLANG, + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":engine_util_blas", + ":engine_util_errmem", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "engine_util_solve", + srcs = ["engine_util_solve.c"], + hdrs = ["engine_util_solve.h"], + copts = [ + "-Wno-unknown-pragmas", + "-Wno-error=unknown-pragmas", + "-Wshadow", + "-Isrc", + ] + select({ + "//tools:clang": [ + "-Wno-unused-command-line-argument", + ], + "//conditions:default": [], + }), + features = THIN_LTO_FEATURE_IF_CLANG, + linkopts = THIN_LTO_LINKOPTS_IF_CLANG, + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":engine_io", + ":engine_util_blas", + ":engine_util_errmem", + ":engine_util_misc", + ":engine_util_sparse", + ":engine_util_spatial", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "engine_vis_init", + srcs = ["engine_vis_init.c"], + hdrs = ["engine_vis_init.h"], + copts = [ + "-Wno-unknown-pragmas", + "-Wno-error=unknown-pragmas", + "-Wshadow", + "-Isrc", + ] + select({ + "//tools:clang": [ + "-Wno-unused-command-line-argument", + ], + "//conditions:default": [], + }), + features = THIN_LTO_FEATURE_IF_CLANG, + linkopts = THIN_LTO_LINKOPTS_IF_CLANG, + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":engine_array_safety", + ":engine_util_errmem", + ":engine_util_misc", + "//:mujoco_hdrs", + ], +) diff --git a/src/engine/engine_setconst.c b/src/engine/engine_setconst.c index 73f8919e75..95c3185158 100644 --- a/src/engine/engine_setconst.c +++ b/src/engine/engine_setconst.c @@ -96,10 +96,13 @@ static void set0(mjModel* m, mjData* d) { // compute dof_M0 for CRB algorithm mj_setM0(m, d); - // save flex_rigid, temporarily make all flexes non-rigid - mjtByte* rigid = mju_malloc(m->nflex); - memcpy(rigid, m->flex_rigid, m->nflex); - memset(m->flex_rigid, 0, m->nflex); + mjtByte* flex_rigid_cache = NULL; + if (m->nflex > 0) { + // save flex_rigid, temporarily make all flexes non-rigid + flex_rigid_cache = mju_malloc(m->nflex); + memcpy(flex_rigid_cache, m->flex_rigid, m->nflex); + memset(m->flex_rigid, 0, m->nflex); + } // run remaining computations mj_crb(m, d); @@ -108,9 +111,11 @@ static void set0(mjModel* m, mjData* d) { mj_tendon(m, d); mj_transmission(m, d); - // restore flex rigidity - memcpy(m->flex_rigid, rigid, m->nflex); - mju_free(rigid); + if (flex_rigid_cache) { + // restore flex rigidity + memcpy(m->flex_rigid, flex_rigid_cache, m->nflex); + mju_free(flex_rigid_cache); + } // restore camera and light mode for (int i=0; i < m->ncam; i++) { diff --git a/src/engine/helper.bzl b/src/engine/helper.bzl new file mode 100644 index 0000000000..5aff432b68 --- /dev/null +++ b/src/engine/helper.bzl @@ -0,0 +1,9 @@ +THIN_LTO_FEATURE_IF_CLANG = select({ + "//tools:clang": ["thin_lto"], + "//conditions:default": [], +}) + +THIN_LTO_LINKOPTS_IF_CLANG = select({ + "//tools:clang": ["-flto=thin"], + "//conditions:default": [], +}) diff --git a/src/render/BUILD.bazel b/src/render/BUILD.bazel new file mode 100644 index 0000000000..d421951768 --- /dev/null +++ b/src/render/BUILD.bazel @@ -0,0 +1,103 @@ +licenses(["notice"]) + +package(default_visibility = ["@mujoco//:__subpackages__"]) + +cc_library( + name = "glad", + srcs = [ + "glad/glad.c", + "glad/loader.cc", + ], + hdrs = ["glad/glad.h"], + copts = [ + "-Wno-unknown-pragmas", + "-Wno-error=unknown-pragmas", + "-Isrc", + ], + linkopts = ["-ldl"], + target_compatible_with = ["@platforms//os:linux"], + deps = ["//src/engine:engine_util_errmem"], +) + +cc_library( + name = "render", + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":render_context", + ":render_gl2", + ":render_gl3", + ":render_util", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "render_context", + srcs = ["render_context.c"], + hdrs = ["render_context.h"], + copts = [ + "-Isrc", + ], + target_compatible_with = ["@platforms//os:linux"], + textual_hdrs = glob([ + "font/*.inc", + ]), + deps = [ + ":glad", + ":render_util", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "render_gl2", + srcs = ["render_gl2.c"], + hdrs = ["render_gl2.h"], + copts = [ + "-Isrc", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + "//:mujoco_hdrs", + "//src/engine:engine_array_safety", + "//src/render:glad", + ], +) + +cc_library( + name = "render_gl3", + srcs = ["render_gl3.c"], + hdrs = ["render_gl3.h"], + copts = [ + "-Isrc", + ], + local_defines = [ + "_GNU_SOURCE", + "mjUSEPLATFORMSIMD", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":glad", + ":render_context", + ":render_gl2", + ":render_util", + "//:mujoco_hdrs", + "//src/engine", + "//src/engine:engine_crossplatform", + "//src/engine:engine_vis_init", + ], +) + +cc_library( + name = "render_util", + srcs = ["render_util.c"], + hdrs = ["render_util.h"], + copts = [ + "-Isrc", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + "//:mujoco_hdrs", + "//src/render:glad", + ], +) diff --git a/src/thread/BUILD.bazel b/src/thread/BUILD.bazel new file mode 100644 index 0000000000..45b5ad806c --- /dev/null +++ b/src/thread/BUILD.bazel @@ -0,0 +1,40 @@ +# Threading library for MuJoCo. +licenses(["notice"]) + +package(default_visibility = ["@mujoco//:__subpackages__"]) + +cc_library( + name = "thread_queue", + hdrs = ["thread_queue.h"], + target_compatible_with = ["@platforms//os:linux"], +) + +cc_library( + name = "thread_task", + srcs = ["thread_task.cc"], + hdrs = ["thread_task.h"], + copts = [ + "-Isrc", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = ["//:mujoco_hdrs"], +) + +cc_library( + name = "thread_pool", + srcs = ["thread_pool.cc"], + hdrs = ["thread_pool.h"], + copts = [ + "-Wno-unknown-pragmas", + "-Wno-error=unknown-pragmas", + "-Isrc", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":thread_queue", + ":thread_task", + "//:mujoco_hdrs", + "//src/engine:engine_crossplatform", + "//src/engine:engine_util_errmem", + ], +) diff --git a/src/ui/BUILD.bazel b/src/ui/BUILD.bazel new file mode 100644 index 0000000000..70f153572d --- /dev/null +++ b/src/ui/BUILD.bazel @@ -0,0 +1,16 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +cc_library( + name = "ui_main", + srcs = ["ui_main.c"], + hdrs = ["ui_main.h"], + copts = [ + "-Isrc", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + "//:mujoco_hdrs", + "//src/engine:engine_array_safety", + "//src/render:glad", + ], +) diff --git a/src/user/BUILD.bazel b/src/user/BUILD.bazel new file mode 100644 index 0000000000..8ab460a0e5 --- /dev/null +++ b/src/user/BUILD.bazel @@ -0,0 +1,166 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +cc_library( + name = "user_flexcomp", + srcs = ["user_flexcomp.cc"], + hdrs = ["user_flexcomp.h"], + copts = [ + "-Wno-unknown-pragmas", + "-Wno-error=unknown-pragmas", + "-Wno-type-limits", + "-Wno-sign-compare", + "-fexceptions", + "-Isrc", + ], + features = ["-use_header_modules"], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":user_model", + ":user_util", + "//:mujoco_hdrs", + "//src/cc:array_safety", + "//src/engine:engine_crossplatform", + "//src/engine:engine_util_errmem", + "//src/user:user_resource", + ], +) + +cc_library( + name = "user_composite", + srcs = ["user_composite.cc"], + hdrs = ["user_composite.h"], + copts = [ + "-Wno-unknown-pragmas", + "-Wno-error=unknown-pragmas", + "-Wno-sign-compare", + "-fexceptions", + "-Isrc", + ], + features = ["-use_header_modules"], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":user_model", + ":user_util", + "//:mujoco_hdrs", + "//src/cc:array_safety", + "//src/engine:engine_io", + "//src/engine:engine_util_errmem", + "//src/engine:engine_util_misc", + ], +) + +cc_library( + name = "user_model", + srcs = [ + "user_api.cc", + "user_init.c", + "user_mesh.cc", + "user_model.cc", + "user_objects.cc", + ], + hdrs = [ + "user_api.h", + "user_model.h", + "user_objects.h", + ], + copts = [ + "-Wno-unknown-pragmas", + "-Wno-error=unknown-pragmas", + "-Wno-sign-compare", + "-fexceptions", + "-Isrc", + "-Iexternal/qhull/src/libqhull_r", + ] + select({ + "//tools:gcc": [ + "-Wno-maybe-uninitialized", + ], + "//conditions:default": [], + }), + features = ["-use_header_modules"], + local_defines = [ + "_GNU_SOURCE", + "MUJOCO_TINYOBJLOADER_IMPL", + "MC_IMPLEM_ENABLE", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":user_cache", + ":user_resource", + ":user_util", + "//:mujoco_hdrs", + "//src/cc:array_safety", + "//src/engine", + "//src/engine:engine_crossplatform", + "//src/engine:engine_io", + "//src/engine:engine_name", + "//src/engine:engine_plugin", + "//src/engine:engine_util_errmem", + "//src/engine:engine_util_misc", + "@MarchingCubeCpp", + "@lodepng", + "@qhull//:libqhull_r", + "@tinyobjloader", + ], +) + +cc_library( + name = "user_util", + srcs = ["user_util.cc"], + hdrs = ["user_util.h"], + copts = [ + "-Wno-sign-compare", + "-Isrc", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + "//:mujoco_hdrs", + "//src/engine:engine_crossplatform", + ], +) + +cc_library( + name = "user_cache", + srcs = ["user_cache.cc"], + hdrs = ["user_cache.h"], + copts = [ + "-Isrc", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":user_resource", + "//:mujoco_hdrs", + ], +) + +cc_library( + name = "user_resource", + srcs = ["user_resource.cc"], + hdrs = ["user_resource.h"], + copts = [ + "-Wshadow", + "-Isrc", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":user_util", + ":user_vfs", + "//:mujoco_hdrs", + "//src/engine:engine_plugin", + "//src/engine:engine_util_misc", + ], +) + +cc_library( + name = "user_vfs", + srcs = ["user_vfs.cc"], + hdrs = ["user_vfs.h"], + copts = [ + "-Isrc", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":user_util", + "//:mujoco_hdrs", + "//src/engine:engine_util_misc", + ], +) diff --git a/src/xml/BUILD.bazel b/src/xml/BUILD.bazel new file mode 100644 index 0000000000..44a65ee66f --- /dev/null +++ b/src/xml/BUILD.bazel @@ -0,0 +1,186 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +exports_files(["xml_native_reader.cc"]) + +cc_library( + name = "xml", + srcs = ["xml.cc"], + hdrs = ["xml.h"], + copts = [ + "-fexceptions", + "-Isrc", + ], + features = ["-use_header_modules"], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":xml_native_reader", + ":xml_native_writer", + ":xml_urdf", + ":xml_util", + "//:mujoco_hdrs", + "//src/cc:array_safety", + "//src/engine:engine_crossplatform", + "//src/user:user_resource", + "//src/user:user_util", + "//src/user:user_vfs", + "@tinyxml2", + ], +) + +cc_library( + name = "xml_api", + srcs = ["xml_api.cc"], + hdrs = ["xml_api.h"], + copts = [ + "-Wno-sign-compare", + "-Isrc", + ] + select({ + "//tools:gcc": [ + "-Wno-maybe-uninitialized", + ], + "//conditions:default": [], + }), + features = ["-use_header_modules"], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":xml", + ":xml_native_reader", + ":xml_util", + "//:mujoco_hdrs", + "//src/engine:engine_io", + "//src/user:user_resource", + "//src/user:user_vfs", + ], +) + +cc_library( + name = "xml_base", + srcs = ["xml_base.cc"], + hdrs = ["xml_base.h"], + copts = [ + "-fexceptions", + "-Isrc", + ], + features = ["-use_header_modules"], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":xml_util", + "//:mujoco_hdrs", + "@tinyxml2", + ], +) + +cc_library( + name = "xml_native_reader", + srcs = ["xml_native_reader.cc"], + hdrs = ["xml_native_reader.h"], + copts = [ + "-Wno-sign-compare", + "-Wno-unknown-pragmas", + "-Wno-error=unknown-pragmas", + "-fexceptions", + "-Isrc", + ], + features = ["-use_header_modules"], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":xml_base", + ":xml_util", + "//:mujoco_hdrs", + "//src/engine:engine_plugin", + "//src/engine:engine_util_errmem", + "//src/engine:engine_util_misc", + "//src/user:user_composite", + "//src/user:user_flexcomp", + "//src/user:user_model", + "//src/user:user_util", + "@tinyxml2", + ], +) + +cc_library( + name = "xml_native_writer", + srcs = ["xml_native_writer.cc"], + hdrs = ["xml_native_writer.h"], + copts = [ + "-Wno-sign-compare", + "-Wno-unknown-pragmas", + "-Wno-error=unknown-pragmas", + "-fexceptions", + "-Isrc", + ], + features = ["-use_header_modules"], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":xml_base", + ":xml_util", + "//:mujoco_hdrs", + "//src/engine:engine_io", + "//src/engine:engine_plugin", + "//src/engine:engine_util_errmem", + "//src/engine:engine_util_misc", + "//src/user:user_model", + "//src/user:user_util", + "@tinyxml2", + ], +) + +cc_library( + name = "xml_urdf", + srcs = ["xml_urdf.cc"], + hdrs = ["xml_urdf.h"], + copts = [ + "-Wno-sign-compare", + "-fexceptions", + "-Isrc", + ], + features = ["-use_header_modules"], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":xml_base", + ":xml_native_reader", + ":xml_util", + "//:mujoco_hdrs", + "//src/user:user_model", + "//src/user:user_util", + "@tinyxml2", + ], +) + +cc_library( + name = "xml_util", + srcs = ["xml_util.cc"], + hdrs = ["xml_util.h"], + copts = [ + "-Wno-sign-compare", + "-Wno-unknown-pragmas", + "-Wno-error=unknown-pragmas", + "-fexceptions", + "-Isrc", + ], + features = ["-use_header_modules"], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + ":xml_numeric_format", + "//:mujoco_hdrs", + "//src/cc:array_safety", + "//src/engine:engine_util_errmem", + "//src/user:user_resource", + "//src/user:user_util", + "@tinyxml2", + ], +) + +cc_library( + name = "xml_numeric_format", + srcs = ["xml_numeric_format.cc"], + hdrs = ["xml_numeric_format.h"], + copts = [ + "-Isrc", + ], + target_compatible_with = ["@platforms//os:linux"], + deps = [ + "//:mujoco_hdrs", + "@tinyxml2", + ], +) diff --git a/test/BUILD.bazel b/test/BUILD.bazel new file mode 100644 index 0000000000..ae55b1c2c2 --- /dev/null +++ b/test/BUILD.bazel @@ -0,0 +1,58 @@ +package(default_visibility = ["@mujoco//test:__subpackages__"]) + +cc_library( + name = "fixture", + testonly = True, + srcs = ["fixture.cc"], + hdrs = ["fixture.h"], + copts = [ + "-Wno-sign-compare", + ], + deps = [ + "//:mujoco", + "//plugin/actuator:register", + "//plugin/elasticity:register", + "//plugin/sdf:register", + "//plugin/sensor:touch_grid", + "@abseil-cpp//absl/base:core_headers", + "@abseil-cpp//absl/container:flat_hash_map", + "@abseil-cpp//absl/container:flat_hash_set", + "@abseil-cpp//absl/strings", + "@abseil-cpp//absl/synchronization", + "@googletest//:gtest", + "@spdlog", + ], +) + +cc_test( + name = "fixture_test", + size = "small", + srcs = ["fixture_test.cc"], + deps = [ + ":fixture", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "header_test", + size = "small", + srcs = ["header_test.cc"], + deps = [ + ":fixture", + "@googletest//:gtest_main", + ], +) + +cc_test( + name = "pipeline_test", + size = "small", + srcs = ["pipeline_test.cc"], + data = [ + "//:test_data_stripped", + ], + deps = [ + ":fixture", + "@googletest//:gtest_main", + ], +) diff --git a/test/benchmark/BUILD.bazel b/test/benchmark/BUILD.bazel new file mode 100644 index 0000000000..0a248d6053 --- /dev/null +++ b/test/benchmark/BUILD.bazel @@ -0,0 +1,34 @@ +names = [ + "step_benchmark_test", + "parse_benchmark_test", + "engine_util_spatial_benchmark_test", + "engine_core_smooth_benchmark_test", + "engine_util_sparse_benchmark_test", +] + +[ + cc_test( + name = name, + srcs = ["{}.cc".format(name)], + data = [ + "//:model_data", + "//:test_benchmark_data", + "//:test_benchmark_data_stripped", + "//:test_plugin_data", + ], + tags = ["manual"], + deps = [ + "//plugin/elasticity:register", + "//test:fixture", + "@abseil-cpp//absl/base:core_headers", + "@google_benchmark//:benchmark_main", + ], + ) + for name in names +] + +test_suite( + name = "benchmark_tests", + tags = ["manual"], + tests = [name for name in names], +) diff --git a/test/benchmark/testdata/BUILD.bazel b/test/benchmark/testdata/BUILD.bazel new file mode 100644 index 0000000000..dce14c2cf1 --- /dev/null +++ b/test/benchmark/testdata/BUILD.bazel @@ -0,0 +1,6 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +filegroup( + name = "model", + srcs = glob(["*.xml"]), +) diff --git a/test/engine/BUILD.bazel b/test/engine/BUILD.bazel new file mode 100644 index 0000000000..d1f0a22b28 --- /dev/null +++ b/test/engine/BUILD.bazel @@ -0,0 +1,59 @@ +load("//test:helper.bzl", "PLUGIN_DIR") + +cc_test( + name = "engine_test", + size = "small", + srcs = [ + "engine_collision_box_test.cc", + "engine_collision_convex_test.cc", + "engine_collision_driver_test.cc", + "engine_collision_gjk_test.cc", + "engine_collision_sdf_test.cc", + "engine_core_constraint_test.cc", + "engine_core_smooth_test.cc", + "engine_derivative_test.cc", + "engine_forward_test.cc", + "engine_inverse_test.cc", + "engine_io_test.cc", + "engine_island_test.cc", + "engine_passive_test.cc", + "engine_plugin_test.cc", + "engine_print_test.cc", + "engine_ray_test.cc", + "engine_sensor_test.cc", + "engine_solver_test.cc", + "engine_support_test.cc", + "engine_thread_test.cc", + "engine_util_blas_test.cc", + "engine_util_container_test.cc", + "engine_util_errmem_test.cc", + "engine_util_misc_test.cc", + "engine_util_solve_test.cc", + "engine_util_sparse_test.cc", + "engine_util_spatial_test.cc", + "engine_vis_state_test.cc", + ], + copts = [ + "-Wno-dangling-else", + "-Wno-unknown-pragmas", + "-Wno-unused-function", + "-Wno-sign-compare", + "-Isrc", + ] + select({ + "//tools:gcc": [ + "-Wno-maybe-uninitialized", + ], + "//conditions:default": [], + }), + data = [ + "//:model_data", + "//:test_data_stripped", + "//:test_engine_data_stripped", + ], + env = PLUGIN_DIR, + deps = [ + "//src/engine:engine_util_container", + "//test:fixture", + "@googletest//:gtest_main", + ], +) diff --git a/test/engine/testdata/BUILD.bazel b/test/engine/testdata/BUILD.bazel new file mode 100644 index 0000000000..0da22a1f22 --- /dev/null +++ b/test/engine/testdata/BUILD.bazel @@ -0,0 +1,9 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +filegroup( + name = "model", + srcs = glob([ + "**/*.xml", + "**/*.obj", + ]), +) diff --git a/test/fixture.cc b/test/fixture.cc index 545691b495..82d8427002 100644 --- a/test/fixture.cc +++ b/test/fixture.cc @@ -80,7 +80,13 @@ const std::string GetTestDataFilePath(std::string_view path) { // NOLINT } const std::string GetModelPath(std::string_view path) { // NOLINT - return absl::StrCat("../model/", path); + // Bazel can only create symlinks for files under the `TEST_NAME.runfiles/mujoco` directory. + const char* bazel_env = std::getenv("BAZEL_TEST"); + if (bazel_env != nullptr) { + return absl::StrCat("model/", path); + } else { + return absl::StrCat("../model/", path); + } } mjModel* LoadModelFromString(std::string_view xml, char* error, diff --git a/test/helper.bzl b/test/helper.bzl new file mode 100644 index 0000000000..48e41cde74 --- /dev/null +++ b/test/helper.bzl @@ -0,0 +1,3 @@ +PLUGIN_DIR = { + "MUJOCO_PLUGIN_DIR": "mujoco_plugin", +} diff --git a/test/plugin/actuator/BUILD.bazel b/test/plugin/actuator/BUILD.bazel new file mode 100644 index 0000000000..e919c62311 --- /dev/null +++ b/test/plugin/actuator/BUILD.bazel @@ -0,0 +1,15 @@ +load("//test:helper.bzl", "PLUGIN_DIR") + +cc_test( + name = "pid_test", + size = "small", + srcs = ["pid_test.cc"], + env = PLUGIN_DIR, + deps = [ + "//test:fixture", + "@abseil-cpp//absl/cleanup", + "@abseil-cpp//absl/strings", + "@abseil-cpp//absl/strings:string_view", + "@googletest//:gtest_main", + ], +) diff --git a/test/plugin/elasticity/BUILD.bazel b/test/plugin/elasticity/BUILD.bazel new file mode 100644 index 0000000000..8d87aaa036 --- /dev/null +++ b/test/plugin/elasticity/BUILD.bazel @@ -0,0 +1,20 @@ +load("//test:helper.bzl", "PLUGIN_DIR") + +cc_test( + name = "elasticity_test", + size = "small", + srcs = ["elasticity_test.cc"], + copts = [ + "-Wno-sign-compare", + ], + env = PLUGIN_DIR, + deps = [ + "//plugin/elasticity:register", + "//plugin/elasticity:shell", + "//test:fixture", + "@abseil-cpp//absl/cleanup", + "@abseil-cpp//absl/strings", + "@abseil-cpp//absl/strings:string_view", + "@googletest//:gtest_main", + ], +) diff --git a/test/plugin/sensor/BUILD.bazel b/test/plugin/sensor/BUILD.bazel new file mode 100644 index 0000000000..3a81b937fb --- /dev/null +++ b/test/plugin/sensor/BUILD.bazel @@ -0,0 +1,13 @@ +cc_test( + name = "sensor_test", + size = "small", + srcs = ["sensor_test.cc"], + data = [ + "//:test_plugin_data", + ], + deps = [ + "//plugin/sensor:touch_grid", + "//test:fixture", + "@googletest//:gtest_main", + ], +) diff --git a/test/plugin/sensor/testdata/BUILD.bazel b/test/plugin/sensor/testdata/BUILD.bazel new file mode 100644 index 0000000000..dce14c2cf1 --- /dev/null +++ b/test/plugin/sensor/testdata/BUILD.bazel @@ -0,0 +1,6 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +filegroup( + name = "model", + srcs = glob(["*.xml"]), +) diff --git a/test/testdata/BUILD.bazel b/test/testdata/BUILD.bazel new file mode 100644 index 0000000000..dce14c2cf1 --- /dev/null +++ b/test/testdata/BUILD.bazel @@ -0,0 +1,6 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +filegroup( + name = "model", + srcs = glob(["*.xml"]), +) diff --git a/test/thread/BUILD.bazel b/test/thread/BUILD.bazel new file mode 100644 index 0000000000..a60b323e8c --- /dev/null +++ b/test/thread/BUILD.bazel @@ -0,0 +1,16 @@ +cc_test( + name = "thread_test", + size = "small", + srcs = [ + "thread_pool_test.cc", + "thread_queue_test.cc", + ], + copts = [ + "-Wno-sign-compare", + ], + deps = [ + "//src/engine:engine_util_container", + "//test:fixture", + "@googletest//:gtest_main", + ], +) diff --git a/test/user/BUILD.bazel b/test/user/BUILD.bazel new file mode 100644 index 0000000000..4c5e2161bd --- /dev/null +++ b/test/user/BUILD.bazel @@ -0,0 +1,40 @@ +load("//test:helper.bzl", "PLUGIN_DIR") + +cc_test( + name = "user_test", + size = "large", # user_api_test.cc takes a long time + srcs = [ + "user_api_test.cc", + "user_cache_test.cc", + "user_composite_test.cc", + "user_flex_test.cc", + "user_model_test.cc", + "user_objects_test.cc", + "user_resource_test.cc", + "user_util_test.cc", + "user_vfs_test.cc", + ], + copts = [ + "-Wno-sign-compare", + "-Wno-write-strings", + ] + select({ + "//tools:gcc": [ + "-Wno-maybe-uninitialized", + ], + "//conditions:default": [], + }), + data = [ + "//:model_data", + "//:test_engine_data_stripped", + "//:test_user_data", + ], + env = PLUGIN_DIR, + deps = [ + "//src/user:user_cache", + "//src/user:user_resource", + "//src/user:user_util", + "//src/user:user_vfs", + "//test:fixture", + "@googletest//:gtest_main", + ], +) diff --git a/test/user/testdata/BUILD.bazel b/test/user/testdata/BUILD.bazel new file mode 100644 index 0000000000..6ac1c13d43 --- /dev/null +++ b/test/user/testdata/BUILD.bazel @@ -0,0 +1,12 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +filegroup( + name = "model", + srcs = glob([ + "**/*.xml", + "**/*.obj", + "**/*.stl", + "**/*.msh", + "**/*.png", + ]), +) diff --git a/test/user/user_cache_test.cc b/test/user/user_cache_test.cc index f226827bd1..80727e128c 100644 --- a/test/user/user_cache_test.cc +++ b/test/user/user_cache_test.cc @@ -38,9 +38,9 @@ using CacheTest = MujocoTest; namespace { constexpr int kMaxSize = 100; // in bytes -constexpr std::string kText = "Hello World"; -constexpr std::string kModel = "myModel"; -constexpr std::string kFile = "hello.txt"; +const std::string kText = "Hello World"; +const std::string kModel = "myModel"; +const std::string kFile = "hello.txt"; void CacheText(mjCCache& cache, const std::string& model, const std::string& name, const std::string& text) { diff --git a/test/user/user_util_test.cc b/test/user/user_util_test.cc index 9873c74ba7..a5b92a64a8 100644 --- a/test/user/user_util_test.cc +++ b/test/user/user_util_test.cc @@ -147,7 +147,7 @@ TEST_F(UserUtilTest, StringToVectorInt) { } TEST_F(UserUtilTest, StringToVectorString) { - auto v = StringToVector(" abc def "); + auto v = StringToVector(std::string(" abc def ")); EXPECT_THAT(v, ElementsAre("abc", "def")); } diff --git a/test/xml/BUILD.bazel b/test/xml/BUILD.bazel new file mode 100644 index 0000000000..3e2689e46e --- /dev/null +++ b/test/xml/BUILD.bazel @@ -0,0 +1,37 @@ +load("//test:helper.bzl", "PLUGIN_DIR") + +cc_test( + name = "xml_test", + size = "medium", # xml_native_writer_test.cc takes a long time. + srcs = [ + "xml_api_test.cc", + "xml_native_reader_test.cc", + "xml_native_writer_test.cc", + "xml_schema_test.cc", + "xml_urdf_test.cc", + ], + copts = [ + "-Wno-unknown-pragmas", + "-Wno-sign-compare", + "-Isrc", + ] + select({ + "//tools:gcc": [ + "-Wno-maybe-uninitialized", + ], + "//conditions:default": [], + }), + data = [ + "//:model_data", + "//:test_xml_data", + ], + env = PLUGIN_DIR, + deps = [ + "//src/xml:xml_api", + "//src/xml:xml_native_reader", + "//src/xml:xml_util", + "//test:fixture", + "@abseil-cpp//absl/strings", + "@abseil-cpp//absl/strings:str_format", + "@googletest//:gtest_main", + ], +) diff --git a/test/xml/testdata/BUILD.bazel b/test/xml/testdata/BUILD.bazel new file mode 100644 index 0000000000..8c53198ba5 --- /dev/null +++ b/test/xml/testdata/BUILD.bazel @@ -0,0 +1,6 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +filegroup( + name = "model", + srcs = glob(["**/*.xml"]), +) diff --git a/tools/BUILD.bazel b/tools/BUILD.bazel new file mode 100644 index 0000000000..3680e805c2 --- /dev/null +++ b/tools/BUILD.bazel @@ -0,0 +1,34 @@ +constraint_setting( + name = "compiler", + default_constraint_value = "clang", +) + +constraint_value( + name = "clang", + constraint_setting = ":compiler", + visibility = ["//visibility:public"], +) + +constraint_value( + name = "gcc", + constraint_setting = ":compiler", + visibility = ["//visibility:public"], +) + +platform( + name = "linux_clang_x86_64", + constraint_values = [ + ":clang", + "@platforms//os:linux", + "@platforms//cpu:x86_64", + ], +) + +platform( + name = "linux_gcc_x86_64", + constraint_values = [ + ":gcc", + "@platforms//os:linux", + "@platforms//cpu:x86_64", + ], +) diff --git a/tools/symlink_files.bzl b/tools/symlink_files.bzl new file mode 100644 index 0000000000..a4fc380764 --- /dev/null +++ b/tools/symlink_files.bzl @@ -0,0 +1,36 @@ +load("@aspect_bazel_lib//lib:paths.bzl", "to_repository_relative_path") + +_symlink_files_attrs = { + "srcs": attr.label_list( + allow_files = True, + doc = "A list of input files for which symbolic links will be created.", + ), + "strip_prefix": attr.string( + doc = """This pecifies a prefix that, if matched at the beginning of each file’s path, will + be stripped from the file path.""", + ), +} + +def _symlink_files_impl(ctx): + outputs = [] + for src in ctx.files.srcs: + workspace_relpath = to_repository_relative_path(src) + if workspace_relpath.startswith(ctx.attr.strip_prefix): + workspace_relpath = workspace_relpath[len(ctx.attr.strip_prefix):] + link = ctx.actions.declare_file(workspace_relpath) + ctx.actions.symlink(output = link, target_file = src) + outputs.append(link) + + return [ + DefaultInfo( + files = depset(outputs), + runfiles = ctx.runfiles(outputs), + ), + ] + +symlink_files = rule( + doc = "Symlink files to the output directory.", + implementation = _symlink_files_impl, + attrs = _symlink_files_attrs, + provides = [DefaultInfo], +) diff --git a/tools/workspace/BUILD.bazel b/tools/workspace/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/workspace/MarchingCubeCpp/BUILD.bazel b/tools/workspace/MarchingCubeCpp/BUILD.bazel new file mode 100644 index 0000000000..8ef196cd85 --- /dev/null +++ b/tools/workspace/MarchingCubeCpp/BUILD.bazel @@ -0,0 +1 @@ +exports_files(["LICENSE"]) diff --git a/tools/workspace/MarchingCubeCpp/LICENSE b/tools/workspace/MarchingCubeCpp/LICENSE new file mode 100644 index 0000000000..f957d8f6b2 --- /dev/null +++ b/tools/workspace/MarchingCubeCpp/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2020 Axel Paris + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/workspace/MarchingCubeCpp/package.BUILD.bazel b/tools/workspace/MarchingCubeCpp/package.BUILD.bazel new file mode 100644 index 0000000000..3d2bd3e50d --- /dev/null +++ b/tools/workspace/MarchingCubeCpp/package.BUILD.bazel @@ -0,0 +1,19 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +cc_library( + name = "MarchingCubeCpp", + hdrs = ["MC.h"], + includes = ["."], + data = [":license_filegroup"], +) + +filegroup( + name = "license_filegroup", + srcs = [ + # The MarchingCubeCpp repository is MIT-licensed but does not provide an official LICENSE + # file. Therefore, we include the `LICENSE` file here in the MuJoCo repository and + # reference it accordingly. See https://github.com/aparis69/MarchingCubeCpp#licence. + "@mujoco//tools/workspace/MarchingCubeCpp:LICENSE", + ], + tags = ["license_filegroup"], +) diff --git a/tools/workspace/MarchingCubeCpp/repository.bzl b/tools/workspace/MarchingCubeCpp/repository.bzl new file mode 100644 index 0000000000..e39720a65e --- /dev/null +++ b/tools/workspace/MarchingCubeCpp/repository.bzl @@ -0,0 +1,11 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def MarchingCubeCpp_repository(name = "MarchingCubeCpp"): + commit = "f03a1b3ec29b1d7d865691ca8aea4f1eb2c2873d" + http_archive( + name = name, + sha256 = "227c10b2cffe886454b92a0e9ef9f0c9e8e001d00ea156cc37c8fc43055c9ca6", + strip_prefix = "MarchingCubeCpp-{}".format(commit), + build_file = "@mujoco//tools/workspace/MarchingCubeCpp:package.BUILD.bazel", + url = "https://github.com/aparis69/MarchingCubeCpp/archive/{}.tar.gz".format(commit), + ) diff --git a/tools/workspace/SdfLib/BUILD.bazel b/tools/workspace/SdfLib/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/workspace/SdfLib/package.BUILD.bazel b/tools/workspace/SdfLib/package.BUILD.bazel new file mode 100644 index 0000000000..cb62b7b6bc --- /dev/null +++ b/tools/workspace/SdfLib/package.BUILD.bazel @@ -0,0 +1,42 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +cc_library( + name = "SdfLib", + srcs = glob([ + "src/sdf/*.cpp", + "src/utils/*.cpp", + ]), + hdrs = glob([ + "src/sdf/*.h", + "include/SdfLib/*.h", + "include/SdfLib/utils/*.h", + "libs/InteractiveComputerGraphics/InteractiveComputerGraphics/TriangleMeshDistance.h", + ]), + deps = [ + "@glm", + "@cereal", + "@spdlog", + ], + includes = [ + "include", + "libs/InteractiveComputerGraphics", + "src", + ], + copts = [ + "-Wno-error=switch", + "-Wno-switch", + "-Wno-sign-compare", + "-Wno-unused-variable", + "-Wno-unused-lambda-capture", + "-Wno-pessimizing-move", + ], + data = [":license_filegroup"], +) + +filegroup( + name = "license_filegroup", + srcs = [ + "LICENSE", + ], + tags = ["license_filegroup"], +) diff --git a/tools/workspace/SdfLib/repository.bzl b/tools/workspace/SdfLib/repository.bzl new file mode 100644 index 0000000000..aa244ad535 --- /dev/null +++ b/tools/workspace/SdfLib/repository.bzl @@ -0,0 +1,11 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def SdfLib_repository(name = "SdfLib"): + commit = "1927bee6bb8225258a39c8cbf14e18a4d50409ae" + http_archive( + name = name, + sha256 = "ff6081954d05041f5f583be69dfc9749a71030d8da64b4b9a7576350911b806a", + strip_prefix = "SdfLib-{}".format(commit), + build_file = "@mujoco//tools/workspace/SdfLib:package.BUILD.bazel", + url = "https://github.com/UPC-ViRVIG/SdfLib/archive/{}.tar.gz".format(commit), + ) diff --git a/tools/workspace/abseil-cpp/BUILD.bazel b/tools/workspace/abseil-cpp/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/workspace/abseil-cpp/repository.bzl b/tools/workspace/abseil-cpp/repository.bzl new file mode 100644 index 0000000000..25afc57e00 --- /dev/null +++ b/tools/workspace/abseil-cpp/repository.bzl @@ -0,0 +1,10 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def abseil_cpp_repository(name = "abseil-cpp"): + version = "20240722.0" + http_archive( + name = name, + sha256 = "f50e5ac311a81382da7fa75b97310e4b9006474f9560ac46f54a9967f07d4ae3", + strip_prefix = "abseil-cpp-{}".format(version), + url = "https://github.com/abseil/abseil-cpp/releases/download/{}/abseil-cpp-{}.tar.gz".format(version, version), + ) diff --git a/tools/workspace/aspect_bazel_lib/BUILD.bazel b/tools/workspace/aspect_bazel_lib/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/workspace/aspect_bazel_lib/repository.bzl b/tools/workspace/aspect_bazel_lib/repository.bzl new file mode 100644 index 0000000000..d46b8092f1 --- /dev/null +++ b/tools/workspace/aspect_bazel_lib/repository.bzl @@ -0,0 +1,10 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def aspect_bazel_lib_repository(name = "aspect_bazel_lib"): + version = "2.9.3" + http_archive( + name = name, + sha256 = "a272d79bb0ac6b6965aa199b1f84333413452e87f043b53eca7f347a23a478e8", + strip_prefix = "bazel-lib-{}".format(version), + url = "https://github.com/bazel-contrib/bazel-lib/releases/download/v{}/bazel-lib-v{}.tar.gz".format(version, version), + ) diff --git a/tools/workspace/cereal/BUILD.bazel b/tools/workspace/cereal/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/workspace/cereal/package.BUILD.bazel b/tools/workspace/cereal/package.BUILD.bazel new file mode 100644 index 0000000000..cce20c8ff6 --- /dev/null +++ b/tools/workspace/cereal/package.BUILD.bazel @@ -0,0 +1,23 @@ +package(default_visibility = [ + "@mujoco//:__subpackages__", + "@SdfLib//:__subpackages__", +]) + +cc_library( + name = "cereal", + hdrs = glob([ + "include/**/*.hpp", + ]), + includes = [ + "include", + ], + data = [":license_filegroup"], +) + +filegroup( + name = "license_filegroup", + srcs = [ + "LICENSE", + ], + tags = ["license_filegroup"], +) diff --git a/tools/workspace/cereal/repository.bzl b/tools/workspace/cereal/repository.bzl new file mode 100644 index 0000000000..e4f9643f62 --- /dev/null +++ b/tools/workspace/cereal/repository.bzl @@ -0,0 +1,11 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def cereal_repository(name = "cereal"): + commit = "ebef1e929807629befafbb2918ea1a08c7194554" + http_archive( + name = name, + sha256 = "ce52ae6abcdbda5fecd63abbaa7ab57e54b814b24d7cb6f5096f5753d1975d24", + strip_prefix = "cereal-{}".format(commit), + build_file = "@mujoco//tools/workspace/cereal:package.BUILD.bazel", + url = "https://github.com/USCiLab/cereal/archive/{}.tar.gz".format(commit), + ) diff --git a/tools/workspace/deb_archive.bzl b/tools/workspace/deb_archive.bzl new file mode 100644 index 0000000000..627eb2306b --- /dev/null +++ b/tools/workspace/deb_archive.bzl @@ -0,0 +1,71 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file") +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "workspace_and_buildfile") + +def _deb_archive_impl(ctx): + for src in ctx.attr.srcs: + ctx.extract(src) + workspace_and_buildfile(ctx) + +deb_archive = repository_rule( + doc = """The deb_archive repository rule extracts .deb archive files, allowing to incorporate + files from Debian packages into your Bazel workspace.""", + implementation = _deb_archive_impl, + attrs = { + "srcs": attr.label_list( + mandatory = True, + allow_empty = False, + doc = "A list of .deb package files to extract.", + ), + "build_file": attr.label( + allow_single_file = True, + doc = """ A file containing BUILD definitions. This BUILD file will be placed in the + root of the extracted repository and allows you to define Bazel targets based on + the extracted contents.""", + ), + "build_file_content": attr.string( + doc = "Optional inline BUILD.bazel file content", + ), + "workspace_file": attr.label( + allow_single_file = True, + doc = """A file containing WORKSPACE definitions, which will be added to the + repository’s root.""", + ), + "workspace_file_content": attr.string( + doc = "Optional inline WORKSPACE file content", + ), + }, +) + +def deb_package(name, urls, sha256s, data_archives = [], **kwargs): + """ + This function downloads `.deb` file from the URLs, extracts the specified data archives, and + invokes the `deb_archive` rule to handle extraction and setup within Bazel workspace. + + Args: + name (string): The name of the Bazel target created for this package. + urls (list of strings): A list of URLs pointing to the .deb packages you want to download + and extract. Each URL should point directly to a downloadable .deb file. + sha256s (list of strings): A list of SHA-256 hashes corresponding to each URL in `urls`. + data_archives (list of string): Specifies the names of the data archive files within each + `.deb` package that you want to extract. + **kwargs: Additional arguments passed to the underlying deb_archive rule. + """ + if not data_archives: + data_archives = ["data.tar.zst"] * len(urls) + srcs = [] + for (url, sha256, data_archive) in zip(urls, sha256s, data_archives): + _, sep, ext = url.rpartition(".") + src_name = name + "_" + sha256 + http_archive( + name = src_name, + url = url, + sha256 = sha256, + build_file_content = """exports_files(["{}"])""".format(data_archive), + ) + srcs.append("@{}//:{}".format(src_name, data_archive)) + + deb_archive( + name = name, + srcs = srcs, + **kwargs + ) diff --git a/tools/workspace/default_dependencies.bzl b/tools/workspace/default_dependencies.bzl new file mode 100644 index 0000000000..d8b7d522cf --- /dev/null +++ b/tools/workspace/default_dependencies.bzl @@ -0,0 +1,8 @@ +load("@rules_python//python:repositories.bzl", "py_repositories") +load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies") + +def add_default_dependencies(excludes = []): + if "rules_python" not in excludes: + py_repositories() + if "aspect_bazel_lib" not in excludes: + aspect_bazel_lib_dependencies() diff --git a/tools/workspace/default_repositories.bzl b/tools/workspace/default_repositories.bzl new file mode 100644 index 0000000000..3a4134f204 --- /dev/null +++ b/tools/workspace/default_repositories.bzl @@ -0,0 +1,62 @@ +load("@mujoco//tools/workspace/MarchingCubeCpp:repository.bzl", "MarchingCubeCpp_repository") +load("@mujoco//tools/workspace/cereal:repository.bzl", "cereal_repository") +load("@mujoco//tools/workspace/glm:repository.bzl", "glm_repository") +load("@mujoco//tools/workspace/libccd:repository.bzl", "libccd_repository") +load("@mujoco//tools/workspace/lodepng:repository.bzl", "lodepng_repository") +load("@mujoco//tools/workspace/SdfLib:repository.bzl", "SdfLib_repository") +load("@mujoco//tools/workspace/spdlog:repository.bzl", "spdlog_repository") +load("@mujoco//tools/workspace/tinyobjloader:repository.bzl", "tinyobjloader_repository") +load("@mujoco//tools/workspace/pybind11:repository.bzl", "pybind11_repository") +load("@mujoco//tools/workspace/rules_python:repository.bzl", "rules_python_repository") +load("@mujoco//tools/workspace/abseil-cpp:repository.bzl", "abseil_cpp_repository") +load("@mujoco//tools/workspace/qhull:repository.bzl", "qhull_repository") +load("@mujoco//tools/workspace/tinyxml2:repository.bzl", "tinyxml2_repository") +load("@mujoco//tools/workspace/libglvnd:repository.bzl", "libglvnd_repository") +load("@mujoco//tools/workspace/libglfw3:repository.bzl", "libglfw3_repository") +load("@mujoco//tools/workspace/googletest:repository.bzl", "googletest_repository") +load("@mujoco//tools/workspace/aspect_bazel_lib:repository.bzl", "aspect_bazel_lib_repository") +load("@mujoco//tools/workspace/google_benchmark:repository.bzl", "google_benchmark_repository") +load("@mujoco//tools/workspace/eigen:repository.bzl", "eigen_repository") +load("@mujoco//tools/workspace/fmt:repository.bzl", "fmt_repository") + +def add_default_repositories(excludes = []): + if "MarchingCubeCpp" not in excludes: + MarchingCubeCpp_repository(name = "MarchingCubeCpp") + if "cereal" not in excludes: + cereal_repository(name = "cereal") + if "glm" not in excludes: + glm_repository(name = "glm") + if "libccd" not in excludes: + libccd_repository(name = "libccd") + if "lodepng" not in excludes: + lodepng_repository(name = "lodepng") + if "SdfLib" not in excludes: + SdfLib_repository(name = "SdfLib") + if "spdlog" not in excludes: + spdlog_repository(name = "spdlog") + if "tinyobjloader" not in excludes: + tinyobjloader_repository(name = "tinyobjloader") + if "pybind11" not in excludes: + pybind11_repository(name = "pybind11") + if "rules_python" not in excludes: + rules_python_repository(name = "rules_python") + if "abseil-cpp" not in excludes: + abseil_cpp_repository(name = "abseil-cpp") + if "qhull" not in excludes: + qhull_repository(name = "qhull") + if "tinyxml2" not in excludes: + tinyxml2_repository(name = "tinyxml2") + if "libglvnd" not in excludes: + libglvnd_repository(name = "libglvnd") + if "libglfw3" not in excludes: + libglfw3_repository(name = "libglfw3") + if "googletest" not in excludes: + googletest_repository(name = "googletest") + if "aspect_bazel_lib" not in excludes: + aspect_bazel_lib_repository(name = "aspect_bazel_lib") + if "google_benchmark" not in excludes: + google_benchmark_repository(name = "google_benchmark") + if "eigen" not in excludes: + eigen_repository(name = "eigen") + if "fmt" not in excludes: + fmt_repository(name = "fmt") diff --git a/tools/workspace/eigen/BUILD.bazel b/tools/workspace/eigen/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/workspace/eigen/package.BUILD.bazel b/tools/workspace/eigen/package.BUILD.bazel new file mode 100644 index 0000000000..8261ecfc3d --- /dev/null +++ b/tools/workspace/eigen/package.BUILD.bazel @@ -0,0 +1,20 @@ +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "eigen", + hdrs = glob(["Eigen/**", "unsupported/Eigen/**"]), + includes = ["."], + data = [":license_filegroup"], +) + +filegroup( + name = "license_filegroup", + srcs = [ + "COPYING.APACHE", + "COPYING.BSD", + "COPYING.MINPACK", + "COPYING.MPL2", + "COPYING.README", + ], + tags = ["license_filegroup"], +) diff --git a/tools/workspace/eigen/repository.bzl b/tools/workspace/eigen/repository.bzl new file mode 100644 index 0000000000..e017caa528 --- /dev/null +++ b/tools/workspace/eigen/repository.bzl @@ -0,0 +1,11 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def eigen_repository(name = "eigen"): + commit = "33d0937c6bdf5ec999939fb17f2a553183d14a74" + http_archive( + name = name, + sha256 = "1a7c7d2e2052642acf78b32ef89dc5b6d12dcb8e552b66407c3e67d7f8e1d73e", + strip_prefix = "eigen-{}".format(commit), + build_file = "@mujoco//tools/workspace/eigen:package.BUILD.bazel", + url = "https://gitlab.com/libeigen/eigen/-/archive/{}/eigen-{}.tar.bz2".format(commit, commit), + ) diff --git a/tools/workspace/fmt/BUILD.bazel b/tools/workspace/fmt/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/workspace/fmt/package.BUILD b/tools/workspace/fmt/package.BUILD new file mode 100644 index 0000000000..5ea13b607c --- /dev/null +++ b/tools/workspace/fmt/package.BUILD @@ -0,0 +1,35 @@ +package(default_visibility = [ + "@mujoco//:__subpackages__", + "@spdlog//:__subpackages__", +]) + +cc_library( + name = "fmt", + srcs = [ + "src/format.cc", + "src/os.cc", + ], + hdrs = [ + "include/fmt/args.h", + "include/fmt/chrono.h", + "include/fmt/color.h", + "include/fmt/compile.h", + "include/fmt/core.h", + "include/fmt/format.h", + "include/fmt/format-inl.h", + "include/fmt/os.h", + "include/fmt/ostream.h", + "include/fmt/printf.h", + "include/fmt/ranges.h", + "include/fmt/std.h", + "include/fmt/xchar.h", + ], + data = [":license_filegroup"], + includes = ["include"], +) + +filegroup( + name = "license_filegroup", + srcs = ["LICENSE"], + tags = ["license_filegroup"], +) diff --git a/tools/workspace/fmt/repository.bzl b/tools/workspace/fmt/repository.bzl new file mode 100644 index 0000000000..67add95dc5 --- /dev/null +++ b/tools/workspace/fmt/repository.bzl @@ -0,0 +1,11 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def fmt_repository(name): + version = "10.2.1" + http_archive( + name = name, + strip_prefix = "fmt-{}".format(version), + sha256 = "1250e4cc58bf06ee631567523f48848dc4596133e163f02615c97f78bab6c811", + url = "https://github.com/fmtlib/fmt/archive/refs/tags/{}.tar.gz".format(version), + build_file = "@mujoco//tools/workspace/fmt:package.BUILD", + ) diff --git a/tools/workspace/glm/BUILD.bazel b/tools/workspace/glm/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/workspace/glm/package.BUILD.bazel b/tools/workspace/glm/package.BUILD.bazel new file mode 100644 index 0000000000..b60203cc23 --- /dev/null +++ b/tools/workspace/glm/package.BUILD.bazel @@ -0,0 +1,29 @@ +package(default_visibility = [ + "@mujoco//:__subpackages__", + "@SdfLib//:__subpackages__", +]) + +cc_library( + name = "glm", + hdrs = glob([ + "glm/*.hpp", + "glm/*.inl", + "glm/detail/*.hpp", + "glm/detail/*.inl", + "glm/gtc/*.hpp", + "glm/gtc/*.inl", + "glm/gtx/*.hpp", + "glm/gtx/*.inl", + "glm/simd/*.h", + ]), + data = [":license_filegroup"], + includes = ["."], +) + +filegroup( + name = "license_filegroup", + srcs = [ + "copying.txt", + ], + tags = ["license_filegroup"], +) diff --git a/tools/workspace/glm/repository.bzl b/tools/workspace/glm/repository.bzl new file mode 100644 index 0000000000..118cbaf8ee --- /dev/null +++ b/tools/workspace/glm/repository.bzl @@ -0,0 +1,11 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def glm_repository(name = "glm"): + commit = "454d480ceb4ac10ca76ac24b49836b7d5a35f786" + http_archive( + name = name, + sha256 = "ce6894e2bc38e5415a01827e23406776cd6d632c65e60fd2333b13621ab0ef43", + strip_prefix = "glm-{}".format(commit), + build_file = "@mujoco//tools/workspace/glm:package.BUILD.bazel", + url = "https://github.com/g-truc/glm/archive/{}.tar.gz".format(commit), + ) diff --git a/tools/workspace/google_benchmark/BUILD.bazel b/tools/workspace/google_benchmark/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/workspace/google_benchmark/repository.bzl b/tools/workspace/google_benchmark/repository.bzl new file mode 100644 index 0000000000..b131e8725d --- /dev/null +++ b/tools/workspace/google_benchmark/repository.bzl @@ -0,0 +1,10 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def google_benchmark_repository(name = "google_benchmark"): + version = "1.8.4" + http_archive( + name = name, + sha256 = "3e7059b6b11fb1bbe28e33e02519398ca94c1818874ebed18e504dc6f709be45", + strip_prefix = "benchmark-{}".format(version), + url = "https://github.com/google/benchmark/archive/refs/tags/v{}.tar.gz".format(version), + ) diff --git a/tools/workspace/googletest/BUILD.bazel b/tools/workspace/googletest/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/workspace/googletest/repository.bzl b/tools/workspace/googletest/repository.bzl new file mode 100644 index 0000000000..13af2c8ffc --- /dev/null +++ b/tools/workspace/googletest/repository.bzl @@ -0,0 +1,10 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def googletest_repository(name = "googletest"): + version = "1.15.2" + http_archive( + name = name, + sha256 = "7b42b4d6ed48810c5362c265a17faebe90dc2373c885e5216439d37927f02926", + strip_prefix = "googletest-{}".format(version), + url = "https://github.com/google/googletest/releases/download/v{}/googletest-{}.tar.gz".format(version, version), + ) diff --git a/tools/workspace/libccd/BUILD.bazel b/tools/workspace/libccd/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/workspace/libccd/package.BUILD.bazel b/tools/workspace/libccd/package.BUILD.bazel new file mode 100644 index 0000000000..5ff09b015f --- /dev/null +++ b/tools/workspace/libccd/package.BUILD.bazel @@ -0,0 +1,57 @@ +load("@bazel_skylib//rules:write_file.bzl", "write_file") + +package(default_visibility = ["@mujoco//:__subpackages__"]) + +write_file( + name = "config_h", + out = "src/ccd/config.h", + content = [""" +#ifndef __CCD_CONFIG_H__ +#define __CCD_CONFIG_H__ + +/* #undef CCD_SINGLE */ +#define CCD_DOUBLE + +#endif /* __CCD_CONFIG_H__ */ + """], +) + +cc_library( + name = "libccd", + srcs = [ + "src/alloc.h", + "src/ccd.c", + "src/dbg.h", + "src/list.h", + "src/mpr.c", + "src/polytope.c", + "src/polytope.h", + "src/simplex.h", + "src/support.c", + "src/support.h", + "src/vec3.c", + ], + hdrs = [ + "src/ccd/ccd.h", + "src/ccd/ccd_export.h", + "src/ccd/compiler.h", + "src/ccd/quat.h", + "src/ccd/vec3.h", + ":config_h", + ], + local_defines = [ + "CCD_STATIC_DEFINE", + ], + includes = [ + "src", + ], + data = [":license_filegroup"], +) + +filegroup( + name = "license_filegroup", + srcs = [ + "BSD-LICENSE", + ], + tags = ["license_filegroup"], +) diff --git a/tools/workspace/libccd/repository.bzl b/tools/workspace/libccd/repository.bzl new file mode 100644 index 0000000000..6833c63e7f --- /dev/null +++ b/tools/workspace/libccd/repository.bzl @@ -0,0 +1,11 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def libccd_repository(name = "libccd"): + commit = "7931e764a19ef6b21b443376c699bbc9c6d4fba8" + http_archive( + name = name, + sha256 = "479994a86d32e2effcaad64204142000ee6b6b291fd1859ac6710aee8d00a482", + strip_prefix = "libccd-{}".format(commit), + build_file = "@mujoco//tools/workspace/libccd:package.BUILD.bazel", + url = "https://github.com/danfis/libccd/archive/{}.tar.gz".format(commit), + ) diff --git a/tools/workspace/libglfw3/BUILD.bazel b/tools/workspace/libglfw3/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/workspace/libglfw3/package.BUILD.bazel b/tools/workspace/libglfw3/package.BUILD.bazel new file mode 100644 index 0000000000..474aa9356d --- /dev/null +++ b/tools/workspace/libglfw3/package.BUILD.bazel @@ -0,0 +1,24 @@ +cc_library( + name = "lib", + hdrs = glob(["usr/include/**/*.h*"]), + srcs = [], + includes = ["usr/include"], + deps = ["@libglvnd//:lib", ":libglfw.so-import", ":libglfw.so.3-import"], + data = [":license_filegroup"], + target_compatible_with = ["@platforms//os:linux", "@platforms//cpu:x86_64"], + visibility = ["//visibility:public"], +) + +cc_import( + name = "libglfw.so-import", + shared_library = "usr/lib/x86_64-linux-gnu/libglfw.so", +) +cc_import( + name = "libglfw.so.3-import", + shared_library = "usr/lib/x86_64-linux-gnu/libglfw.so.3", +) +filegroup( + name = "license_filegroup", + tags = ["license_filegroup"], + srcs = glob(["usr/share/doc/*/copyright"]), +) diff --git a/tools/workspace/libglfw3/repository.bzl b/tools/workspace/libglfw3/repository.bzl new file mode 100644 index 0000000000..a5dbb83d31 --- /dev/null +++ b/tools/workspace/libglfw3/repository.bzl @@ -0,0 +1,19 @@ +load("@mujoco//tools/workspace:deb_archive.bzl", "deb_package") + +def libglfw3_repository(name = "libglfw3"): + deb_package( + name = name, + urls = [ + "http://mirrors.kernel.org/ubuntu/pool/universe/g/glfw3/libglfw3_3.3.6-1_amd64.deb", + "http://mirrors.kernel.org/ubuntu/pool/universe/g/glfw3/libglfw3-dev_3.3.6-1_amd64.deb", + ], + sha256s = [ + "a7fe08d4ded1c376e8b008fdeef220b8a0335258a05c542982424cdb43b61af3", + "2b2a68725a34dd69bcce045282806f1d1ffa6c43376aa1023058683f51a31b02", + ], + data_archives = [ + "data.tar.zst", + "data.tar.zst", + ], + build_file = "@mujoco//tools/workspace/libglfw3:package.BUILD.bazel", + ) diff --git a/tools/workspace/libglvnd/BUILD.bazel b/tools/workspace/libglvnd/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/workspace/libglvnd/package.BUILD.bazel b/tools/workspace/libglvnd/package.BUILD.bazel new file mode 100644 index 0000000000..25f6437ce8 --- /dev/null +++ b/tools/workspace/libglvnd/package.BUILD.bazel @@ -0,0 +1,16 @@ +cc_library( + name = "lib", + hdrs = glob(["usr/include/**/*.h*"]), + srcs = [], + includes = ["usr/include"], + deps = [], + data = [":license_filegroup"], + target_compatible_with = ["@platforms//os:linux", "@platforms//cpu:x86_64"], + visibility = ["//visibility:public"], +) + +filegroup( + name = "license_filegroup", + tags = ["license_filegroup"], + srcs = glob(["usr/share/doc/*/copyright"]), +) diff --git a/tools/workspace/libglvnd/repository.bzl b/tools/workspace/libglvnd/repository.bzl new file mode 100644 index 0000000000..ffa2aeb750 --- /dev/null +++ b/tools/workspace/libglvnd/repository.bzl @@ -0,0 +1,10 @@ +load("@mujoco//tools/workspace:deb_archive.bzl", "deb_package") + +def libglvnd_repository(name = "libglvnd"): + deb_package( + name = name, + urls = ["http://mirrors.kernel.org/ubuntu/pool/main/libg/libglvnd/libglvnd-dev_1.4.0-1_amd64.deb"], + sha256s = ["af38c9f0f7f65735d89094cb5bc32afa58012e4bd48bae995653c465dc110165"], + data_archives = ["data.tar.zst"], + build_file = "@mujoco//tools/workspace/libglvnd:package.BUILD.bazel", + ) diff --git a/tools/workspace/lodepng/BUILD.bazel b/tools/workspace/lodepng/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/workspace/lodepng/package.BUILD.bazel b/tools/workspace/lodepng/package.BUILD.bazel new file mode 100644 index 0000000000..4cc07356cf --- /dev/null +++ b/tools/workspace/lodepng/package.BUILD.bazel @@ -0,0 +1,19 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +filegroup( + name = "license_filegroup", + srcs = ["LICENSE"], + tags = ["license_filegroup"], +) + +cc_library( + name = "lodepng", + srcs = [ + "lodepng.cpp", + ], + hdrs = [ + "lodepng.h", + ], + data = [":license_filegroup"], + includes = ["."], +) diff --git a/tools/workspace/lodepng/repository.bzl b/tools/workspace/lodepng/repository.bzl new file mode 100644 index 0000000000..0e456c5e20 --- /dev/null +++ b/tools/workspace/lodepng/repository.bzl @@ -0,0 +1,11 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def lodepng_repository(name = "lodepng"): + commit = "b4ed2cd7ecf61d29076169b49199371456d4f90b" + http_archive( + name = name, + sha256 = "b67e466ba659c07ac775d07dbd97af319cde449ce14abed9ae596df29d888603", + strip_prefix = "lodepng-{}".format(commit), + build_file = "@mujoco//tools/workspace/lodepng:package.BUILD.bazel", + url = "https://github.com/lvandeve/lodepng/archive/{}.tar.gz".format(commit), + ) diff --git a/tools/workspace/pybind11/BUILD.bazel b/tools/workspace/pybind11/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/workspace/pybind11/package.BUILD.bazel b/tools/workspace/pybind11/package.BUILD.bazel new file mode 100644 index 0000000000..3f02423ad0 --- /dev/null +++ b/tools/workspace/pybind11/package.BUILD.bazel @@ -0,0 +1,15 @@ +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "pybind11", + includes = ["include"], + hdrs = glob(["include/**/*.h"]), + data = [":license_filegroup"], + deps = ["@python_3_11//:python_headers"], +) + +filegroup( + name = "license_filegroup", + srcs = ["LICENSE"], + tags = ["license_filegroup"], +) diff --git a/tools/workspace/pybind11/repository.bzl b/tools/workspace/pybind11/repository.bzl new file mode 100644 index 0000000000..7a6f05bba1 --- /dev/null +++ b/tools/workspace/pybind11/repository.bzl @@ -0,0 +1,11 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def pybind11_repository(name = "pybind11"): + version = "2.13.5" + http_archive( + name = name, + build_file = "@mujoco//tools/workspace/pybind11:package.BUILD.bazel", + sha256 = "b1e209c42b3a9ed74da3e0b25a4f4cd478d89d5efbb48f04b277df427faf6252", + strip_prefix = "pybind11-{}".format(version), + url = "https://github.com/pybind/pybind11/archive/refs/tags/v{}.tar.gz".format(version), + ) diff --git a/tools/workspace/qhull/BUILD.bazel b/tools/workspace/qhull/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/workspace/qhull/package.BUILD.bazel b/tools/workspace/qhull/package.BUILD.bazel new file mode 100644 index 0000000000..5c7e8ced1e --- /dev/null +++ b/tools/workspace/qhull/package.BUILD.bazel @@ -0,0 +1,93 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +cc_library( + name = "libqhull", + srcs = [ + "src/libqhull/geom.c", + "src/libqhull/geom2.c", + "src/libqhull/global.c", + "src/libqhull/io.c", + "src/libqhull/libqhull.c", + "src/libqhull/mem.c", + "src/libqhull/merge.c", + "src/libqhull/poly.c", + "src/libqhull/poly2.c", + "src/libqhull/qset.c", + "src/libqhull/random.c", + "src/libqhull/rboxlib.c", + "src/libqhull/stat.c", + "src/libqhull/user.c", + "src/libqhull/usermem.c", + "src/libqhull/userprintf.c", + "src/libqhull/userprintf_rbox.c", + ], + hdrs = [ + "src/libqhull/geom.h", + "src/libqhull/io.h", + "src/libqhull/libqhull.h", + "src/libqhull/mem.h", + "src/libqhull/merge.h", + "src/libqhull/poly.h", + "src/libqhull/qhull_a.h", + "src/libqhull/qset.h", + "src/libqhull/random.h", + "src/libqhull/stat.h", + "src/libqhull/user.h", + ], + copts = select({ + "@mujoco//tools:clang": ["-Wno-unused-but-set-variable"], + "//conditions:default": [], + }), + data = [":license_filegroup"], + includes = ["src"], + linkopts = ["-lm"], +) + +cc_library( + name = "libqhull_r", + srcs = [ + "src/libqhull_r/geom2_r.c", + "src/libqhull_r/geom_r.c", + "src/libqhull_r/global_r.c", + "src/libqhull_r/io_r.c", + "src/libqhull_r/libqhull_r.c", + "src/libqhull_r/mem_r.c", + "src/libqhull_r/merge_r.c", + "src/libqhull_r/poly2_r.c", + "src/libqhull_r/poly_r.c", + "src/libqhull_r/qset_r.c", + "src/libqhull_r/random_r.c", + "src/libqhull_r/rboxlib_r.c", + "src/libqhull_r/stat_r.c", + "src/libqhull_r/user_r.c", + "src/libqhull_r/usermem_r.c", + "src/libqhull_r/userprintf_r.c", + "src/libqhull_r/userprintf_rbox_r.c", + ], + hdrs = [ + "src/libqhull_r/geom_r.h", + "src/libqhull_r/io_r.h", + "src/libqhull_r/libqhull_r.h", + "src/libqhull_r/mem_r.h", + "src/libqhull_r/merge_r.h", + "src/libqhull_r/poly_r.h", + "src/libqhull_r/qhull_ra.h", + "src/libqhull_r/qset_r.h", + "src/libqhull_r/random_r.h", + "src/libqhull_r/stat_r.h", + "src/libqhull_r/user_r.h", + ], + copts = select({ + "@mujoco//tools:clang": ["-Wno-unused-but-set-variable"], + "//conditions:default": [], + }), + data = [":license_filegroup"], + includes = ["src"], + linkopts = ["-lm"], +) + +filegroup( + name = "license_filegroup", + srcs = ["COPYING.txt"], + tags = ["license_filegroup"], +) diff --git a/tools/workspace/qhull/repository.bzl b/tools/workspace/qhull/repository.bzl new file mode 100644 index 0000000000..aa9a237cc4 --- /dev/null +++ b/tools/workspace/qhull/repository.bzl @@ -0,0 +1,11 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def qhull_repository(name = "qhull"): + commit = "0c8fc90d2037588024d9964515c1e684f6007ecc" + http_archive( + name = name, + sha256 = "227afadbfe4b934ef7da385dac0c7e7abf5d977fb3d4734b299e7b38a334a45a", + strip_prefix = "qhull-{}".format(commit), + build_file = "@mujoco//tools/workspace/qhull:package.BUILD.bazel", + url = "https://github.com/qhull/qhull/archive/{}.tar.gz".format(commit), + ) diff --git a/tools/workspace/rules_python/BUILD.bazel b/tools/workspace/rules_python/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/workspace/rules_python/repository.bzl b/tools/workspace/rules_python/repository.bzl new file mode 100644 index 0000000000..99d688210b --- /dev/null +++ b/tools/workspace/rules_python/repository.bzl @@ -0,0 +1,10 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def rules_python_repository(name = "rules_python"): + version = "0.37.0" + http_archive( + name = name, + sha256 = "0cc05ddb27614baecace068986931e2a6e9f69114e6115fc5dc58250faf56e0f", + strip_prefix = "rules_python-{}".format(version), + url = "https://github.com/bazelbuild/rules_python/releases/download/{}/rules_python-{}.tar.gz".format(version, version), + ) diff --git a/tools/workspace/spdlog/BUILD.bazel b/tools/workspace/spdlog/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/workspace/spdlog/package.BUILD.bazel b/tools/workspace/spdlog/package.BUILD.bazel new file mode 100644 index 0000000000..5bc2e40eac --- /dev/null +++ b/tools/workspace/spdlog/package.BUILD.bazel @@ -0,0 +1,32 @@ +package(default_visibility = [ + "@mujoco//:__subpackages__", + "@SdfLib//:__subpackages__", +]) + +cc_library( + name = "spdlog", + srcs = [ + "src/async.cpp", + "src/cfg.cpp", + "src/color_sinks.cpp", + "src/file_sinks.cpp", + "src/spdlog.cpp", + "src/stdout_sinks.cpp", + ], + hdrs = glob(["include/**/*.h"]), + data = [":license_filegroup"], + includes = ["include"], + deps = ["@fmt"], + local_defines = [ + "SPDLOG_COMPILED_LIB", + "SPDLOG_FMT_EXTERNAL", + ], +) + +filegroup( + name = "license_filegroup", + srcs = [ + "LICENSE", + ], + tags = ["license_filegroup"], +) diff --git a/tools/workspace/spdlog/repository.bzl b/tools/workspace/spdlog/repository.bzl new file mode 100644 index 0000000000..66d1e64ec7 --- /dev/null +++ b/tools/workspace/spdlog/repository.bzl @@ -0,0 +1,11 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def spdlog_repository(name = "spdlog"): + version = "1.14.1" + http_archive( + name = name, + sha256 = "1586508029a7d0670dfcb2d97575dcdc242d3868a259742b69f100801ab4e16b", + strip_prefix = "spdlog-{}".format(version), + build_file = "@mujoco//tools/workspace/spdlog:package.BUILD.bazel", + url = "https://github.com/gabime/spdlog/archive/refs/tags/v{}.tar.gz".format(version), + ) diff --git a/tools/workspace/tinyobjloader/BUILD.bazel b/tools/workspace/tinyobjloader/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/workspace/tinyobjloader/package.BUILD.bazel b/tools/workspace/tinyobjloader/package.BUILD.bazel new file mode 100644 index 0000000000..74197e584e --- /dev/null +++ b/tools/workspace/tinyobjloader/package.BUILD.bazel @@ -0,0 +1,14 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +cc_library( + name = "tinyobjloader", + hdrs = ["tiny_obj_loader.h"], + data = [":license_filegroup"], + includes = ["."], +) + +filegroup( + name = "license_filegroup", + srcs = ["LICENSE"], + tags = ["license_filegroup"], +) diff --git a/tools/workspace/tinyobjloader/repository.bzl b/tools/workspace/tinyobjloader/repository.bzl new file mode 100644 index 0000000000..25b9a87e08 --- /dev/null +++ b/tools/workspace/tinyobjloader/repository.bzl @@ -0,0 +1,11 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def tinyobjloader_repository(name = "tinyobjloader"): + commit = "1421a10d6ed9742f5b2c1766d22faa6cfbc56248" + http_archive( + name = name, + sha256 = "e334b2900380efdc19a0ea42e5e966a6a6a04831dd830dd42a80e28ce6d1e9be", + strip_prefix = "tinyobjloader-{}".format(commit), + build_file = "@mujoco//tools/workspace/tinyobjloader:package.BUILD.bazel", + url = "https://github.com/tinyobjloader/tinyobjloader/archive/{}.tar.gz".format(commit), + ) diff --git a/tools/workspace/tinyxml2/BUILD.bazel b/tools/workspace/tinyxml2/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/workspace/tinyxml2/package.BUILD.bazel b/tools/workspace/tinyxml2/package.BUILD.bazel new file mode 100644 index 0000000000..5412426215 --- /dev/null +++ b/tools/workspace/tinyxml2/package.BUILD.bazel @@ -0,0 +1,15 @@ +package(default_visibility = ["@mujoco//:__subpackages__"]) + +cc_library( + name = "tinyxml2", + srcs = ["tinyxml2.cpp"], + hdrs = ["tinyxml2.h"], + data = [":license_filegroup"], + includes = ["."] +) + +filegroup( + name = "license_filegroup", + srcs = ["LICENSE.txt"], + tags = ["license_filegroup"], +) diff --git a/tools/workspace/tinyxml2/repository.bzl b/tools/workspace/tinyxml2/repository.bzl new file mode 100644 index 0000000000..facf8ff47a --- /dev/null +++ b/tools/workspace/tinyxml2/repository.bzl @@ -0,0 +1,11 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def tinyxml2_repository(name = "tinyxml2"): + commit = "9a89766acc42ddfa9e7133c7d81a5bda108a0ade" + http_archive( + name = name, + sha256 = "562d77a5f3b1631c289e6856a440c2f459ba5e120a529ce70a08279c2d3d5667", + strip_prefix = "tinyxml2-{}".format(commit), + build_file = "@mujoco//tools/workspace/tinyxml2:package.BUILD.bazel", + url = "https://github.com/leethomason/tinyxml2/archive/{}.tar.gz".format(commit), + ) From 1a46092248787de7740c442f4298fbda13533b37 Mon Sep 17 00:00:00 2001 From: junhyeokahn Date: Tue, 12 Nov 2024 14:38:28 -0500 Subject: [PATCH 2/7] rebase onto master --- BUILD.bazel | 1 + mjx/mujoco/mjx/BUILD.bazel | 36 +++++++++++++++++++++++++++++++++ plugin/elasticity/BUILD.bazel | 38 ----------------------------------- python/mujoco/BUILD.bazel | 3 +++ python/mujoco/structs.cc | 2 +- src/engine/BUILD.bazel | 11 ++++++++++ 6 files changed, 52 insertions(+), 39 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index dd2a680bb5..1be2f7a7de 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -52,6 +52,7 @@ filegroup( "include/mujoco/mjmodel.h", "include/mujoco/mjplugin.h", "include/mujoco/mjrender.h", + "include/mujoco/mjsan.h", "include/mujoco/mjspec.h", "include/mujoco/mjthread.h", "include/mujoco/mjtnum.h", diff --git a/mjx/mujoco/mjx/BUILD.bazel b/mjx/mujoco/mjx/BUILD.bazel index 62195f6b9a..da93bd5307 100644 --- a/mjx/mujoco/mjx/BUILD.bazel +++ b/mjx/mujoco/mjx/BUILD.bazel @@ -121,6 +121,7 @@ py_library( ":math", ":passive", ":scan", + ":sensor", ":smooth", ":solver", ":support", @@ -303,6 +304,7 @@ py_library( ":io", ":passive", ":ray", + ":sensor", ":smooth", ":solver", ":support", @@ -327,6 +329,40 @@ py_library( ], ) +py_library( + name = "sensor", + srcs = [ + "_src/sensor.py", + ], + deps = [ + ":types", + requirement("jax"), + requirement("numpy"), + ], +) + +py_test( + name = "sensor_test", + size = "small", + srcs = [ + "_src/sensor_test.py", + ], + data = [ + "//mjx/mujoco/mjx/test_data:model", + ], + shard_count = 3, + deps = [ + ":mjx", + ":test_util", + "//:mujoco-py", + requirement("absl-py"), + requirement("jax"), + requirement("numpy"), + requirement("typing_extensions"), + requirement("importlib_resources"), + ], +) + py_test( name = "collision_driver_test", size = "medium", diff --git a/plugin/elasticity/BUILD.bazel b/plugin/elasticity/BUILD.bazel index c057e67682..2c73f7e6ad 100644 --- a/plugin/elasticity/BUILD.bazel +++ b/plugin/elasticity/BUILD.bazel @@ -32,24 +32,6 @@ cc_library( ], ) -cc_library( - name = "solid", - srcs = [ - "solid.cc", - ], - hdrs = [ - "solid.h", - ], - copts = [ - "-Wno-sign-compare", - ], - target_compatible_with = ["@platforms//os:linux"], - deps = [ - ":elasticity_impl", - "//:mujoco_hdrs", - ], -) - cc_library( name = "shell", srcs = [ @@ -68,24 +50,6 @@ cc_library( ], ) -cc_library( - name = "membrane", - srcs = [ - "membrane.cc", - ], - hdrs = [ - "membrane.h", - ], - copts = [ - "-Wno-sign-compare", - ], - target_compatible_with = ["@platforms//os:linux"], - deps = [ - ":elasticity_impl", - "//:mujoco_hdrs", - ], -) - cc_library( name = "register", srcs = [ @@ -97,9 +61,7 @@ cc_library( target_compatible_with = ["@platforms//os:linux"], deps = [ ":cable", - ":membrane", ":shell", - ":solid", "//:mujoco_hdrs", ], alwayslink = True, diff --git a/python/mujoco/BUILD.bazel b/python/mujoco/BUILD.bazel index 5ee0b5228a..82907fb640 100644 --- a/python/mujoco/BUILD.bazel +++ b/python/mujoco/BUILD.bazel @@ -309,6 +309,9 @@ pybind_extension( "specs.cc", "specs.cc.inc", ], + copts = [ + "-Wno-sign-compare", + ], dynamic_deps = [ "//:mujoco_shared", ], diff --git a/python/mujoco/structs.cc b/python/mujoco/structs.cc index c52caa3c48..5ce90778fb 100644 --- a/python/mujoco/structs.cc +++ b/python/mujoco/structs.cc @@ -40,7 +40,7 @@ #include #include #include "errors.h" -#include "function_traits.h" +#include "python/mujoco/function_traits.h" #include "indexer_xmacro.h" #include "indexers.h" #include "private.h" diff --git a/src/engine/BUILD.bazel b/src/engine/BUILD.bazel index e320cc0651..cecf3d8beb 100644 --- a/src/engine/BUILD.bazel +++ b/src/engine/BUILD.bazel @@ -77,6 +77,7 @@ cc_library( ":engine_name", ":engine_plugin", ":engine_ray", + ":engine_sort", ":engine_util_blas", ":engine_util_errmem", ":engine_util_misc", @@ -171,6 +172,7 @@ cc_library( target_compatible_with = ["@platforms//os:linux"], deps = [ ":engine_collision_primitive", + ":engine_io", ":engine_util_blas", ":engine_util_errmem", ":engine_util_misc", @@ -345,6 +347,15 @@ cc_library( ], ) +cc_library( + name = "engine_sort", + hdrs = ["engine_sort.h"], + copts = ["-Wshadow"], + features = THIN_LTO_FEATURE_IF_CLANG, + linkopts = THIN_LTO_LINKOPTS_IF_CLANG, + target_compatible_with = ["@platforms//os:linux"], +) + cc_library( name = "engine_util_blas", srcs = ["engine_util_blas.c"], From 413de06a84e11b5008d6071b275177a7a4d65b11 Mon Sep 17 00:00:00 2001 From: Junhyeok Ahn Date: Fri, 15 Nov 2024 11:18:30 -0500 Subject: [PATCH 3/7] delete duplicated pkgutil --- python/mujoco/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/python/mujoco/__init__.py b/python/mujoco/__init__.py index c2720f1614..ca77a1a0a9 100644 --- a/python/mujoco/__init__.py +++ b/python/mujoco/__init__.py @@ -14,8 +14,6 @@ # ============================================================================== """Python bindings for MuJoCo.""" -__path__ = __import__('pkgutil').extend_path(__path__, __name__) - import ctypes import ctypes.util import os From ad6ed73abe357e40131442d9b279c683c3a4e33b Mon Sep 17 00:00:00 2001 From: junhyeokahn Date: Mon, 25 Nov 2024 11:32:15 -0500 Subject: [PATCH 4/7] revert the include paths to fix ci --- python/mujoco/BUILD.bazel | 10 +++------- python/mujoco/enums.cc | 2 +- python/mujoco/functions.cc | 2 +- python/mujoco/render.cc | 2 +- python/mujoco/specs.cc | 2 +- python/mujoco/structs.cc | 2 +- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/python/mujoco/BUILD.bazel b/python/mujoco/BUILD.bazel index 82907fb640..093d2fdfb5 100644 --- a/python/mujoco/BUILD.bazel +++ b/python/mujoco/BUILD.bazel @@ -88,6 +88,7 @@ pybind_extension( cc_library( name = "enum_traits", hdrs = ["enum_traits.h"], + includes = ["."], deps = ["//:mujoco_hdrs"], ) @@ -120,6 +121,7 @@ generated_file( cc_library( name = "function_traits", hdrs = ["function_traits.h"], + includes = ["."], deps = [ "//:mujoco_hdrs", "//python/mujoco/util:crossplatform", @@ -161,9 +163,6 @@ pybind_library( pybind_extension( name = "_functions", srcs = ["functions.cc"], - copts = [ - "-Ipython/mujoco", - ], dynamic_deps = [ "//:mujoco_shared", ], @@ -188,9 +187,6 @@ cc_library( pybind_extension( name = "_render", srcs = ["render.cc"], - copts = [ - "-Ipython/mujoco", - ], dynamic_deps = [ "//:mujoco_shared", ], @@ -237,7 +233,6 @@ pybind_extension( "-Wno-type-limits", "-Wno-error", "-Wno-int-in-bool-context", - "-Ipython/mujoco", ], dynamic_deps = [ "//:mujoco_shared", @@ -312,6 +307,7 @@ pybind_extension( copts = [ "-Wno-sign-compare", ], + includes = ["."], dynamic_deps = [ "//:mujoco_shared", ], diff --git a/python/mujoco/enums.cc b/python/mujoco/enums.cc index 417f056c86..c13bac6fc6 100644 --- a/python/mujoco/enums.cc +++ b/python/mujoco/enums.cc @@ -20,7 +20,7 @@ #include #include "util/crossplatform.h" -#include "python/mujoco/enum_traits.h" +#include "enum_traits.h" #include "util/tuple_tools.h" #include #include diff --git a/python/mujoco/functions.cc b/python/mujoco/functions.cc index 7b8e93f4d6..7fed04f7c9 100644 --- a/python/mujoco/functions.cc +++ b/python/mujoco/functions.cc @@ -24,7 +24,7 @@ #include #include #include "errors.h" -#include "python/mujoco/function_traits.h" +#include "function_traits.h" #include "functions.h" #include "private.h" #include "raw.h" diff --git a/python/mujoco/render.cc b/python/mujoco/render.cc index 15c06689f1..c621cd0e2d 100644 --- a/python/mujoco/render.cc +++ b/python/mujoco/render.cc @@ -21,7 +21,7 @@ #include #include #include "errors.h" -#include "python/mujoco/function_traits.h" +#include "function_traits.h" #include "functions.h" #include "raw.h" #include "structs.h" diff --git a/python/mujoco/specs.cc b/python/mujoco/specs.cc index a16e99df05..2869483e27 100644 --- a/python/mujoco/specs.cc +++ b/python/mujoco/specs.cc @@ -1092,6 +1092,6 @@ PYBIND11_MODULE(_specs, m) { self.global = value; }); -#include "python/mujoco/specs.cc.inc" +#include "specs.cc.inc" } // PYBIND11_MODULE // NOLINT } // namespace mujoco::python diff --git a/python/mujoco/structs.cc b/python/mujoco/structs.cc index 5ce90778fb..c52caa3c48 100644 --- a/python/mujoco/structs.cc +++ b/python/mujoco/structs.cc @@ -40,7 +40,7 @@ #include #include #include "errors.h" -#include "python/mujoco/function_traits.h" +#include "function_traits.h" #include "indexer_xmacro.h" #include "indexers.h" #include "private.h" From bc99adc33ef9a0cbbb03ac92755e0ba9b4271ebe Mon Sep 17 00:00:00 2001 From: junhyeokahn Date: Mon, 25 Nov 2024 11:35:23 -0500 Subject: [PATCH 5/7] clean up gitignore --- .gitignore | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index c0b6d9f82d..733be8b757 100644 --- a/.gitignore +++ b/.gitignore @@ -32,15 +32,11 @@ __pycache__/ *.py[cod] *$py.class -<<<<<<< HEAD # MuJoCo's default log file MUJOCO_LOG.TXT # Clang cache .cache/ -======= + # Bazel build artifacts (symlinks) /bazel-* - -.cache ->>>>>>> 3dabc6bf (Bazel Build for v3.2.2) From 052a71f09ebdbba961900f19b0878dd04057e41c Mon Sep 17 00:00:00 2001 From: junhyeokahn Date: Fri, 20 Dec 2024 10:43:25 -0500 Subject: [PATCH 6/7] match copts with CMake --- .bazelversion | 1 + BUILD.bazel | 14 ++++---- plugin/actuator/BUILD.bazel | 9 +++-- plugin/elasticity/BUILD.bazel | 22 +++++-------- plugin/sdf/BUILD.bazel | 43 ++++++++++-------------- plugin/sensor/BUILD.bazel | 4 ++- python/mujoco/BUILD.bazel | 8 ++--- python/mujoco/util/BUILD.bazel | 12 ++++--- simulate/BUILD.bazel | 12 +++---- src/cc/BUILD.bazel | 4 ++- src/engine/BUILD.bazel | 53 +++++++++++++----------------- src/render/BUILD.bazel | 15 ++++----- src/thread/BUILD.bazel | 10 +++--- src/ui/BUILD.bazel | 4 ++- src/user/BUILD.bazel | 30 ++++++----------- src/xml/BUILD.bazel | 33 +++++++------------ test/BUILD.bazel | 12 +++++-- test/engine/BUILD.bazel | 2 ++ test/plugin/actuator/BUILD.bazel | 1 + test/plugin/elasticity/BUILD.bazel | 1 + test/plugin/sensor/BUILD.bazel | 1 + test/thread/BUILD.bazel | 2 ++ test/user/BUILD.bazel | 2 ++ test/xml/BUILD.bazel | 1 + tools/def.bzl | 51 ++++++++++++++++++++++++++++ 25 files changed, 185 insertions(+), 162 deletions(-) create mode 100644 .bazelversion create mode 100644 tools/def.bzl diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 0000000000..815da58b7a --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +7.4.1 diff --git a/BUILD.bazel b/BUILD.bazel index 1be2f7a7de..72c6b9386c 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,5 +1,6 @@ load("@mujoco//tools:symlink_files.bzl", "symlink_files") load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier") +load("@mujoco//tools:def.bzl", "mj_cc_library") package(default_visibility = ["@mujoco//:__subpackages__"]) @@ -11,7 +12,7 @@ filegroup( tags = ["license_filegroup"], ) -cc_library( +mj_cc_library( name = "mujoco_hdrs", hdrs = [":mujoco_headers"], includes = [ @@ -21,9 +22,8 @@ cc_library( visibility = ["//visibility:public"], ) -cc_library( +mj_cc_library( name = "_core", - linkopts = ["-Wl,--gc-sections"], target_compatible_with = ["@platforms//os:linux"], deps = [ "//src/engine", @@ -32,9 +32,8 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "_graphics_native", - linkopts = ["-Wl,--gc-sections"], target_compatible_with = ["@platforms//os:linux"], deps = [ "//src/render", @@ -63,7 +62,7 @@ filegroup( ], ) -cc_library( +mj_cc_library( name = "mujoco", hdrs = [":mujoco_headers"], data = [ @@ -73,7 +72,6 @@ cc_library( "include", ], target_compatible_with = ["@platforms//os:linux"], - visibility = ["//visibility:public"], deps = [ ":_core", ":_graphics_native", @@ -82,7 +80,7 @@ cc_library( cc_shared_library( name = "mujoco_shared", - shared_lib_name = "libmujoco.so.3.2.2", + shared_lib_name = "libmujoco.so", target_compatible_with = ["@platforms//os:linux"], visibility = ["//visibility:public"], deps = [ diff --git a/plugin/actuator/BUILD.bazel b/plugin/actuator/BUILD.bazel index f310388b1e..0d97af3117 100644 --- a/plugin/actuator/BUILD.bazel +++ b/plugin/actuator/BUILD.bazel @@ -1,18 +1,17 @@ +load("@mujoco//tools:def.bzl", "mj_cc_library") + package(default_visibility = ["@mujoco//:__subpackages__"]) -cc_library( +mj_cc_library( name = "pid", srcs = ["pid.cc"], hdrs = ["pid.h"], - copts = [ - "-Wno-sign-compare", - ], deps = [ "//:mujoco_hdrs", ], ) -cc_library( +mj_cc_library( name = "register", srcs = [ "register.cc", diff --git a/plugin/elasticity/BUILD.bazel b/plugin/elasticity/BUILD.bazel index 2c73f7e6ad..9eeed180d0 100644 --- a/plugin/elasticity/BUILD.bazel +++ b/plugin/elasticity/BUILD.bazel @@ -1,6 +1,8 @@ +load("@mujoco//tools:def.bzl", "mj_cc_library") + package(default_visibility = ["@mujoco//:__subpackages__"]) -cc_library( +mj_cc_library( name = "elasticity_impl", srcs = [ "elasticity.cc", @@ -8,16 +10,14 @@ cc_library( hdrs = [ "elasticity.h", ], - copts = [ - "-Wno-sign-compare", - ], target_compatible_with = ["@platforms//os:linux"], deps = [ "//:mujoco_hdrs", ], + alwayslink = True, ) -cc_library( +mj_cc_library( name = "cable", srcs = [ "cable.cc", @@ -30,9 +30,10 @@ cc_library( ":elasticity_impl", "//:mujoco_hdrs", ], + alwayslink = True, ) -cc_library( +mj_cc_library( name = "shell", srcs = [ "shell.cc", @@ -40,24 +41,19 @@ cc_library( hdrs = [ "shell.h", ], - copts = [ - "-Wno-sign-compare", - ], target_compatible_with = ["@platforms//os:linux"], deps = [ ":elasticity_impl", "//:mujoco_hdrs", ], + alwayslink = True, ) -cc_library( +mj_cc_library( name = "register", srcs = [ "register.cc", ], - copts = [ - "-Wno-sign-compare", - ], target_compatible_with = ["@platforms//os:linux"], deps = [ ":cable", diff --git a/plugin/sdf/BUILD.bazel b/plugin/sdf/BUILD.bazel index c94b4056fa..df4248cdf1 100644 --- a/plugin/sdf/BUILD.bazel +++ b/plugin/sdf/BUILD.bazel @@ -1,6 +1,8 @@ +load("@mujoco//tools:def.bzl", "mj_cc_library") + package(default_visibility = ["@mujoco//:__subpackages__"]) -cc_library( +mj_cc_library( name = "sdf_impl", srcs = [ "sdf.cc", @@ -8,15 +10,13 @@ cc_library( hdrs = [ "sdf.h", ], - copts = [ - "-Wno-sign-compare", - ], deps = [ "//:mujoco_hdrs", ], + alwayslink = True, ) -cc_library( +mj_cc_library( name = "torus", srcs = [ "torus.cc", @@ -24,16 +24,14 @@ cc_library( hdrs = [ "torus.h", ], - copts = [ - "-Wno-sign-compare", - ], deps = [ ":sdf_impl", "//:mujoco_hdrs", ], + alwayslink = True, ) -cc_library( +mj_cc_library( name = "bolt", srcs = [ "bolt.cc", @@ -41,16 +39,14 @@ cc_library( hdrs = [ "bolt.h", ], - copts = [ - "-Wno-sign-compare", - ], deps = [ ":sdf_impl", "//:mujoco_hdrs", ], + alwayslink = True, ) -cc_library( +mj_cc_library( name = "bowl", srcs = [ "bowl.cc", @@ -58,16 +54,14 @@ cc_library( hdrs = [ "bowl.h", ], - copts = [ - "-Wno-sign-compare", - ], deps = [ ":sdf_impl", "//:mujoco_hdrs", ], + alwayslink = True, ) -cc_library( +mj_cc_library( name = "nut", srcs = [ "nut.cc", @@ -75,16 +69,14 @@ cc_library( hdrs = [ "nut.h", ], - copts = [ - "-Wno-sign-compare", - ], deps = [ ":sdf_impl", "//:mujoco_hdrs", ], + alwayslink = True, ) -cc_library( +mj_cc_library( name = "gear", srcs = [ "gear.cc", @@ -92,16 +84,14 @@ cc_library( hdrs = [ "gear.h", ], - copts = [ - "-Wno-sign-compare", - ], deps = [ ":sdf_impl", "//:mujoco_hdrs", ], + alwayslink = True, ) -cc_library( +mj_cc_library( name = "sdflib", srcs = [ "sdflib.cc", @@ -114,9 +104,10 @@ cc_library( "//:mujoco_hdrs", "@SdfLib", ], + alwayslink = True, ) -cc_library( +mj_cc_library( name = "register", srcs = [ "register.cc", diff --git a/plugin/sensor/BUILD.bazel b/plugin/sensor/BUILD.bazel index a225256ab7..c679190dbb 100644 --- a/plugin/sensor/BUILD.bazel +++ b/plugin/sensor/BUILD.bazel @@ -1,6 +1,8 @@ +load("@mujoco//tools:def.bzl", "mj_cc_library") + package(default_visibility = ["@mujoco//:__subpackages__"]) -cc_library( +mj_cc_library( name = "touch_grid", srcs = [ "sensor.cc", diff --git a/python/mujoco/BUILD.bazel b/python/mujoco/BUILD.bazel index 093d2fdfb5..2393238b21 100644 --- a/python/mujoco/BUILD.bazel +++ b/python/mujoco/BUILD.bazel @@ -3,6 +3,7 @@ load("//devtools/bbcp/builddefs:build_defs.bzl", "generated_file") load("//devtools/python/blaze:pybind.bzl", "pybind_extension", "pybind_library") load("@pip_deps//:requirements.bzl", "requirement") load("@mujoco//tools:symlink_files.bzl", "symlink_files") +load("@mujoco//tools:def.bzl", "mj_cc_library") package(default_visibility = ["@mujoco//:__subpackages__"]) @@ -50,7 +51,7 @@ generated_file( wrapped_target = ":_genrule_enum_traits.h", ) -cc_library( +mj_cc_library( name = "mujoco_private_api_header", hdrs = ["private.h"], deps = ["//:mujoco_hdrs"], @@ -85,7 +86,7 @@ pybind_extension( ], ) -cc_library( +mj_cc_library( name = "enum_traits", hdrs = ["enum_traits.h"], includes = ["."], @@ -118,7 +119,7 @@ generated_file( wrapped_target = ":_genrule_function_traits.h", ) -cc_library( +mj_cc_library( name = "function_traits", hdrs = ["function_traits.h"], includes = ["."], @@ -232,7 +233,6 @@ pybind_extension( "-Wno-redundant-move", "-Wno-type-limits", "-Wno-error", - "-Wno-int-in-bool-context", ], dynamic_deps = [ "//:mujoco_shared", diff --git a/python/mujoco/util/BUILD.bazel b/python/mujoco/util/BUILD.bazel index ce019d9059..f3269b5421 100644 --- a/python/mujoco/util/BUILD.bazel +++ b/python/mujoco/util/BUILD.bazel @@ -1,6 +1,8 @@ +load("@mujoco//tools:def.bzl", "mj_cc_library") + package(default_visibility = ["@mujoco//:__subpackages__"]) -cc_library( +mj_cc_library( name = "array_traits", hdrs = ["array_traits.h"], deps = [ @@ -9,17 +11,17 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "crossplatform", hdrs = ["crossplatform.h"], ) -cc_library( +mj_cc_library( name = "func_traits", hdrs = ["func_traits.h"], ) -cc_library( +mj_cc_library( name = "func_wrap", hdrs = ["func_wrap.h"], deps = [ @@ -30,7 +32,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "tuple_tools", hdrs = ["tuple_tools.h"], deps = [ diff --git a/simulate/BUILD.bazel b/simulate/BUILD.bazel index 496b190b6b..6d9fd13e62 100644 --- a/simulate/BUILD.bazel +++ b/simulate/BUILD.bazel @@ -1,6 +1,8 @@ +load("@mujoco//tools:def.bzl", "mj_cc_library") + package(default_visibility = ["@mujoco//:__subpackages__"]) -cc_library( +mj_cc_library( name = "platform_ui_adapter", srcs = [ "glfw_adapter.cc", @@ -23,7 +25,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "simulate_lib", srcs = [ "array_safety.h", @@ -32,9 +34,6 @@ cc_library( hdrs = [ "simulate.h", ], - copts = [ - "-Wno-sign-compare", - ], data = [ "//:license_filegroup", ], @@ -50,9 +49,6 @@ cc_binary( srcs = [ "main.cc", ], - copts = [ - "-Wno-sign-compare", - ], data = [ "//:license_filegroup", ], diff --git a/src/cc/BUILD.bazel b/src/cc/BUILD.bazel index 886701112e..9b060caf43 100644 --- a/src/cc/BUILD.bazel +++ b/src/cc/BUILD.bazel @@ -1,6 +1,8 @@ +load("@mujoco//tools:def.bzl", "mj_cc_library") + package(default_visibility = ["@mujoco//:__subpackages__"]) -cc_library( +mj_cc_library( name = "array_safety", hdrs = ["array_safety.h"], target_compatible_with = ["@platforms//os:linux"], diff --git a/src/engine/BUILD.bazel b/src/engine/BUILD.bazel index cecf3d8beb..a5aab9e1f1 100644 --- a/src/engine/BUILD.bazel +++ b/src/engine/BUILD.bazel @@ -1,8 +1,9 @@ load("//src/engine:helper.bzl", "THIN_LTO_FEATURE_IF_CLANG", "THIN_LTO_LINKOPTS_IF_CLANG") +load("@mujoco//tools:def.bzl", "mj_cc_library") package(default_visibility = ["@mujoco//:__subpackages__"]) -cc_library( +mj_cc_library( name = "engine", srcs = [ "engine_collision_driver.c", @@ -45,7 +46,6 @@ cc_library( "engine_vis_visualize.h", ], copts = [ - "-Wno-unknown-pragmas", "-Wno-error=unknown-pragmas", "-Wshadow", "-Isrc", @@ -92,7 +92,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "engine_array_safety", copts = ["-Wshadow"], features = THIN_LTO_FEATURE_IF_CLANG, @@ -101,7 +101,7 @@ cc_library( textual_hdrs = ["engine_array_safety.h"], ) -cc_library( +mj_cc_library( name = "engine_callback", srcs = ["engine_callback.c"], hdrs = ["engine_callback.h"], @@ -122,7 +122,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "engine_collision_box", srcs = [ "engine_collision_box.c", @@ -146,7 +146,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "engine_collision_convex", srcs = [ "engine_collision_convex.c", @@ -157,7 +157,6 @@ cc_library( "engine_collision_gjk.h", ], copts = [ - "-Wno-unknown-pragmas", "-Wno-error=unknown-pragmas", "-Wshadow", "-Isrc", @@ -182,7 +181,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "engine_collision_primitive", srcs = ["engine_collision_primitive.c"], hdrs = ["engine_collision_primitive.h"], @@ -206,7 +205,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "engine_crossplatform", srcs = ["engine_crossplatform.cc"], hdrs = ["engine_crossplatform.h"], @@ -224,12 +223,11 @@ cc_library( target_compatible_with = ["@platforms//os:linux"], ) -cc_library( +mj_cc_library( name = "engine_io", srcs = ["engine_io.c"], hdrs = ["engine_io.h"], copts = [ - "-Wno-unknown-pragmas", "-Wno-error=unknown-pragmas", "-Wno-type-limits", "-Wshadow", @@ -255,7 +253,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "engine_macro", hdrs = ["engine_macro.h"], copts = ["-Wshadow"], @@ -268,7 +266,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "engine_name", srcs = ["engine_name.c"], hdrs = ["engine_name.h"], @@ -291,7 +289,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "engine_plugin", srcs = ["engine_plugin.cc"], hdrs = [ @@ -299,7 +297,6 @@ cc_library( "engine_plugin.h", ], copts = [ - "-Wno-unknown-pragmas", "-Wno-error=unknown-pragmas", "-Wshadow", "-Isrc", @@ -318,12 +315,11 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "engine_ray", srcs = ["engine_ray.c"], hdrs = ["engine_ray.h"], copts = [ - "-Wno-unknown-pragmas", "-Wno-error=unknown-pragmas", "-Wshadow", "-Isrc", @@ -347,7 +343,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "engine_sort", hdrs = ["engine_sort.h"], copts = ["-Wshadow"], @@ -356,7 +352,7 @@ cc_library( target_compatible_with = ["@platforms//os:linux"], ) -cc_library( +mj_cc_library( name = "engine_util_blas", srcs = ["engine_util_blas.c"], hdrs = ["engine_util_blas.h"], @@ -380,7 +376,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "engine_util_container", srcs = ["engine_util_container.c"], hdrs = ["engine_util_container.h"], @@ -400,12 +396,11 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "engine_util_errmem", srcs = ["engine_util_errmem.c"], hdrs = ["engine_util_errmem.h"], copts = [ - "-Wno-unknown-pragmas", "-Wno-error=unknown-pragmas", "-Wshadow", "-Isrc", @@ -425,12 +420,11 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "engine_util_misc", srcs = ["engine_util_misc.c"], hdrs = ["engine_util_misc.h"], copts = [ - "-Wno-unknown-pragmas", "-Wno-error=unknown-pragmas", "-Wshadow", "-Isrc", @@ -453,7 +447,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "engine_util_sparse", srcs = [ "engine_util_sparse.c", @@ -486,12 +480,11 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "engine_util_spatial", srcs = ["engine_util_spatial.c"], hdrs = ["engine_util_spatial.h"], copts = [ - "-Wno-unknown-pragmas", "-Wno-error=unknown-pragmas", "-Wshadow", "-Isrc", @@ -511,12 +504,11 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "engine_util_solve", srcs = ["engine_util_solve.c"], hdrs = ["engine_util_solve.h"], copts = [ - "-Wno-unknown-pragmas", "-Wno-error=unknown-pragmas", "-Wshadow", "-Isrc", @@ -540,12 +532,11 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "engine_vis_init", srcs = ["engine_vis_init.c"], hdrs = ["engine_vis_init.h"], copts = [ - "-Wno-unknown-pragmas", "-Wno-error=unknown-pragmas", "-Wshadow", "-Isrc", diff --git a/src/render/BUILD.bazel b/src/render/BUILD.bazel index d421951768..60f279648b 100644 --- a/src/render/BUILD.bazel +++ b/src/render/BUILD.bazel @@ -1,8 +1,8 @@ -licenses(["notice"]) +load("@mujoco//tools:def.bzl", "mj_cc_library") package(default_visibility = ["@mujoco//:__subpackages__"]) -cc_library( +mj_cc_library( name = "glad", srcs = [ "glad/glad.c", @@ -10,7 +10,6 @@ cc_library( ], hdrs = ["glad/glad.h"], copts = [ - "-Wno-unknown-pragmas", "-Wno-error=unknown-pragmas", "-Isrc", ], @@ -19,7 +18,7 @@ cc_library( deps = ["//src/engine:engine_util_errmem"], ) -cc_library( +mj_cc_library( name = "render", target_compatible_with = ["@platforms//os:linux"], deps = [ @@ -31,7 +30,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "render_context", srcs = ["render_context.c"], hdrs = ["render_context.h"], @@ -49,7 +48,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "render_gl2", srcs = ["render_gl2.c"], hdrs = ["render_gl2.h"], @@ -64,7 +63,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "render_gl3", srcs = ["render_gl3.c"], hdrs = ["render_gl3.h"], @@ -88,7 +87,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "render_util", srcs = ["render_util.c"], hdrs = ["render_util.h"], diff --git a/src/thread/BUILD.bazel b/src/thread/BUILD.bazel index 45b5ad806c..fc073b4524 100644 --- a/src/thread/BUILD.bazel +++ b/src/thread/BUILD.bazel @@ -1,15 +1,14 @@ -# Threading library for MuJoCo. -licenses(["notice"]) +load("@mujoco//tools:def.bzl", "mj_cc_library") package(default_visibility = ["@mujoco//:__subpackages__"]) -cc_library( +mj_cc_library( name = "thread_queue", hdrs = ["thread_queue.h"], target_compatible_with = ["@platforms//os:linux"], ) -cc_library( +mj_cc_library( name = "thread_task", srcs = ["thread_task.cc"], hdrs = ["thread_task.h"], @@ -20,12 +19,11 @@ cc_library( deps = ["//:mujoco_hdrs"], ) -cc_library( +mj_cc_library( name = "thread_pool", srcs = ["thread_pool.cc"], hdrs = ["thread_pool.h"], copts = [ - "-Wno-unknown-pragmas", "-Wno-error=unknown-pragmas", "-Isrc", ], diff --git a/src/ui/BUILD.bazel b/src/ui/BUILD.bazel index 70f153572d..ab9d9841e3 100644 --- a/src/ui/BUILD.bazel +++ b/src/ui/BUILD.bazel @@ -1,6 +1,8 @@ +load("@mujoco//tools:def.bzl", "mj_cc_library") + package(default_visibility = ["@mujoco//:__subpackages__"]) -cc_library( +mj_cc_library( name = "ui_main", srcs = ["ui_main.c"], hdrs = ["ui_main.h"], diff --git a/src/user/BUILD.bazel b/src/user/BUILD.bazel index 8ab460a0e5..9853cb2040 100644 --- a/src/user/BUILD.bazel +++ b/src/user/BUILD.bazel @@ -1,14 +1,14 @@ +load("@mujoco//tools:def.bzl", "mj_cc_library") + package(default_visibility = ["@mujoco//:__subpackages__"]) -cc_library( +mj_cc_library( name = "user_flexcomp", srcs = ["user_flexcomp.cc"], hdrs = ["user_flexcomp.h"], copts = [ - "-Wno-unknown-pragmas", "-Wno-error=unknown-pragmas", "-Wno-type-limits", - "-Wno-sign-compare", "-fexceptions", "-Isrc", ], @@ -25,14 +25,12 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "user_composite", srcs = ["user_composite.cc"], hdrs = ["user_composite.h"], copts = [ - "-Wno-unknown-pragmas", "-Wno-error=unknown-pragmas", - "-Wno-sign-compare", "-fexceptions", "-Isrc", ], @@ -49,7 +47,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "user_model", srcs = [ "user_api.cc", @@ -64,18 +62,11 @@ cc_library( "user_objects.h", ], copts = [ - "-Wno-unknown-pragmas", "-Wno-error=unknown-pragmas", - "-Wno-sign-compare", "-fexceptions", "-Isrc", "-Iexternal/qhull/src/libqhull_r", - ] + select({ - "//tools:gcc": [ - "-Wno-maybe-uninitialized", - ], - "//conditions:default": [], - }), + ], features = ["-use_header_modules"], local_defines = [ "_GNU_SOURCE", @@ -103,12 +94,11 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "user_util", srcs = ["user_util.cc"], hdrs = ["user_util.h"], copts = [ - "-Wno-sign-compare", "-Isrc", ], target_compatible_with = ["@platforms//os:linux"], @@ -118,7 +108,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "user_cache", srcs = ["user_cache.cc"], hdrs = ["user_cache.h"], @@ -132,7 +122,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "user_resource", srcs = ["user_resource.cc"], hdrs = ["user_resource.h"], @@ -150,7 +140,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "user_vfs", srcs = ["user_vfs.cc"], hdrs = ["user_vfs.h"], diff --git a/src/xml/BUILD.bazel b/src/xml/BUILD.bazel index 44a65ee66f..0da269c3f8 100644 --- a/src/xml/BUILD.bazel +++ b/src/xml/BUILD.bazel @@ -1,8 +1,10 @@ +load("@mujoco//tools:def.bzl", "mj_cc_library") + package(default_visibility = ["@mujoco//:__subpackages__"]) exports_files(["xml_native_reader.cc"]) -cc_library( +mj_cc_library( name = "xml", srcs = ["xml.cc"], hdrs = ["xml.h"], @@ -27,19 +29,13 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "xml_api", srcs = ["xml_api.cc"], hdrs = ["xml_api.h"], copts = [ - "-Wno-sign-compare", "-Isrc", - ] + select({ - "//tools:gcc": [ - "-Wno-maybe-uninitialized", - ], - "//conditions:default": [], - }), + ], features = ["-use_header_modules"], target_compatible_with = ["@platforms//os:linux"], deps = [ @@ -53,7 +49,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "xml_base", srcs = ["xml_base.cc"], hdrs = ["xml_base.h"], @@ -70,13 +66,11 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "xml_native_reader", srcs = ["xml_native_reader.cc"], hdrs = ["xml_native_reader.h"], copts = [ - "-Wno-sign-compare", - "-Wno-unknown-pragmas", "-Wno-error=unknown-pragmas", "-fexceptions", "-Isrc", @@ -98,13 +92,11 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "xml_native_writer", srcs = ["xml_native_writer.cc"], hdrs = ["xml_native_writer.h"], copts = [ - "-Wno-sign-compare", - "-Wno-unknown-pragmas", "-Wno-error=unknown-pragmas", "-fexceptions", "-Isrc", @@ -125,12 +117,11 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "xml_urdf", srcs = ["xml_urdf.cc"], hdrs = ["xml_urdf.h"], copts = [ - "-Wno-sign-compare", "-fexceptions", "-Isrc", ], @@ -147,13 +138,11 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "xml_util", srcs = ["xml_util.cc"], hdrs = ["xml_util.h"], copts = [ - "-Wno-sign-compare", - "-Wno-unknown-pragmas", "-Wno-error=unknown-pragmas", "-fexceptions", "-Isrc", @@ -171,7 +160,7 @@ cc_library( ], ) -cc_library( +mj_cc_library( name = "xml_numeric_format", srcs = ["xml_numeric_format.cc"], hdrs = ["xml_numeric_format.h"], diff --git a/test/BUILD.bazel b/test/BUILD.bazel index ae55b1c2c2..aca9c970b0 100644 --- a/test/BUILD.bazel +++ b/test/BUILD.bazel @@ -5,11 +5,11 @@ cc_library( testonly = True, srcs = ["fixture.cc"], hdrs = ["fixture.h"], - copts = [ - "-Wno-sign-compare", + implementation_deps = [ + "//:mujoco", ], deps = [ - "//:mujoco", + "//:mujoco_hdrs", "//plugin/actuator:register", "//plugin/elasticity:register", "//plugin/sdf:register", @@ -30,8 +30,10 @@ cc_test( srcs = ["fixture_test.cc"], deps = [ ":fixture", + "//:mujoco", "@googletest//:gtest_main", ], + linkstatic=True, ) cc_test( @@ -40,8 +42,10 @@ cc_test( srcs = ["header_test.cc"], deps = [ ":fixture", + "//:mujoco", "@googletest//:gtest_main", ], + linkstatic=True, ) cc_test( @@ -53,6 +57,8 @@ cc_test( ], deps = [ ":fixture", + "//:mujoco", "@googletest//:gtest_main", ], + linkstatic=True, ) diff --git a/test/engine/BUILD.bazel b/test/engine/BUILD.bazel index d1f0a22b28..4f1b9bc60b 100644 --- a/test/engine/BUILD.bazel +++ b/test/engine/BUILD.bazel @@ -52,8 +52,10 @@ cc_test( ], env = PLUGIN_DIR, deps = [ + "//:mujoco", "//src/engine:engine_util_container", "//test:fixture", "@googletest//:gtest_main", ], + linkstatic=True, ) diff --git a/test/plugin/actuator/BUILD.bazel b/test/plugin/actuator/BUILD.bazel index e919c62311..b86ef60ba0 100644 --- a/test/plugin/actuator/BUILD.bazel +++ b/test/plugin/actuator/BUILD.bazel @@ -12,4 +12,5 @@ cc_test( "@abseil-cpp//absl/strings:string_view", "@googletest//:gtest_main", ], + linkstatic=True, ) diff --git a/test/plugin/elasticity/BUILD.bazel b/test/plugin/elasticity/BUILD.bazel index 8d87aaa036..b38d0947d8 100644 --- a/test/plugin/elasticity/BUILD.bazel +++ b/test/plugin/elasticity/BUILD.bazel @@ -17,4 +17,5 @@ cc_test( "@abseil-cpp//absl/strings:string_view", "@googletest//:gtest_main", ], + linkstatic=True, ) diff --git a/test/plugin/sensor/BUILD.bazel b/test/plugin/sensor/BUILD.bazel index 3a81b937fb..7e41fa43c9 100644 --- a/test/plugin/sensor/BUILD.bazel +++ b/test/plugin/sensor/BUILD.bazel @@ -10,4 +10,5 @@ cc_test( "//test:fixture", "@googletest//:gtest_main", ], + linkstatic=True, ) diff --git a/test/thread/BUILD.bazel b/test/thread/BUILD.bazel index a60b323e8c..2dbb6ab54e 100644 --- a/test/thread/BUILD.bazel +++ b/test/thread/BUILD.bazel @@ -9,8 +9,10 @@ cc_test( "-Wno-sign-compare", ], deps = [ + "//:mujoco", "//src/engine:engine_util_container", "//test:fixture", "@googletest//:gtest_main", ], + linkstatic=True, ) diff --git a/test/user/BUILD.bazel b/test/user/BUILD.bazel index 4c5e2161bd..176c7b7939 100644 --- a/test/user/BUILD.bazel +++ b/test/user/BUILD.bazel @@ -30,6 +30,7 @@ cc_test( ], env = PLUGIN_DIR, deps = [ + "//:mujoco", "//src/user:user_cache", "//src/user:user_resource", "//src/user:user_util", @@ -37,4 +38,5 @@ cc_test( "//test:fixture", "@googletest//:gtest_main", ], + linkstatic=True, ) diff --git a/test/xml/BUILD.bazel b/test/xml/BUILD.bazel index 3e2689e46e..cd7a29076d 100644 --- a/test/xml/BUILD.bazel +++ b/test/xml/BUILD.bazel @@ -34,4 +34,5 @@ cc_test( "@abseil-cpp//absl/strings:str_format", "@googletest//:gtest_main", ], + linkstatic=True, ) diff --git a/tools/def.bzl b/tools/def.bzl new file mode 100644 index 0000000000..ee18238bf7 --- /dev/null +++ b/tools/def.bzl @@ -0,0 +1,51 @@ +def _append(a, b): + if b == None: + return a + else: + return a + b + +def _get_default_copts(): + return [ + "-fvisibility=hidden", + "-Werror", + "-Wall", + "-Wpedantic", + "-Wimplicit-fallthrough", + "-Wunused", + "-Wvla", + "-Wno-int-in-bool-context", + "-Wno-sign-compare", + "-Wno-unknown-pragmas", + ] + select({ + "//tools:gcc": [ + "-Wno-maybe-uninitialized", + ], + "//tools:clang": [ + "-Wno-unused-but-set-variable", + ], + "//conditions:default": [], + }) + +def _get_default_defines(): + return [] + +def _get_default_deps(): + return [] + +def _get_default_linkopts(): + return [ + "-Wl,--gc-sections", + ] + + +def mj_cc_library(name, deps = None, srcs = None, hdrs = None, copts = None, defines = None, linkopts = None, **kwargs): + native.cc_library( + name = name, + deps = _append(_get_default_deps(), deps), + srcs = srcs, + hdrs = hdrs, + copts = _append(_get_default_copts(), copts), + defines = _append(_get_default_defines(), defines), + linkopts = _append(_get_default_linkopts(), linkopts), + **kwargs + ) From 001ba94e0bde73069ff3d265454065d57aee1cab Mon Sep 17 00:00:00 2001 From: Junhyeok Ahn Date: Sat, 22 Feb 2025 20:39:49 -0500 Subject: [PATCH 7/7] rebase onto the latest master --- mjx/mujoco/mjx/BUILD.bazel | 2 + python/mujoco/BUILD.bazel | 39 +++++++++++++------- python/mujoco/codegen/BUILD.bazel | 12 +++--- python/mujoco/enums.cc | 2 +- python/mujoco/introspect/BUILD.bazel | 6 +++ python/mujoco/introspect/codegen/BUILD.bazel | 10 ++--- test/benchmark/BUILD.bazel | 5 +++ test/benchmark/ccd_benchmark_test.cc | 2 +- test/engine/BUILD.bazel | 3 ++ test/user/BUILD.bazel | 1 + 10 files changed, 55 insertions(+), 27 deletions(-) diff --git a/mjx/mujoco/mjx/BUILD.bazel b/mjx/mujoco/mjx/BUILD.bazel index da93bd5307..7652fd8064 100644 --- a/mjx/mujoco/mjx/BUILD.bazel +++ b/mjx/mujoco/mjx/BUILD.bazel @@ -268,6 +268,7 @@ py_library( ":scan", ":types", "//:mujoco-py", + "//python/mujoco/introspect:mjxmacro", requirement("jax"), requirement("numpy"), ], @@ -478,6 +479,7 @@ py_test( requirement("absl-py"), requirement("numpy"), requirement("trimesh"), + requirement("typing_extensions"), ], ) diff --git a/python/mujoco/BUILD.bazel b/python/mujoco/BUILD.bazel index 2393238b21..b8e5edab9a 100644 --- a/python/mujoco/BUILD.bazel +++ b/python/mujoco/BUILD.bazel @@ -251,7 +251,11 @@ pybind_extension( pybind_extension( name = "_rollout", - srcs = ["rollout.cc"], + srcs = [ + "rollout.cc", + "threadpool.h", + "threadpool.cc" + ], dynamic_deps = [ "//:mujoco_shared", ], @@ -358,6 +362,7 @@ py_test( ":mujoco-py", requirement("absl-py"), requirement("numpy"), + requirement("typing-extensions"), ], ) @@ -393,22 +398,26 @@ py_test( ":mujoco-py", requirement("absl-py"), requirement("numpy"), + requirement("typing-extensions"), ], ) -# This fails due to the missing pystub -# py_test( -# name = "specs_test", -# srcs = ["specs_test.py"], -# data = [ -# "//:test_data", -# ], -# deps = [ -# ":mujoco-py", -# requirement("absl-py"), -# requirement("numpy"), -# ], -# ) +py_test( + name = "specs_test", + srcs = ["specs_test.py"], + data = [ + "//python/mujoco/testdata:model", + ":symlinked_plugins", + ], + deps = [ + ":mujoco-py", + requirement("absl-py"), + requirement("numpy"), + requirement("etils"), + requirement("typing-extensions"), + requirement("importlib-resources"), + ], +) py_test( name = "minimize_test", @@ -418,6 +427,7 @@ py_test( ":mujoco-py", requirement("absl-py"), requirement("numpy"), + requirement("typing-extensions"), ], ) @@ -456,5 +466,6 @@ py_test( deps = [ ":mujoco-py", requirement("absl-py"), + requirement("typing-extensions"), ], ) diff --git a/python/mujoco/codegen/BUILD.bazel b/python/mujoco/codegen/BUILD.bazel index 3a7fca3d0c..3e439310c4 100644 --- a/python/mujoco/codegen/BUILD.bazel +++ b/python/mujoco/codegen/BUILD.bazel @@ -6,8 +6,8 @@ py_binary( name = "generate_enum_traits", srcs = ["generate_enum_traits.py"], deps = [ - "//introspect:ast_nodes", - "//introspect:enums", + "//python/mujoco/introspect:ast_nodes", + "//python/mujoco/introspect:enums", requirement("absl-py"), ], ) @@ -16,8 +16,8 @@ py_binary( name = "generate_function_traits", srcs = ["generate_function_traits.py"], deps = [ - "//introspect:ast_nodes", - "//introspect:functions", + "//python/mujoco/introspect:ast_nodes", + "//python/mujoco/introspect:functions", requirement("absl-py"), ], ) @@ -26,8 +26,8 @@ py_binary( name = "generate_spec_bindings", srcs = ["generate_spec_bindings.py"], deps = [ - "//introspect:ast_nodes", - "//introspect:structs", + "//python/mujoco/introspect:ast_nodes", + "//python/mujoco/introspect:structs", requirement("absl-py"), ], ) diff --git a/python/mujoco/enums.cc b/python/mujoco/enums.cc index c13bac6fc6..640e7c0c30 100644 --- a/python/mujoco/enums.cc +++ b/python/mujoco/enums.cc @@ -44,7 +44,7 @@ inline T FloorDiv(T a, T b) { template void DefEnum(py::module_& m) { - py::enum_ e(m, Trait::name, py::module_local()); + py::enum_ e(m, Trait::name); for (const auto& [name, enumerator] : Trait::values) { e.value(name, enumerator); } diff --git a/python/mujoco/introspect/BUILD.bazel b/python/mujoco/introspect/BUILD.bazel index 535f009031..e80761a9ee 100644 --- a/python/mujoco/introspect/BUILD.bazel +++ b/python/mujoco/introspect/BUILD.bazel @@ -29,3 +29,9 @@ py_library( srcs = ["structs.py"], deps = [":ast_nodes"], ) + +py_library( + name = "mjxmacro", + srcs = ["mjxmacro.py"], + deps = [":structs"], +) diff --git a/python/mujoco/introspect/codegen/BUILD.bazel b/python/mujoco/introspect/codegen/BUILD.bazel index 27a5f57d71..29e4dbf3e7 100644 --- a/python/mujoco/introspect/codegen/BUILD.bazel +++ b/python/mujoco/introspect/codegen/BUILD.bazel @@ -24,7 +24,7 @@ py_binary( srcs = ["generate_enums.py"], deps = [ ":formatter", - "//introspect:ast_nodes", + "//python/mujoco/introspect:ast_nodes", requirement("absl-py"), "@abseil-cpp//absl/flags:flag", ], @@ -50,8 +50,8 @@ py_binary( srcs = ["generate_functions.py"], deps = [ ":formatter", - "//introspect:ast_nodes", - "//introspect:type_parsing", + "//python/mujoco/introspect:ast_nodes", + "//python/mujoco/introspect:type_parsing", requirement("absl-py"), "@abseil-cpp//absl/flags:flag", ], @@ -78,8 +78,8 @@ py_binary( srcs = ["generate_structs.py"], deps = [ ":formatter", - "//introspect:ast_nodes", - "//introspect:type_parsing", + "//python/mujoco/introspect:ast_nodes", + "//python/mujoco/introspect:type_parsing", requirement("absl-py"), "@abseil-cpp//absl/flags:flag", ], diff --git a/test/benchmark/BUILD.bazel b/test/benchmark/BUILD.bazel index 0a248d6053..a1d284445b 100644 --- a/test/benchmark/BUILD.bazel +++ b/test/benchmark/BUILD.bazel @@ -4,6 +4,11 @@ names = [ "engine_util_spatial_benchmark_test", "engine_core_smooth_benchmark_test", "engine_util_sparse_benchmark_test", + "ccd_benchmark_test", + "factorI_benchmark_test", + "inertia_benchmark_test", + "solveLD_benchmark_test", + "thread_performance_test", ] [ diff --git a/test/benchmark/ccd_benchmark_test.cc b/test/benchmark/ccd_benchmark_test.cc index aaf093597b..5c46475741 100644 --- a/test/benchmark/ccd_benchmark_test.cc +++ b/test/benchmark/ccd_benchmark_test.cc @@ -19,7 +19,7 @@ #include #include -#include +#include "absl/base/attributes.h" #include #include #include "test/fixture.h" diff --git a/test/engine/BUILD.bazel b/test/engine/BUILD.bazel index 4f1b9bc60b..51d5a56937 100644 --- a/test/engine/BUILD.bazel +++ b/test/engine/BUILD.bazel @@ -22,6 +22,7 @@ cc_test( "engine_ray_test.cc", "engine_sensor_test.cc", "engine_solver_test.cc", + "engine_sort_test.cc", "engine_support_test.cc", "engine_thread_test.cc", "engine_util_blas_test.cc", @@ -32,6 +33,7 @@ cc_test( "engine_util_sparse_test.cc", "engine_util_spatial_test.cc", "engine_vis_state_test.cc", + "engine_vis_visualize_test.cc", ], copts = [ "-Wno-dangling-else", @@ -54,6 +56,7 @@ cc_test( deps = [ "//:mujoco", "//src/engine:engine_util_container", + "//src/engine:engine_util_sparse", "//test:fixture", "@googletest//:gtest_main", ], diff --git a/test/user/BUILD.bazel b/test/user/BUILD.bazel index 176c7b7939..314bdb6186 100644 --- a/test/user/BUILD.bazel +++ b/test/user/BUILD.bazel @@ -35,6 +35,7 @@ cc_test( "//src/user:user_resource", "//src/user:user_util", "//src/user:user_vfs", + "//src/cc:array_safety", "//test:fixture", "@googletest//:gtest_main", ],