Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Configure publishing of the sbt plugin and tools library #130

Merged
merged 8 commits into from
Jul 24, 2018

Conversation

jonas
Copy link
Member

@jonas jonas commented Jul 22, 2018

Refs #60

@jonas
Copy link
Member Author

jonas commented Jul 22, 2018

Still need to update the documentation for how to use the sbt plugin.

I'm also wondering if we should make the plugin to automatically fetch the scala-native-bindgen binary now in order to make it easier to use version 0.2. What do you think?

@kornilova203
Copy link
Member

I'll update documentation

Automatic download would be awesome, will it be difficult to do?

@jonas
Copy link
Member Author

jonas commented Jul 22, 2018

No, I have most of the code already from another project.

@jonas
Copy link
Member Author

jonas commented Jul 23, 2018

Here's the test I made locally:

tmp/scala-native-bindgen-sbt-test > tree .
.
├── build.sbt
├── project
│   ├── build.properties
│   └── plugins.sbt
└── src
    └── main
        └── resources
            └── header.h

4 directories, 4 files

/tmp/scala-native-bindgen-sbt-test > cat project/plugins.sbt
addSbtPlugin("org.scala-native.bindgen" % "sbt-scala-native-bindgen" % "0.2.0-RC1")
resolvers += Resolver.bintrayIvyRepo("scala-native-bindgen", "sbt-plugin")
resolvers += Resolver.bintrayRepo("scala-native-bindgen", "maven")

/tmp/scala-native-bindgen-sbt-test > cat build.sbt
name := "test"
organization := "org.scala-native.bindgen.sbt.test"
enablePlugins(ScalaNativeBindgenPlugin)
scalaVersion := "2.11.12"

inConfig(Compile)(
  Def.settings(
    nativeBindgenHeader := (resourceDirectory in Compile).value / "header.h",
    nativeBindgenPackage := Some("org.example.app"),
    nativeBindgenLink := Some("app"),
    nativeBindgenExclude := Some("__"),
    name in nativeBindgen := "AppAPI"
  ))

/tmp/scala-native-bindgen-sbt-test > sbt
[info] Loading settings from plugins.sbt ...
[info] Loading project definition from /private/tmp/scala-native-bindgen-sbt-test/project
[info] Updating ProjectRef(uri("file:/private/tmp/scala-native-bindgen-sbt-test/project/"), "scala-native-bindgen-sbt-test-build")...
[info] Done updating.
[info] Loading settings from build.sbt ...
[info] Set current project to test (in build file:/private/tmp/scala-native-bindgen-sbt-test/)
[info] sbt server started at local:///Users/fonseca/.sbt/1.0/server/28c562a21f402d453df4/sock
sbt:test> nativeBindgen
[info] Updating ...
[info] downloading https://github.com/jonas/scala-native-bindgen/releases/download/v0.2.0-RC1/scala-native-bindgen-darwin ...
[info] 	[SUCCESSFUL ] org.scala-native.bindgen#scala-native-bindgen-darwin;0.2.0-RC1!scala-native-bindgen-darwin.0-RC1/scala-native-bindgen-darwin (16323ms)
[info] Done updating.
[success] Total time: 18 s, completed 23-Jul-2018 1:01:55 AM
sbt:test> ^C

/tmp/scala-native-bindgen-sbt-test > cat target/scala-2.11/src_managed/main/sbt-scala-native-bindgen/ScalaNativeBindgen.scala
package org.example.app

import scala.scalanative._
import scala.scalanative.native._

@native.link("app")
@native.extern
object AppAPI {
  def access(path: native.CString, mode: native.CInt): native.CInt = native.extern
  def read(fildes: native.CInt, buf: native.Ptr[Byte], nbyte: native.CInt): native.CInt = native.extern
  def printf(format: native.CString, varArgs: native.CVararg*): native.CInt = native.extern
}

@jonas jonas merged commit 942598b into scala-native:master Jul 24, 2018
@jonas jonas deleted the release branch July 24, 2018 03:39
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants