Conversation
- Move core module under slinc directory. - Add `examples` module and `examples-native` module. `example-native` exists for the purpose of building native lib as a sbt project. The example demonstrates basic downcall, upcall and pointer handling.
| lazy val `examples-native` = project | ||
| .in(file("slinc-examples-native")) | ||
| .enablePlugins(JniNative) | ||
| .settings( | ||
| publishTo := None, | ||
| publishLocal := Def.task(()), | ||
| nativeCompile / sourceDirectory := sourceDirectory.value | ||
| ) |
There was a problem hiding this comment.
JniNative plugin invokes CMake to create native shared lib.
| .settings( | ||
| publishTo := None, | ||
| publishLocal := Def.task(()), | ||
| copyNative := { |
There was a problem hiding this comment.
This copies a shared lib from examples-native project to load it from resource.
https://github.com/scala-interop/slinc/pull/222/files#diff-d7b7c9d5ea6a2ac0cbbd2da77262f2b3074469d52c44ad9dd3a3dd2b16f00ebbR7
Compile / resourceGenerators is invoked at run and package.
Executing run (or package, not compile) will add a file demo to resourceManaged, which is target/scala-*/resource_managed". By default, generated resources are not included in the packaged source artifact. To do so, add them as you would other mappings. See Adding files to a package.
https://www.scala-sbt.org/1.x/docs/Howto-Generating-Files.html
| // rename shared lib name so that it complies with SlinC convention(`{lib name}_{arch}.{ext}`). | ||
| val destName = { | ||
| val arch = | ||
| (`examples-native` / nativePlatform).value.takeWhile(_ != '-') |
There was a problem hiding this comment.
nativePlatform returns string in format {arch}-{kernel} such as arm64-darwin.
| */ | ||
| lazy val `examples-native` = project | ||
| .in(file("slinc-examples-native")) | ||
| .enablePlugins(JniNative) |
There was a problem hiding this comment.
JniNative is not necessary, but I think it will reduce LoC.
|
Ah, I found https://github.com/scala-interop/slinc/tree/feat/new-core-model branch. Would you mind if I port some benchmark related code from https://github.com/i10416/bench to the branch? Or is it better to wait for the branch is merged into main? |
It's nowhere near complete, so just deal with main first. |
This PR adds the following changes.
examplesmodule andexamples-nativemodule.example-nativeexists for the purpose of building native lib as a sbt sub-project. The example demonstrates basic downcall, upcall and pointer handling as well as loading library from resource.I'm planning to port benchmark from https://github.com/i10416/bench to
benchmodule(jmh benchmark module) andbench-nativemodule(auxiliary module to build native shared lib for jni) if you're happy with it.I'd like to hear your thought before making a progress.
By the way, CI is failing and a part of ci file is commented-out. Is this still under migration from mill to sbt?