-
Notifications
You must be signed in to change notification settings - Fork 5
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
Organize projects #222
base: master
Are you sure you want to change the base?
Organize projects #222
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JniNative plugin invokes CMake to create native shared lib.
.settings( | ||
publishTo := None, | ||
publishLocal := Def.task(()), | ||
copyNative := { |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
examples
module andexamples-native
module.example-native
exists 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
bench
module(jmh benchmark module) andbench-native
module(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?