-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile.sh
More file actions
executable file
·31 lines (22 loc) · 981 Bytes
/
compile.sh
File metadata and controls
executable file
·31 lines (22 loc) · 981 Bytes
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
#!/bin/bash
SRC_DIR="src/rust"
DEST_DIR="../../../lib"
# Install cross if not already installed
if ! command -v cross &> /dev/null; then
cargo install cross
fi
cd "$SRC_DIR" || exit
for dir in */; do
if [ -d "$dir" ]; then
cd "$dir" || exit
# Compile for Linux
cross build --release --target x86_64-unknown-linux-gnu
mv target/x86_64-unknown-linux-gnu/release/*.so "$DEST_DIR/$(ls target/x86_64-unknown-linux-gnu/release/*.so | head -n 1 | xargs basename | sed 's/lib//')"
# Compile for Windows
cross build --release --target x86_64-pc-windows-gnu
mv target/x86_64-pc-windows-gnu/release/*.dll "$DEST_DIR/$(ls target/x86_64-pc-windows-gnu/release/*.dll | head -n 1 | xargs basename | sed 's/lib//')"
# no compile for MacOS, as it is not supported by cross (or I couldn't find out how to do it lol)
cd ..
fi
done
echo "All projects compiled and .so, .dll files moved to $DEST_DIR"