Skip to content

Commit

Permalink
feat(android): setup uniffi infra
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Nov 19, 2024
1 parent 4011062 commit b96bf72
Show file tree
Hide file tree
Showing 20 changed files with 3,633 additions and 25 deletions.
549 changes: 549 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ members = [
"./packages/backend/native",
"./packages/common/native",
"./packages/frontend/native",
"./packages/frontend/native/schema"
"./packages/frontend/native/schema",
"./packages/frontend/mobile-native",
]
resolver = "2"

[workspace.dependencies]
affine_common = { path = "./packages/common/native" }
criterion2 = { version = "2", default-features = false }
anyhow = "1"
chrono = "0.4"
dotenv = "0.15"
Expand Down
29 changes: 28 additions & 1 deletion packages/frontend/apps/android/App/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.application'

android {
namespace "app.affine.pro"
namespace "app.affine.pro"
compileSdk rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "app.affine.pro"
Expand All @@ -22,6 +22,8 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

ndkVersion "28.0.12433566"
}

repositories {
Expand All @@ -40,8 +42,10 @@ dependencies {
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation project(':capacitor-cordova-android-plugins')
implementation 'net.java.dev.jna:jna:5.6.0'
}

apply plugin: 'kotlin-android'
apply from: 'capacitor.build.gradle'

try {
Expand All @@ -52,3 +56,26 @@ try {
} catch(Exception e) {
logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
}

apply plugin: 'org.mozilla.rust-android-gradle.rust-android'

cargo {
module = "../../../../mobile-native" // Or whatever directory contains your Cargo.toml
libname = "affine_mobile_native" // Or whatever matches Cargo.toml's [package] name.
targets = ["arm64", "darwin-aarch64", "darwin-x86-64"]
pythonCommand = "python3.12"
targetDirectory = "../../../../../../target"
}

kotlin {
compilerOptions {
apiVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
}
}

tasks.whenTaskAdded { task ->
if ((task.name == 'javaPreCompileDebug' || task.name == 'javaPreCompileRelease')) {
task.dependsOn 'cargoBuild'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
dependencies {


implementation 'androidx.core:core-ktx:1.15.0'
}


Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package app.affine.pro

import android.os.Bundle
import android.util.Log
import com.getcapacitor.BridgeActivity
import uniffi.ffi.hashcashMint;

class MainActivity : BridgeActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
val hashed = hashcashMint("hello")
Log.d("MainActivity", "onCreate: $hashed")
super.onCreate(savedInstanceState)
}
}
Loading

0 comments on commit b96bf72

Please sign in to comment.