Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nadavwr/scala-native-sbt-jni-example
an example of how to build C code as part of a Scala Native project using sbt-jni
https://github.com/nadavwr/scala-native-sbt-jni-example
cmake sbt-jni scala-native
Last synced: 25 days ago
JSON representation
an example of how to build C code as part of a Scala Native project using sbt-jni
- Host: GitHub
- URL: https://github.com/nadavwr/scala-native-sbt-jni-example
- Owner: nadavwr
- Created: 2017-05-19T15:07:40.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-05-19T15:29:50.000Z (over 7 years ago)
- Last Synced: 2024-04-22T13:32:39.728Z (8 months ago)
- Topics: cmake, sbt-jni, scala-native
- Language: CMake
- Size: 1.95 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-scala-native - Building C code using sbt-jni - Example for compiling C code in a Scala Native project using [sbt-jni](https://github.com/jodersky/sbt-jni). (Tutorials and Examples)
README
[sbt-jni](https://github.com/jodersky/sbt-jni)'s `nativeCompile` will compile and link a dynamic library used from Scala code. Scala Native's `nativeLink` and `run` will "just work" (with a tiny nudge so that the dynamic library is picked up).
Packaging is somewhat of an issue: `package` works just fine, and you'll see that the dynamic library is packaged as `native/${your_platform}/libprintln0.dylib`, but additional work will be needed to be able to use it as part of a dependency jar. Cross-compilation is also not addressed.
Given its stated purpose (JNI...), it is understandable that sbt-jni expects us to build a dynamic library. However, building and linking against a static library is perfectly possible (albeit alongside a dynamic library, so that sbt-jni doesn't complain). See comment at bottom of `CMakeLists.txt`. It doesn't handle packaging of static libraries out-of-the-box, but all that seems to be within easy reach.