Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

i10416
Copy link
Contributor

@i10416 i10416 commented Feb 29, 2024

This PR adds the following changes.

  • 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 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) and bench-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?

- 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.
Comment on lines +99 to +106
lazy val `examples-native` = project
.in(file("slinc-examples-native"))
.enablePlugins(JniNative)
.settings(
publishTo := None,
publishLocal := Def.task(()),
nativeCompile / sourceDirectory := sourceDirectory.value
)
Copy link
Contributor Author

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 := {
Copy link
Contributor Author

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(_ != '-')
Copy link
Contributor Author

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.

@i10416 i10416 changed the title draft: organize projects Organize projects Mar 2, 2024
*/
lazy val `examples-native` = project
.in(file("slinc-examples-native"))
.enablePlugins(JniNative)
Copy link
Contributor Author

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.

@i10416
Copy link
Contributor Author

i10416 commented Mar 2, 2024

@markehammons

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?

@markehammons
Copy link
Collaborator

@markehammons

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants