Update Rust build system: use rustup with musl target for static builds
This commit is contained in:
@@ -51,29 +51,21 @@ build_rust_component() {
|
||||
fi
|
||||
|
||||
# Build the project
|
||||
echo " Compiling with cargo..."
|
||||
if command -v cargo >/dev/null; then
|
||||
cargo build --release
|
||||
|
||||
# Install binary to Alpine root
|
||||
mkdir -p "$ALPINE_ROOT$install_path"
|
||||
cp "target/release/$binary_name" "$ALPINE_ROOT$install_path/"
|
||||
chmod +x "$ALPINE_ROOT$install_path/$binary_name"
|
||||
|
||||
echo " Success: $install_path/$binary_name installed to Alpine root"
|
||||
return 0
|
||||
else
|
||||
echo " Error: cargo not found - installing Rust..."
|
||||
apk add --no-cache rust cargo
|
||||
cargo build --release
|
||||
|
||||
mkdir -p "$ALPINE_ROOT$install_path"
|
||||
cp "target/release/$binary_name" "$ALPINE_ROOT$install_path/"
|
||||
chmod +x "$ALPINE_ROOT$install_path/$binary_name"
|
||||
|
||||
echo " Success: $install_path/$binary_name installed to Alpine root"
|
||||
return 0
|
||||
fi
|
||||
echo " Compiling with cargo for musl target..."
|
||||
|
||||
# Source cargo environment
|
||||
. ~/.cargo/env
|
||||
|
||||
# Build with musl target for static linking
|
||||
cargo build --release --target x86_64-unknown-linux-musl
|
||||
|
||||
# Install binary to Alpine root
|
||||
mkdir -p "$ALPINE_ROOT$install_path"
|
||||
cp "target/x86_64-unknown-linux-musl/release/$binary_name" "$ALPINE_ROOT$install_path/"
|
||||
chmod +x "$ALPINE_ROOT$install_path/$binary_name"
|
||||
|
||||
echo " Success: $install_path/$binary_name installed to Alpine root (musl static)"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Function to build Go project from submodule
|
||||
|
||||
Reference in New Issue
Block a user