chore: Change package name and upload build_all.sh
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,9 +1,7 @@
|
||||
# Rust
|
||||
/target/
|
||||
|
||||
/build_all.sh
|
||||
|
||||
/bindings/kotlin/src/main/kotlin/uniffi/
|
||||
/bindings/kotlin/src/main/kotlin/cz/jzitnik
|
||||
/bindings/kotlin/src/main/resources/lib/
|
||||
/bindings/kotlin/src/main/resources/linux-x86-64/
|
||||
/bindings/kotlin/src/main/resources/win32-x86-64/
|
||||
|
||||
76
build_all.sh
Executable file
76
build_all.sh
Executable file
@@ -0,0 +1,76 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
export ANDROID_NDK_HOME=/home/kuba/.Android/Sdk/ndk/27.0.12077973/
|
||||
|
||||
# Configuration
|
||||
PROJECT_NAME="jecna_supl_client"
|
||||
LIB_NAME="lib${PROJECT_NAME}"
|
||||
KOTLIN_RES_DIR="bindings/kotlin/src/main/resources"
|
||||
KOTLIN_SRC_DIR="bindings/kotlin/src/main/kotlin"
|
||||
|
||||
# Targets
|
||||
LINUX_TARGET="x86_64-unknown-linux-gnu"
|
||||
ANDROID_TARGETS=("aarch64-linux-android" "armv7-linux-androideabi" "x86_64-linux-android")
|
||||
WINDOWS_TARGET="x86_64-pc-windows-gnu"
|
||||
|
||||
echo "=== Building for Linux ($LINUX_TARGET) ==="
|
||||
cargo build --release --target $LINUX_TARGET
|
||||
|
||||
echo "=== Building for Android ==="
|
||||
for target in "${ANDROID_TARGETS[@]}"; do
|
||||
echo "--- Building $target ---"
|
||||
cargo ndk -t $target build --release
|
||||
done
|
||||
|
||||
echo "=== Building for Windows ($WINDOWS_TARGET) ==="
|
||||
if rustup target list --installed | grep -q "$WINDOWS_TARGET" && command -v x86_64-w64-mingw32-gcc >/dev/null; then
|
||||
cargo build --release --target $WINDOWS_TARGET
|
||||
else
|
||||
echo "Warning: Windows target or x86_64-w64-mingw32-gcc not found. Skipping Windows build."
|
||||
fi
|
||||
|
||||
echo "=== Generating Kotlin Bindings ==="
|
||||
# Use the Linux library for metadata extraction
|
||||
GEN_LIB_PATH="target/$LINUX_TARGET/release/${LIB_NAME}.so"
|
||||
if [ ! -f "$GEN_LIB_PATH" ]; then
|
||||
# Fallback to host build if linux target failed/was different
|
||||
GEN_LIB_PATH="target/release/${LIB_NAME}.so"
|
||||
fi
|
||||
|
||||
cargo run --features uniffi-cli --bin uniffi-bindgen generate \
|
||||
--library "$GEN_LIB_PATH" \
|
||||
--language kotlin \
|
||||
--out-dir "$KOTLIN_SRC_DIR" \
|
||||
--no-format
|
||||
|
||||
echo "=== Organizing Native Libraries ==="
|
||||
|
||||
# Linux x86_64
|
||||
mkdir -p "$KOTLIN_RES_DIR/linux-x86-64"
|
||||
cp "target/$LINUX_TARGET/release/${LIB_NAME}.so" "$KOTLIN_RES_DIR/linux-x86-64/${LIB_NAME}.so"
|
||||
|
||||
# Android
|
||||
mkdir -p "$KOTLIN_RES_DIR/lib/arm64-v8a"
|
||||
cp "target/aarch64-linux-android/release/${LIB_NAME}.so" "$KOTLIN_RES_DIR/lib/arm64-v8a/${LIB_NAME}.so"
|
||||
|
||||
mkdir -p "$KOTLIN_RES_DIR/lib/armeabi-v7a"
|
||||
cp "target/armv7-linux-androideabi/release/${LIB_NAME}.so" "$KOTLIN_RES_DIR/lib/armeabi-v7a/${LIB_NAME}.so"
|
||||
|
||||
mkdir -p "$KOTLIN_RES_DIR/lib/x86_64"
|
||||
cp "target/x86_64-linux-android/release/${LIB_NAME}.so" "$KOTLIN_RES_DIR/lib/x86_64/${LIB_NAME}.so"
|
||||
|
||||
# Windows
|
||||
WIN_DLL="target/$WINDOWS_TARGET/release/${PROJECT_NAME}.dll"
|
||||
if [ -f "$WIN_DLL" ]; then
|
||||
mkdir -p "$KOTLIN_RES_DIR/win32-x86-64"
|
||||
cp "$WIN_DLL" "$KOTLIN_RES_DIR/win32-x86-64/${PROJECT_NAME}.dll"
|
||||
fi
|
||||
|
||||
# This is just for me cuz I have memory like a goldfish and I will forget how to upload it to central... Leave me alone
|
||||
echo "=== Build Complete ==="
|
||||
echo "To upload to Sonatype Central:"
|
||||
echo "1. cd bindings/kotlin"
|
||||
echo "2. JAVA_HOME=/usr/lib/jvm/java-17-openjdk ./gradlew clean zipBundle"
|
||||
echo "3. Upload the file 'bindings/kotlin/build/distributions/sonatype-bundle.zip'"
|
||||
echo " at https://central.sonatype.com/publishing/deployments"
|
||||
2
uniffi.toml
Normal file
2
uniffi.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
[bindings.kotlin]
|
||||
package_name = "cz.jzitnik.jecna_supl_client"
|
||||
Reference in New Issue
Block a user