-
-
Notifications
You must be signed in to change notification settings - Fork 494
mujoco: add package #8810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
mujoco: add package #8810
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| package("mujoco") | ||
| set_homepage("https://www.ada-url.com") | ||
| set_description("Multi-Joint dynamics with Contact. A general purpose physics simulator.") | ||
| set_license("Apache-2.0") | ||
|
|
||
| set_urls("https://github.com/google-deepmind/mujoco/archive/refs/tags/$(version).tar.gz", | ||
| "https://github.com/google-deepmind/mujoco.git") | ||
|
|
||
| add_versions("3.4.0", "adff5e9397aac20189ee1525aabf1fbecc63c43697e8ad66a61220222983810f") | ||
|
|
||
| add_configs("simulate", {description = "Build simulate library for MuJoCo", default = false, type = "boolean"}) | ||
| add_configs("usd", {description = "Build with OpenUSD", default = false, type = "boolean"}) | ||
|
|
||
| add_links("simulate", "mujoco") | ||
|
|
||
| add_deps("cmake") | ||
| if is_subhost("windows") then | ||
| add_deps("pkgconf") | ||
| else | ||
| add_deps("pkg-config") | ||
| end | ||
| add_deps("libccd", "lodepng", "qhull", "tinyobjloader", "tinyxml2", "trianglemeshdistance", "marchingcubecpp") | ||
|
|
||
| on_load(function (package) | ||
| if package:config("usd") then | ||
| package:add("deps", "usd") | ||
| package:add("defines", "mjUSEUSD") | ||
| end | ||
| if package:config("simulate") then | ||
| package:add("deps", "glfw") | ||
| end | ||
|
|
||
| if not package:config("shared") then | ||
| package:add("defines", "MJ_STATIC") | ||
| end | ||
| end) | ||
|
|
||
| on_install(function (package) | ||
| if package:dep("qhull"):config("shared") then | ||
| raise("package(mujoco) unsupported shared qhull library") | ||
| end | ||
|
|
||
| io.replace("CMakeLists.txt", "add_library(mujoco SHARED", "add_library(mujoco ", {plain = true}) | ||
| io.replace("CMakeLists.txt", "include(MujocoDependencies)", "", {plain = true}) | ||
| io.replace("CMakeLists.txt", "CCD_STATIC_DEFINE MUJOCO_DLL_EXPORTS", "", {plain = true}) | ||
|
|
||
| io.replace("cmake/MujocoOptions.cmake", "-Werror", "", {plain = true}) | ||
| io.replace("simulate/cmake/SimulateOptions.cmake", "-Werror", "", {plain = true}) | ||
|
|
||
| io.replace("src/user/user_mesh.cc", [[#include "qhull_ra.h"]], "#include <libqhull_r/qhull_ra.h>", {plain = true}) | ||
| io.replace("src/user/user_mesh.cc", | ||
| "#include <TriangleMeshDistance/include/tmd/TriangleMeshDistance.h>", | ||
| "#include <tmd/TriangleMeshDistance.h>", {plain = true}) | ||
|
|
||
| io.replace("CMakeLists.txt", [[target_link_libraries( | ||
| mujoco | ||
| PRIVATE ccd | ||
| lodepng | ||
| qhullstatic_r | ||
| tinyobjloader | ||
| tinyxml2 | ||
| )]], "", {plain = true}) | ||
|
|
||
| local file = io.open("CMakeLists.txt", "a") | ||
| if file then | ||
| file:print([[ | ||
| if (BUILD_SHARED_LIBS) | ||
| target_compile_definitions(mujoco PRIVATE MUJOCO_DLL_EXPORTS) | ||
| else() | ||
| target_compile_definitions(mujoco PUBLIC MJ_STATIC) | ||
| endif() | ||
|
|
||
| find_package(ccd CONFIG REQUIRED) | ||
| include(FindPkgConfig) | ||
| pkg_search_module("lodepng" REQUIRED IMPORTED_TARGET "lodepng") | ||
| find_package(Qhull CONFIG REQUIRED) | ||
| find_package(tinyobjloader CONFIG REQUIRED) | ||
| find_package(tinyxml2 CONFIG REQUIRED) | ||
| pkg_search_module("trianglemeshdistance" REQUIRED IMPORTED_TARGET "trianglemeshdistance") | ||
| pkg_search_module("marchingcubecpp" REQUIRED IMPORTED_TARGET "marchingcubecpp") | ||
| target_link_libraries(mujoco PRIVATE | ||
| ccd | ||
| PkgConfig::lodepng | ||
| Qhull::qhullcpp | ||
star-hengxing marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| tinyobjloader::tinyobjloader | ||
| tinyxml2::tinyxml2 | ||
| PkgConfig::trianglemeshdistance | ||
| PkgConfig::marchingcubecpp | ||
| ) | ||
| ]]) | ||
| file:close() | ||
| end | ||
|
|
||
| if package:config("simulate") then | ||
| io.replace("simulate/CMakeLists.txt", "include(SimulateDependencies)", "", {plain = true}) | ||
| io.replace("simulate/CMakeLists.txt", "if(NOT TARGET lodepng)", "if(0)", {plain = true}) | ||
| io.replace("simulate/CMakeLists.txt", | ||
| "add_library(libmujoco_simulate STATIC $<TARGET_OBJECTS:platform_ui_adapter> $<TARGET_OBJECTS:lodepng>)", | ||
| [[ | ||
| add_library(libmujoco_simulate STATIC $<TARGET_OBJECTS:platform_ui_adapter>) | ||
| include(FindPkgConfig) | ||
| pkg_search_module("lodepng" REQUIRED IMPORTED_TARGET "lodepng") | ||
| find_package(Qhull CONFIG REQUIRED) | ||
| find_package(glfw3 REQUIRED CONFIG) | ||
| target_link_libraries(libmujoco_simulate PRIVATE PkgConfig::lodepng Qhull::qhullstatic_r) | ||
star-hengxing marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ]], {plain = true}) | ||
| end | ||
|
|
||
| local configs = { | ||
| "-DMUJOCO_BUILD_EXAMPLES=OFF", | ||
| "-DMUJOCO_BUILD_TESTS=OFF", | ||
| "-DMUJOCO_BUILD_TESTS_WASM=OFF", | ||
| "-DMUJOCO_SIMULATE_USE_SYSTEM_GLFW=ON", | ||
| } | ||
| table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) | ||
| table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) | ||
|
|
||
| table.insert(configs, "-DMUJOCO_BUILD_SIMULATE=" .. (package:config("simulate") and "ON" or "OFF")) | ||
| table.insert(configs, "-DMUJOCO_WITH_USD=" .. (package:config("usd") and "ON" or "OFF")) | ||
| import("package.tools.cmake").install(package, configs) | ||
| end) | ||
|
|
||
| on_test(function (package) | ||
| assert(package:has_cfuncs("mjv_defaultCamera", {includes = "mujoco/mujoco.h"})) | ||
| end) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.