File tree Expand file tree Collapse file tree 3 files changed +15
-23
lines changed
tests/src/test/scala/org/scalanative/bindgen
tools/src/main/scala/org/scalanative/bindgen Expand file tree Collapse file tree 3 files changed +15
-23
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ inThisBuild(
18
18
19
19
val tests = project
20
20
.in(file(" tests" ))
21
+ .dependsOn(tools)
21
22
.aggregate(samples)
22
23
.settings(
23
24
fork in Test := true ,
Original file line number Diff line number Diff line change 1
1
package org .scalanative .bindgen
2
2
3
- import java .io .{File , PrintWriter }
3
+ import java .io .{File }
4
4
import org .scalatest .FunSpec
5
5
import scala .io .Source
6
- import scala .sys .process ._
7
6
8
7
class BindgenSpec extends FunSpec {
9
8
describe(" Bindgen" ) {
@@ -19,24 +18,15 @@ class BindgenSpec extends FunSpec {
19
18
}
20
19
21
20
def bindgen (inputFile : File , name : String , outputFile : File ): Unit = {
22
- val cmd = Seq (
23
- bindgenPath,
24
- inputFile.getAbsolutePath,
25
- " --name" ,
26
- name,
27
- " --link" ,
28
- " bindgentests" ,
29
- " --package" ,
30
- " org.scalanative.bindgen.samples" ,
31
- " --exclude-prefix=__" ,
32
- " --"
33
- )
34
- val output = Process (cmd).lineStream.mkString(" \n " )
35
-
36
- new PrintWriter (outputFile) {
37
- write(output)
38
- close()
39
- }
21
+ Bindgen ()
22
+ .bindgenExecutable(new File (bindgenPath))
23
+ .header(inputFile)
24
+ .scalaObjectName(name)
25
+ .link(" bindgentests" )
26
+ .packageName(" org.scalanative.bindgen.samples" )
27
+ .excludePrefix(" __" )
28
+ .generate()
29
+ .writeToFile(outputFile)
40
30
}
41
31
42
32
def contentOf (file : File ) =
Original file line number Diff line number Diff line change @@ -148,12 +148,13 @@ object Bindgen {
148
148
}
149
149
150
150
if (excludePrefix != null ) {
151
- cmd :+= excludePrefix
151
+ cmd ++= Seq ( " --exclude-prefix " , excludePrefix)
152
152
}
153
153
154
- cmd :+= " --"
154
+ for (arg <- extraArg) cmd ++= Seq (" --extra-arg" , arg)
155
+ for (arg <- extraArgBefore) cmd ++= Seq (" --extra-arg-before" , arg)
155
156
156
- // TODO: extra args
157
+ cmd :+= " -- "
157
158
158
159
val output = Process (cmd).lineStream.mkString(" \n " )
159
160
You can’t perform that action at this time.
0 commit comments