-
Notifications
You must be signed in to change notification settings - Fork 2
/
build_third_parties.sh
executable file
·211 lines (167 loc) · 6.43 KB
/
build_third_parties.sh
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/bin/bash
CURRENT_DIR=$PWD
cd $(dirname $0)
MULTIVERSE_DIR=$PWD/multiverse
BIN_DIR=$MULTIVERSE_DIR/bin
if [ ! -d "$BIN_DIR" ]; then
# Create the folder if it doesn't exist
mkdir -p $BIN_DIR
fi
EXT_DIR=$MULTIVERSE_DIR/external
BUILD_DIR=$MULTIVERSE_DIR/build
SRC_DIR=$MULTIVERSE_DIR/src
INCLUDE_DIR=$MULTIVERSE_DIR/include
BUILD_BLENDER=true
BUILD_USD=true
BUILD_MUJOCO=true
BUILD_PYBIND11=true
while [ -n "$1" ]; do
case "$1" in
--excludes) echo -n "--excludes option passed"
shift 1
if [ "$#" -eq 0 ]; then
echo ""
BUILD_BLENDER=false
BUILD_USD=false
BUILD_MUJOCO=false
BUILD_PYBIND11=false
else
echo -n ", with value:"
for module in "$@"; do
echo -n " $module"
shift 1
if [ "$module" = "blender" ]; then
BUILD_BLENDER=OFF
elif [ "$module" = "usd" ]; then
BUILD_USD=OFF
elif [ "$module" = "mujoco" ]; then
BUILD_MUJOCO=OFF
elif [ "$module" = "pybind11" ]; then
BUILD_PYBIND11=OFF
fi
done
echo ""
fi
;;
*) echo "Option $1 not recognized"
shift 1
;;
esac
done
if [ $BUILD_USD = true ]; then
echo "Building USD..."
# Build USD
USD_BUILD_DIR=$BUILD_DIR/USD
USD_EXT_DIR=$EXT_DIR/USD
git submodule update --init $USD_EXT_DIR
if [ ! -d "$USD_BUILD_DIR" ]; then
# Create the folder if it doesn't exist
mkdir -p "$USD_BUILD_DIR"
echo "Folder created: $USD_BUILD_DIR"
else
echo "Folder already exists: $USD_BUILD_DIR"
fi
for virtualenvwrapper in $(which virtualenvwrapper.sh) /usr/share/virtualenvwrapper/virtualenvwrapper.sh /usr/local/bin/virtualenvwrapper.sh /home/$USER/.local/bin/virtualenvwrapper.sh; do
if [ -f $virtualenvwrapper ]; then
. $virtualenvwrapper
mkvirtualenv --system-site-packages multiverse
pip install pyside6 pyopengl
python3 $USD_EXT_DIR/build_scripts/build_usd.py $USD_BUILD_DIR
ln -sf $USD_BUILD_DIR/bin/usdview $BIN_DIR
ln -sf $USD_BUILD_DIR/bin/usdGenSchema $BIN_DIR
ln -sf $USD_BUILD_DIR/bin/usdcat $BIN_DIR
break
fi
done
if [ ! -f $virtualenvwrapper ]; then
echo "virtualenvwrapper.sh not found"
fi
fi
if [ $BUILD_BLENDER = true ]; then
echo "Building Blender..."
FROM_SRC=false
BLENDER_BUILD_DIR=$BUILD_DIR/blender
if [ ! -d "$BLENDER_BUILD_DIR" ]; then
# Create the folder if it doesn't exist
mkdir -p "$BLENDER_BUILD_DIR"
echo "Folder created: $BLENDER_BUILD_DIR"
else
echo "Folder already exists: $BLENDER_BUILD_DIR"
fi
if [ $FROM_SRC = true ]; then
# Build blender
BLENDER_EXT_DIR=$EXT_DIR/blender-git
git submodule update --init $BLENDER_EXT_DIR/blender
(cd $BLENDER_EXT_DIR/blender && make update && ./build_files/utils/make_update.py --use-linux-libraries)
(cd $BLENDER_BUILD_DIR && cmake -S ../../external/blender-git/blender -B . -Wno-deprecated -Wno-dev && make -j$(nproc) && make install)
else
# Download blender
BLENDER_TAR_FILE=blender-4.2.0-linux-x64.tar.xz
curl -o $EXT_DIR/$BLENDER_TAR_FILE https://download.blender.org/release/Blender4.2/$BLENDER_TAR_FILE
tar xf $EXT_DIR/$BLENDER_TAR_FILE -C $BLENDER_BUILD_DIR --strip-components=1
fi
(cd $BLENDER_BUILD_DIR/4.2/python/bin;
./python3.11 -m pip install --upgrade pip build --no-warn-script-location;
./python3.11 -m pip install bpy Pillow --no-warn-script-location) # For blender
ln -sf $BLENDER_BUILD_DIR/blender $BIN_DIR
ln -sf $BLENDER_BUILD_DIR/4.2/python/bin/python3.11 $BIN_DIR
fi
if [ $BUILD_MUJOCO = true ]; then
echo "Building MuJoCo..."
# Build MuJoCo
FROM_SRC=true
MUJOCO_BUILD_DIR=$BUILD_DIR/mujoco
MUJOCO_EXT_DIR=$EXT_DIR/mujoco
if [ ! -d "$MUJOCO_BUILD_DIR" ]; then
# Create the folder if it doesn't exist
mkdir -p "$MUJOCO_BUILD_DIR"
echo "Folder created: $MUJOCO_BUILD_DIR"
else
echo "Folder already exists: $MUJOCO_BUILD_DIR"
fi
if [ $FROM_SRC = true ]; then
# Build MuJoCo
# git submodule update --init $MUJOCO_EXT_DIR
MUJOCO_PLUGIN_DIR=$MUJOCO_BUILD_DIR/bin/mujoco_plugin
mkdir -p $MUJOCO_PLUGIN_DIR
(cd $MUJOCO_BUILD_DIR && cmake $MUJOCO_EXT_DIR -DCMAKE_INSTALL_PREFIX=$MUJOCO_BUILD_DIR -Wno-deprecated -Wno-dev && cmake --build . && cmake --install . && cp $MUJOCO_BUILD_DIR/lib/libmultiverse_connector.so $MUJOCO_PLUGIN_DIR)
else
# Download MuJoCo
MUJOCO_TAR_FILE=mujoco-3.2.5-linux-x86_64.tar.gz
curl -sL https://github.com/google-deepmind/mujoco/releases/download/3.2.5/$MUJOCO_TAR_FILE | tar zx -C $MUJOCO_BUILD_DIR --strip-components=1
fi
ln -sf $MUJOCO_BUILD_DIR/bin/simulate $BIN_DIR
fi
if [ $BUILD_PYBIND11 = true ]; then
echo "Building pybind11..."
# Build pybind11
PYBIND11_BUILD_DIR=$BUILD_DIR/pybind11
PYBIND11_EXT_DIR=$EXT_DIR/pybind11
git submodule update --init $PYBIND11_EXT_DIR
if [ ! -d "$PYBIND11_BUILD_DIR" ]; then
# Create the folder if it doesn't exist
mkdir -p "$PYBIND11_BUILD_DIR"
echo "Folder created: $PYBIND11_BUILD_DIR"
else
echo "Folder already exists: $PYBIND11_BUILD_DIR"
fi
(cd $PYBIND11_BUILD_DIR && cmake $PYBIND11_EXT_DIR -DCMAKE_INSTALL_PREFIX=$PYBIND11_BUILD_DIR -Wno-deprecated -Wno-dev && cmake --build . && sudo cmake --install .)
fi
RELOAD=false
if ! echo "$PATH" | grep -q "$BIN_DIR"; then
PATH_TO_ADD="export PATH=$PATH:$BIN_DIR"
echo "$PATH_TO_ADD" >> ~/.bashrc
echo "Add $PATH_TO_ADD to ~/.bashrc"
RELOAD=true
fi
if ! echo "$PYTHONPATH" | grep -q "$USD_BUILD_DIR/lib/python"; then
PYTHONPATH_TO_ADD="export PYTHONPATH=$PYTHONPATH:$USD_BUILD_DIR/lib/python"
echo "$PYTHONPATH_TO_ADD" >> ~/.bashrc
echo "Add $PYTHONPATH_TO_ADD to ~/.bashrc"
RELOAD=true
fi
cd $CURRENT_DIR
if [ "$RELOAD" = true ]; then
exec bash # Reload ~/.bashrc
rosdep update
fi