Skip to content

Commit

Permalink
Only generate DllName class where it's needed
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault committed Apr 27, 2021
1 parent 2f153e4 commit 4deb58c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 3 additions & 7 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import mill._, scalalib._
import scala.concurrent.duration._


object `windows-jni-utils` extends WindowsUtils with HasCSources with JniUtilsPublishModule {
object `windows-jni-utils` extends WindowsUtils with HasCSources with JniUtilsPublishModule with WithDllNameJava {
def linkingLibs = Seq("ole32")

def compile = T{
Expand Down Expand Up @@ -50,7 +50,7 @@ object `windows-jni-utils-tests` extends ScalaModule with JniUtilsPublishModule

// compile these projects to generate or update JNI header files
object headers extends Module {
object `windows-jni-utils` extends WindowsUtils with GenerateHeaders
object `windows-jni-utils` extends WindowsUtils with GenerateHeaders with WithDllNameJava
object `windows-jni-utils-bootstrap` extends WindowsUtils with GenerateHeaders {
def moduleDeps = Seq(`windows-jni-utils`)
def cDirectory = `windows-jni-utils`.cDirectory()
Expand All @@ -68,12 +68,8 @@ object headers extends Module {
define.BasePath(super.millModuleBasePath.value / os.up)
}

trait WindowsUtils extends MavenModule with JniUtilsPublishVersion with WithDllNameJava {
trait WindowsUtils extends MavenModule with JniUtilsPublishVersion {
def compileIvyDeps = Agg(Deps.svm)
def dllName = T{
val ver = publishVersion()
s"csjniutils-$ver"
}
}

def windowsJvmArchive = T.persistent {
Expand Down
7 changes: 6 additions & 1 deletion settings.sc
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ def publishSonatype(
}

trait WithDllNameJava extends JavaModule {
def dllName: T[String]
def generatedSources = T{
val f = T.ctx().dest / "coursier" / "jniutils" / "DllName.java"
val dllName0 = dllName()
Expand All @@ -296,4 +295,10 @@ trait WithDllNameJava extends JavaModule {
os.write(f, content, createFolders = true)
Seq(PathRef(f))
}

def publishVersion: T[String]
def dllName = T{
val ver = publishVersion()
s"csjniutils-$ver"
}
}

0 comments on commit 4deb58c

Please sign in to comment.