mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2025-12-18 06:24:21 +01:00
Build SDK bindings for Flutter (#488)
* Add build SDK bindings scripts for flutter * Remove REMOVE_RECURSE to prevent bindings deletion * Address feedback
This commit is contained in:
2
.github/workflows/publish-flutter.yml
vendored
2
.github/workflows/publish-flutter.yml
vendored
@@ -60,7 +60,9 @@ jobs:
|
|||||||
rm -rf lib
|
rm -rf lib
|
||||||
cp -r ../build/packages/flutter/android .
|
cp -r ../build/packages/flutter/android .
|
||||||
cp -r ../build/packages/flutter/ios .
|
cp -r ../build/packages/flutter/ios .
|
||||||
|
mv android/build.gradle.production android/build.gradle
|
||||||
mv ios/flutter_breez_liquid.podspec.production ios/flutter_breez_liquid.podspec
|
mv ios/flutter_breez_liquid.podspec.production ios/flutter_breez_liquid.podspec
|
||||||
|
rm ios/breez_sdk_liquid.podspec
|
||||||
cp -r ../build/packages/flutter/lib .
|
cp -r ../build/packages/flutter/lib .
|
||||||
cp -r ../build/lib/bindings/langs/flutter/breez_sdk_liquid/include/breez_sdk_liquid.h ios/Classes
|
cp -r ../build/lib/bindings/langs/flutter/breez_sdk_liquid/include/breez_sdk_liquid.h ios/Classes
|
||||||
cp ../build/packages/flutter/analysis_options.yaml .
|
cp ../build/packages/flutter/analysis_options.yaml .
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ bootstrap frb='true' build='false':
|
|||||||
@if {{build}} == true; then just build; fi
|
@if {{build}} == true; then just build; fi
|
||||||
@if {{build}} == true; then melos build; fi
|
@if {{build}} == true; then melos build; fi
|
||||||
@if {{build}} == true; then just link; fi
|
@if {{build}} == true; then just link; fi
|
||||||
|
@if {{build}} == true; then just build-uniffi; fi
|
||||||
just check
|
just check
|
||||||
|
|
||||||
# Install flutter_rust_bridge_codegen dependencies
|
# Install flutter_rust_bridge_codegen dependencies
|
||||||
@@ -54,6 +55,16 @@ build-android profile='frb-min':
|
|||||||
build-other profile='frb-min':
|
build-other profile='frb-min':
|
||||||
dart scripts/build_other.dart --profile {{profile}}
|
dart scripts/build_other.dart --profile {{profile}}
|
||||||
|
|
||||||
|
build-uniffi:
|
||||||
|
just build-uniffi-android
|
||||||
|
just build-uniffi-swift
|
||||||
|
|
||||||
|
build-uniffi-android:
|
||||||
|
bash scripts/build_uniffi_android.sh
|
||||||
|
|
||||||
|
build-uniffi-swift:
|
||||||
|
bash scripts/build_uniffi_swift.sh
|
||||||
|
|
||||||
# (melos) Run tests on packages in workspace
|
# (melos) Run tests on packages in workspace
|
||||||
test build='false':
|
test build='false':
|
||||||
just test-dart {{build}}
|
just test-dart {{build}}
|
||||||
|
|||||||
14
lib/bindings/langs/flutter/scripts/build_uniffi_android.sh
Normal file
14
lib/bindings/langs/flutter/scripts/build_uniffi_android.sh
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
cd ../..
|
||||||
|
make android
|
||||||
|
rm -r ../../packages/flutter/android/src/main/kotlin
|
||||||
|
mkdir -p ../../packages/flutter/android/src/main/jniLibs/arm64-v8a
|
||||||
|
mkdir -p ../../packages/flutter/android/src/main/jniLibs/armeabi-v7a
|
||||||
|
mkdir -p ../../packages/flutter/android/src/main/jniLibs/x86
|
||||||
|
mkdir -p ../../packages/flutter/android/src/main/jniLibs/x86_64
|
||||||
|
cp ffi/kotlin/jniLibs/arm64-v8a/*.so ../../packages/flutter/android/src/main/jniLibs/arm64-v8a/
|
||||||
|
cp ffi/kotlin/jniLibs/armeabi-v7a/*.so ../../packages/flutter/android/src/main/jniLibs/armeabi-v7a/
|
||||||
|
cp ffi/kotlin/jniLibs/x86/*.so ../../packages/flutter/android/src/main/jniLibs/x86/
|
||||||
|
cp ffi/kotlin/jniLibs/x86_64/*.so ../../packages/flutter/android/src/main/jniLibs/x86_64/
|
||||||
|
cp -r langs/android/lib/src/main/kotlin ../../packages/flutter/android/src/main/
|
||||||
|
cp -r ffi/kotlin/breez_sdk_liquid ../../packages/flutter/android/src/main/kotlin
|
||||||
6
lib/bindings/langs/flutter/scripts/build_uniffi_swift.sh
Normal file
6
lib/bindings/langs/flutter/scripts/build_uniffi_swift.sh
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
cd ../..
|
||||||
|
make bindings-swift
|
||||||
|
rm -rf ../../packages/flutter/ios/bindings-swift
|
||||||
|
cp -r langs/swift ../../packages/flutter/ios/bindings-swift
|
||||||
|
rm -f ../../packages/flutter/ios/bindings-swift/Package.swift
|
||||||
@@ -5,6 +5,7 @@ TAG_NAME=`awk '/^version: /{print $2}' $ROOT/packages/flutter/pubspec.yaml`
|
|||||||
|
|
||||||
# iOS & macOS
|
# iOS & macOS
|
||||||
APPLE_HEADER="version = '$TAG_NAME' # generated; do not edit"
|
APPLE_HEADER="version = '$TAG_NAME' # generated; do not edit"
|
||||||
|
sed -i.bak "1 s/.*/$APPLE_HEADER/" $ROOT/packages/flutter/ios/breez_sdk_liquid.podspec
|
||||||
sed -i.bak "1 s/.*/$APPLE_HEADER/" $ROOT/packages/flutter/ios/flutter_breez_liquid.podspec
|
sed -i.bak "1 s/.*/$APPLE_HEADER/" $ROOT/packages/flutter/ios/flutter_breez_liquid.podspec
|
||||||
sed -i.bak "1 s/.*/$APPLE_HEADER/" $ROOT/packages/flutter/ios/flutter_breez_liquid.podspec.production
|
sed -i.bak "1 s/.*/$APPLE_HEADER/" $ROOT/packages/flutter/ios/flutter_breez_liquid.podspec.production
|
||||||
sed -i.bak "1 s/.*/$APPLE_HEADER/" $ROOT/packages/flutter/macos/flutter_breez_liquid.podspec
|
sed -i.bak "1 s/.*/$APPLE_HEADER/" $ROOT/packages/flutter/macos/flutter_breez_liquid.podspec
|
||||||
@@ -18,4 +19,9 @@ do
|
|||||||
rm $ROOT/packages/flutter/$CMAKE_PLATFORM/*.bak
|
rm $ROOT/packages/flutter/$CMAKE_PLATFORM/*.bak
|
||||||
done
|
done
|
||||||
|
|
||||||
|
GRADLE_HEADER="version '$TAG_NAME' \/\/ generated; do not edit"
|
||||||
|
sed -i.bak "1 s/.*/$GRADLE_HEADER/" $ROOT/packages/flutter/android/build.gradle
|
||||||
|
sed -i.bak "1 s/.*/$GRADLE_HEADER/" $ROOT/packages/flutter/android/build.gradle.production
|
||||||
|
rm $ROOT/packages/flutter/android/*.bak
|
||||||
|
|
||||||
git add $ROOT/packages/flutter/
|
git add $ROOT/packages/flutter/
|
||||||
2
packages/flutter/.gitignore
vendored
2
packages/flutter/.gitignore
vendored
@@ -27,4 +27,4 @@ migrate_working_dir/
|
|||||||
**/doc/api/
|
**/doc/api/
|
||||||
.dart_tool/
|
.dart_tool/
|
||||||
.packages
|
.packages
|
||||||
build/
|
build/
|
||||||
|
|||||||
1
packages/flutter/android/.gitignore
vendored
1
packages/flutter/android/.gitignore
vendored
@@ -10,5 +10,6 @@
|
|||||||
|
|
||||||
# Ignore Rust binaries
|
# Ignore Rust binaries
|
||||||
src/main/jniLibs/
|
src/main/jniLibs/
|
||||||
|
src/main/kotlin/
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ if(NOT EXISTS ${ArchivePath})
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Extract the binaries, overriding any already present.
|
# Extract the binaries, overriding any already present.
|
||||||
file(REMOVE_RECURSE ${LibRoot})
|
|
||||||
file(MAKE_DIRECTORY ${LibRoot})
|
file(MAKE_DIRECTORY ${LibRoot})
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${CMAKE_COMMAND} -E tar xzf ${ArchivePath}
|
COMMAND ${CMAKE_COMMAND} -E tar xzf ${ArchivePath}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
// The Android Gradle Plugin builds the native code with the Android NDK.
|
version '0.2.1' // generated; do not edit
|
||||||
|
|
||||||
group 'com.example.flutter_breez_liquid'
|
group 'com.example.flutter_breez_liquid'
|
||||||
version '0.2.1'
|
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
|
ext.kotlin_version = '1.8.20'
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@@ -12,6 +11,7 @@ buildscript {
|
|||||||
dependencies {
|
dependencies {
|
||||||
// The Android Gradle Plugin knows how to build native code with the NDK.
|
// The Android Gradle Plugin knows how to build native code with the NDK.
|
||||||
classpath 'com.android.tools.build:gradle:7.1.2'
|
classpath 'com.android.tools.build:gradle:7.1.2'
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,11 +23,13 @@ rootProject.allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
apply plugin: 'kotlinx-serialization'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
// Bumping the plugin compileSdkVersion requires all clients of this plugin
|
// Bumping the plugin compileSdkVersion requires all clients of this plugin
|
||||||
// to bump the version in their app.
|
// to bump the version in their app.
|
||||||
compileSdkVersion 31
|
compileSdkVersion 34
|
||||||
|
|
||||||
// Bumping the plugin ndkVersion requires all clients of this plugin to bump
|
// Bumping the plugin ndkVersion requires all clients of this plugin to bump
|
||||||
// the version in their app and to download a newer version of the NDK.
|
// the version in their app and to download a newer version of the NDK.
|
||||||
@@ -52,8 +54,22 @@ android {
|
|||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = '1.8'
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main.java.srcDirs += 'src/main/kotlin'
|
||||||
|
}
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 16
|
minSdkVersion 24
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation "net.java.dev.jna:jna:5.14.0@aar"
|
||||||
|
/* JSON serialization */
|
||||||
|
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3'
|
||||||
|
}
|
||||||
|
|||||||
57
packages/flutter/android/build.gradle.production
Normal file
57
packages/flutter/android/build.gradle.production
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
version '0.2.1' // generated; do not edit
|
||||||
|
group 'com.example.flutter_breez_liquid'
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// The Android Gradle Plugin knows how to build native code with the NDK.
|
||||||
|
classpath 'com.android.tools.build:gradle:7.1.2'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.allprojects {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
|
android {
|
||||||
|
// Bumping the plugin compileSdkVersion requires all clients of this plugin
|
||||||
|
// to bump the version in their app.
|
||||||
|
compileSdkVersion 34
|
||||||
|
|
||||||
|
// Bumping the plugin ndkVersion requires all clients of this plugin to bump
|
||||||
|
// the version in their app and to download a newer version of the NDK.
|
||||||
|
ndkVersion "21.1.6352462"
|
||||||
|
|
||||||
|
// Invoke the shared CMake build with the Android Gradle Plugin.
|
||||||
|
externalNativeBuild {
|
||||||
|
cmake {
|
||||||
|
path "CMakeLists.txt"
|
||||||
|
|
||||||
|
// The default CMake version for the Android Gradle Plugin is 3.10.2.
|
||||||
|
// https://developer.android.com/studio/projects/install-ndk#vanilla_cmake
|
||||||
|
//
|
||||||
|
// The Flutter tooling requires that developers have CMake 3.10 or later
|
||||||
|
// installed. You should not increase this version, as doing so will cause
|
||||||
|
// the plugin to fail to compile for some customers of the plugin.
|
||||||
|
// version "3.10.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
minSdkVersion 24
|
||||||
|
}
|
||||||
|
}
|
||||||
3
packages/flutter/ios/.gitignore
vendored
3
packages/flutter/ios/.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
Flutter/
|
Flutter/
|
||||||
Runner/
|
Runner/
|
||||||
Frameworks/*
|
Frameworks/*
|
||||||
!Frameworks/.gitkeep
|
!Frameworks/.gitkeep
|
||||||
|
bindings-swift
|
||||||
|
|||||||
25
packages/flutter/ios/breez_sdk_liquid.podspec
Normal file
25
packages/flutter/ios/breez_sdk_liquid.podspec
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
version = '0.2.1' # generated; do not edit
|
||||||
|
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
|
||||||
|
# Run `pod lib lint breez_sdk.podspec` to validate before publishing.
|
||||||
|
Pod::Spec.new do |s|
|
||||||
|
s.name = 'BreezSDKLiquid'
|
||||||
|
s.version = "#{version}"
|
||||||
|
s.license = { :type => "MIT" }
|
||||||
|
s.summary = "Swift bindings to the Breez Liquid SDK"
|
||||||
|
s.homepage = "https://breez.technology"
|
||||||
|
s.authors = { "Breez" => "contact@breez.technology" }
|
||||||
|
s.documentation_url = "https://sdk-doc.breez.technology"
|
||||||
|
s.ios.deployment_target = "13.0"
|
||||||
|
s.source = { :path => '.' }
|
||||||
|
s.source_files = [
|
||||||
|
'bindings-swift/Sources/BreezSDKLiquid/*.swift',
|
||||||
|
'bindings-swift/Sources/BreezSDKLiquid/**/*.swift'
|
||||||
|
]
|
||||||
|
s.platform = :ios, '13.0'
|
||||||
|
s.static_framework = true
|
||||||
|
s.vendored_frameworks = "bindings-swift/breez_sdk_liquidFFI.xcframework"
|
||||||
|
|
||||||
|
# Flutter.framework does not contain a i386 slice.
|
||||||
|
s.pod_target_xcconfig = {'STRIP_STYLE' => 'non-global', 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
|
||||||
|
s.swift_version = '5.0'
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user