Skip to content

Commit 1c43a1b

Browse files
committed
feat: use gobley fork as bindgen tool for android
1 parent da8b578 commit 1c43a1b

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

build_android.sh

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ set -e # Exit immediately if a command exits with a non-zero status.
3434

3535
echo "Starting Android build process..."
3636

37+
# Install gobley-uniffi-bindgen from fork with patched version
38+
echo "Installing gobley-uniffi-bindgen fork..."
39+
cargo install --git https://github.com/ovitrif/gobley.git --branch fix-v0.2.0 gobley-uniffi-bindgen --force
40+
3741
#TODO: Remove this section when example/main.rs builds successfully
3842
# Store example/main.rs content in memory and remove the file
3943
if [ -f "example/main.rs" ]; then
@@ -126,29 +130,30 @@ fi
126130
TMP_DIR=$(mktemp -d)
127131

128132
# Generate the bindings to temp directory first
129-
cargo run --bin uniffi-bindgen generate \
130-
--library "$LIBRARY_PATH" \
131-
--language kotlin \
132-
--config uniffi.toml \
133+
gobley-uniffi-bindgen --library "$LIBRARY_PATH" \
134+
--config uniffi-android.toml \
133135
--out-dir "$TMP_DIR"
134136

135-
# Move the Kotlin file from the nested directory to the final location
136-
echo "Moving Kotlin file to final location..."
137-
find "$TMP_DIR" -name "bitkitcore.kt" -exec mv {} "$BASE_DIR/" \;
137+
# Move the Kotlin files from the nested directory to the final location
138+
echo "Moving Kotlin files to final location..."
139+
mv "$TMP_DIR"/main/kotlin/com/synonym/bitkitcore/*.kt "$BASE_DIR/"
138140

139141
# Clean up temp directory and any remaining uniffi directories
140142
echo "Cleaning up temporary files..."
141143
rm -rf "$TMP_DIR"
142144
rm -rf "$ANDROID_LIB_DIR/uniffi"
143145

144-
# Verify the file was moved correctly
145-
if [ ! -f "$BASE_DIR/bitkitcore.kt" ]; then
146+
# Verify the files were moved correctly
147+
if [ ! -f "$BASE_DIR/bitkitcore.android.kt" ] || [ ! -f "$BASE_DIR/bitkitcore.common.kt" ]; then
146148
echo "Error: Kotlin bindings were not moved correctly"
147149
echo "Contents of $BASE_DIR:"
148150
ls -la "$BASE_DIR"
149151
exit 1
150152
fi
151153

154+
echo "Generated Kotlin bindings:"
155+
ls -la "$BASE_DIR"
156+
152157
# Sync version
153158
echo "Syncing version from Cargo.toml..."
154159
CARGO_VERSION=$(grep '^version = ' Cargo.toml | sed 's/version = "\(.*\)"/\1/' | head -1)
@@ -159,4 +164,4 @@ rm -f "$ANDROID_LIB_DIR/gradle.properties.bak"
159164
echo "Testing android library publish to Maven Local..."
160165
"$ANDROID_LIB_DIR"/gradlew --project-dir "$ANDROID_LIB_DIR" clean publishToMavenLocal
161166

162-
echo "Android build process completed successfully!"
167+
echo "Android build process completed successfully!"

0 commit comments

Comments
 (0)