Skip to content

Instantly share code, notes, and snippets.

@terasakisatoshi
Created May 16, 2024 09:23
Show Gist options
  • Save terasakisatoshi/aa9a404eeb777159927587d6e88d2fae to your computer and use it in GitHub Desktop.
Save terasakisatoshi/aa9a404eeb777159927587d6e88d2fae to your computer and use it in GitHub Desktop.
How to Build Mujoco v3 using BinaryBuilder.jl
# Note that this script can accept some limited command-line arguments, run
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder
name = "MuJoCo"
version = v"3.1.5"
# Collection of sources required to build mujoco
sources = [
GitSource("https://github.com/deepmind/mujoco", "e001975f083e769898811763c4c887afb52523c2"),
DirectorySource("bundled")
]
# Bash recipe for building across all platforms
script = raw"""
cd $WORKSPACE/srcdir/mujoco
#if [[ "${target}" == *-mingw* ]]; then
# atomic_patch -p1 ../patches/mingw.patch
#if [[ "${target}" == *-apple-darwin* ]]; then
# atomic_patch -p1 ../patches/macos.patch
#else
atomic_patch -p1 ../patches/other.patch
#fi
CPPFLAGS="-I${prefix}/include"
CXXFLAGS="-I${prefix}/include"
cmake \
-DCMAKE_INSTALL_PREFIX=$prefix \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \
-DCMAKE_BUILD_TYPE=Release \
-DMUJOCO_BUILD_EXAMPLES=OFF \
-DMUJOCO_BUILD_SIMULATE=OFF \
-DMUJOCO_BUILD_TESTS=OFF \
-DMUJOCO_TEST_PYTHON_UTIL=OFF \
.
cmake --build .
cmake --install .
"""
# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
platforms = [
Platform("x86_64", "linux", libc="glibc"),
Platform("aarch64", "linux", libc="glibc"),
#Platform("powerpc64le", "linux", libc="glibc"),
#Platform("x86_64", "macos"),
#Platform("aarch64", "macos"),
#Platform("x86_64", "windows")
]
platforms = expand_cxxstring_abis(platforms)
products = [
LibraryProduct("libmujoco", :libmujoco)
]
linux_platforms = [p for p in platforms if Sys.islinux(p)]
# Dependencies that must be installed before this package can be built
dependencies = [
BuildDependency("Xorg_libX11_jll"; platforms=linux_platforms),
BuildDependency("Xorg_xorgproto_jll"; platforms=linux_platforms),
BuildDependency("GLFW_jll"; platforms=linux_platforms),
BuildDependency("Xorg_libXrandr_jll"; platforms=linux_platforms),
BuildDependency("Libglvnd_jll"; platforms=linux_platforms),
BuildDependency("Xorg_libXi_jll"; platforms=linux_platforms),
BuildDependency("Xorg_libXinerama_jll"; platforms=linux_platforms),
BuildDependency("Xorg_libXcursor_jll"; platforms=linux_platforms)
]
# Build the tarballs.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6", preferred_gcc_version=v"11.1.0")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment