-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·66 lines (56 loc) · 1.72 KB
/
build.sh
File metadata and controls
executable file
·66 lines (56 loc) · 1.72 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
#!/usr/bin/env bash
set -e
set -x # показывать команды
# --- Проверка Rust ---
if ! command -v cargo &>/dev/null; then
echo "Rust не найден. Автоустановка..."
curl https://sh.rustup.rs -sSf | sh -s -- -y
export PATH="$HOME/.cargo/bin:$PATH"
fi
# --- Определяем OS и ARCH ---
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"
TARGET=""
EXT=""
case "$OS" in
darwin)
if [ "$ARCH" = "arm64" ]; then
TARGET="aarch64-apple-darwin"
else
TARGET="x86_64-apple-darwin"
fi
EXT="dylib"
;;
linux)
if [ "$ARCH" = "aarch64" ]; then
TARGET="aarch64-unknown-linux-gnu"
else
TARGET="x86_64-unknown-linux-gnu"
fi
EXT="so"
;;
mingw*|msys*|cygwin*)
if [ "$ARCH" = "aarch64" ]; then
TARGET="aarch64-pc-windows-gnu"
else
TARGET="x86_64-pc-windows-gnu"
fi
EXT="dll"
;;
*)
echo "Unsupported OS/ARCH: $OS/$ARCH"
exit 1
;;
esac
echo "Building for target: $TARGET"
# --- Проверка и установка target Rust ---
if ! rustup target list | grep -q "${TARGET} (installed)"; then
rustup target add $TARGET
fi
# --- Сборка Rust динамической библиотеки ---
cargo build --release --target $TARGET --manifest-path ./Cargo.toml
# --- Копируем библиотеку в каталог с Go пакетом ---
LIB_NAME="libalchemist_c"
BUILD_DIR="target/$TARGET/release"
cp "$BUILD_DIR/$LIB_NAME.$EXT" "$LIB_NAME.$EXT"
echo "Библиотека $LIB_NAME.$EXT готова и лежит в корне проекта"