-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_macos_wheel.sh
More file actions
executable file
·120 lines (91 loc) · 3.37 KB
/
build_macos_wheel.sh
File metadata and controls
executable file
·120 lines (91 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env bash
set -e
build_type="Release"
echo "Going back to the root of the project"
ROOT_DIR="$(pwd)"
cd ${ROOT_DIR}
if [ ! -d "${ROOT_DIR}/install" ]; then
mkdir install
fi
SHOW_HELP=false
build_filament=OFF
build_with_vulkan=OFF
build_studio=OFF
build_simulate=ON
njobs=4
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help) SHOW_HELP=true; shift ;;
--debug) build_type="Debug"; shift ;;
--filament) build_filament=ON; shift ;;
--vulkan) build_with_vulkan=ON; shift ;;
--studio) build_studio=ON; shift ;;
--njobs) njobs="$2"; shift 2 ;;
--install-dir) install_dir="$2"; shift 2 ;;
*) echo "Unkown option: $1"; exit 1 ;;
esac
done
[[ -n $install_dir ]] && USER_INSTALL_DIR="${install_dir}" || USER_INSTALL_DIR="${ROOT_DIR}/install"
if [ ! -d "${USER_INSTALL_DIR}" ]; then
mkdir -p $USER_INSTALL_DIR
fi
if [[ "${build_filament}" == "ON" ]]; then
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
build_simulate=OFF
build_studio=ON
fi
echo "Configuring ..."
CMAKE_CONFIG_ARGS=(
"-DCMAKE_BUILD_TYPE=${build_type}"
"-DUSE_STATIC_LIBCXX=OFF"
"-DBUILD_SHARED_LIBS=OFF"
"-DMUJOCO_BUILD_EXAMPLES=OFF"
"-DMUJOCO_BUILD_SIMULATE=${build_simulate}"
"-DMUJOCO_BUILD_TESTS=OFF"
"-DMUJOCO_WITH_USD=OFF"
"-DMUJOCO_TEST_AI2=ON"
"-DMUJOCO_USE_FILAMENT=${build_filament}"
"-DMUJOCO_USE_FILAMENT_MJR_COMPAT=${build_filament}"
"-DMUJOCO_USE_FILAMENT_VULKAN=OFF"
"-DFILAMENT_SUPPORTS_VULKAN=OFF"
"-DFILAMENT_SUPPORTS_METAL=OFF"
"-DMUJOCO_BUILD_STUDIO=${build_studio}"
"-DCMAKE_INSTALL_PREFIX=${USER_INSTALL_DIR}"
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF"
)
if [[ -n "${CMAKE_ARGS}" ]]; then
read -a cmake_args_arr <<<"$CMAKE_ARGS"
CMAKE_CONFIG_ARGS+=("${cmake_args_arr[@]}")
fi
cmake -B build "${CMAKE_CONFIG_ARGS[@]}"
echo "Building ..."
cmake --build build --config="${build_type}" --parallel ${njobs}
echo "Installing to target dir ..."
cmake --install build
echo "Copy plugins to install directory"
mkdir -p install/mujoco_plugin
cp ${ROOT_DIR}/build/lib/libactuator.* ${ROOT_DIR}/install/mujoco_plugin
cp ${ROOT_DIR}/build/lib/libelasticity.* ${ROOT_DIR}/install/mujoco_plugin
cp ${ROOT_DIR}/build/lib/libsensor.* ${ROOT_DIR}/install/mujoco_plugin
cp ${ROOT_DIR}/build/lib/libsdf_plugin.* ${ROOT_DIR}/install/mujoco_plugin
if [[ "${build_filament}" == "ON" ]]; then
echo "Copy filament assets to install directory"
mkdir -p install/filament/assets
cp ${ROOT_DIR}/build/bin/assets/*.filamat ${ROOT_DIR}/install/filament/assets
cp ${ROOT_DIR}/build/bin/assets/*.ktx ${ROOT_DIR}/install/filament/assets
cp ${ROOT_DIR}/build/bin/assets/*.ttf ${ROOT_DIR}/install/filament/assets
fi
echo "Make source distribution"
bash ${ROOT_DIR}/python/make_sdist_macos.sh
echo "Build python wheel"
export MUJOCO_PATH="${ROOT_DIR}/install"
export MUJOCO_PLUGIN_PATH="${ROOT_DIR}/install/mujoco_plugin"
MUJOCO_CMAKE_ARGS=""
MUJOCO_FILAMENT_ASSETS=""
if [[ "${build_filament}" == "ON" ]]; then
MUJOCO_FILAMENT_ASSETS="${ROOT_DIR}/install/filament/assets"
fi
MUJOCO_CMAKE_ARGS="${MUJOCO_CMAKE_ARGS}" MUJOCO_FILAMENT_ASSETS="${MUJOCO_FILAMENT_ASSETS}" uv build --wheel --force-pep517 ${ROOT_DIR}/python/dist/mujoco-*.tar.gz --out-dir ${ROOT_DIR}/python/dist
# Clean install dir afterwards, to avoid being used as default search path
rm -rf ${USER_INSTALL_DIR}