-
Notifications
You must be signed in to change notification settings - Fork 19
WIP: JVM support #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: JVM support #38
Conversation
| outputs.files(defFile) | ||
| } | ||
|
|
||
| tasks.create<Exec>("buildNative") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run build.sh to build the binary and save it to build/native/powersync-sqlite/${OS}/output
| iosArm64() | ||
| iosSimulatorArm64() | ||
| jvm { | ||
| val processResources = compilations["main"].processResourcesTaskName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bundle the binary into the jar
| @@ -0,0 +1,12 @@ | |||
| #!/bin/bash | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure whats the convention for the location of build files 🤔
| @@ -0,0 +1,91 @@ | |||
| #include <jni.h> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mentioned in the PR note, this is copied from androidMain, would be good to share the file
| public actual val isDebug: Boolean | ||
| // TODO: need to determine a good way to set this on JVM presuming we don't want to bundle BuildKonfig in the | ||
| // library. | ||
| get() = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't want to add the dependency on BuildKonfig to the library, will explore if there is an alternative.
| val schema = InternalSchema.synchronous() | ||
| this.driver = PsSqlDriver( | ||
| scope = scope, | ||
| driver = JdbcSqliteDriver("jdbc:sqlite:$dbFilename", Properties(), schema) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the cause of the crash, not loading sqlite driver with extension support so the powersync_rs_version isn't available
| import java.io.File | ||
| import java.io.InputStream | ||
|
|
||
| private interface LibraryLoader { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI recommended this approach so I'm sure there is a better way 😂
|
Thanks @henwoods for getting this going, I have gone through the PR and run into the same issue as you've pointed out. I think what might help is that we already release powersync-sqlite-core https://github.com/powersync-ja/powersync-sqlite-core/releases for different targets i.e. linux, windows etc which will be useful for here. Here's an example of how it has been implemented in Flutter
I will have more time to look at this again next week. |
|
is this currently being worked on ? |
|
@Shabinder we have noted your interest but we are not currently looking at this. We are open to anyone in the community continuing with the PR to get it complete. |
|
Closing this as it has been superseded by #88 |
Currently non-functional and only tested on OSX. I've not much experience bundling native libs so probably there is convention errors and hackiness that needs to be cleaned up with the build/make/gradle configs and the library loader.
Notes:
[SQLITE_ERROR] SQL error or missing database (no such function: powersync_rs_version), guessing this is because we need a way to support extensions for the JVM driver. Is this handled by requery on Android?TODOs:
sqlight_bindings.cppis copy/pasta from Android, would be good to pull it up so it can be sharedUsage:
RELEASE_SIGNING_ENABLED=false)publishToMavenLocaltaskpowersync-helloand create a Gradle run configurationhello-powersync:desktopmodulerun -DmainClass=com.powersync.demo.MainKtExpect the app to crash with the missing
powersync_rs_versionfunction error