Move platform libs to dist/klib/$target (#926)
This commit is contained in:
committed by
Nikolay Igotti
parent
7b4b857e2b
commit
faa5ba0e7c
+18
-5
@@ -34,7 +34,12 @@ fun defaultResolver(repositories: List<String>, targetManager: TargetManager): S
|
||||
defaultResolver(repositories, Distribution(targetManager))
|
||||
|
||||
fun defaultResolver(repositories: List<String>, distribution: Distribution): SearchPathResolver =
|
||||
KonanLibrarySearchPathResolver(repositories, distribution.klib, distribution.localKonanDir)
|
||||
KonanLibrarySearchPathResolver(
|
||||
repositories,
|
||||
distribution.targetManager,
|
||||
distribution.klib,
|
||||
distribution.localKonanDir
|
||||
)
|
||||
|
||||
fun SearchPathResolver.resolveImmediateLibraries(libraryNames: List<String>,
|
||||
target: KonanTarget,
|
||||
@@ -94,8 +99,13 @@ fun SearchPathResolver.resolveLibrariesRecursive(libraryNames: List<String>,
|
||||
)
|
||||
}
|
||||
|
||||
class KonanLibrarySearchPathResolver(repositories: List<String>,
|
||||
val distributionKlib: String?, val localKonanDir: String?, val skipCurrentDir: Boolean = false): SearchPathResolver {
|
||||
class KonanLibrarySearchPathResolver(
|
||||
repositories: List<String>,
|
||||
val targetManager: TargetManager?,
|
||||
val distributionKlib: String?,
|
||||
val localKonanDir: String?,
|
||||
val skipCurrentDir: Boolean = false
|
||||
): SearchPathResolver {
|
||||
|
||||
val localHead: File?
|
||||
get() = localKonanDir?.File()?.klib
|
||||
@@ -103,6 +113,9 @@ class KonanLibrarySearchPathResolver(repositories: List<String>,
|
||||
val distHead: File?
|
||||
get() = distributionKlib?.File()
|
||||
|
||||
val distPlatformHead: File?
|
||||
get() = targetManager?.let { distHead?.child(targetManager.targetName) }
|
||||
|
||||
val currentDirHead: File?
|
||||
get() = if (!skipCurrentDir) File.userDir else null
|
||||
|
||||
@@ -112,7 +125,7 @@ class KonanLibrarySearchPathResolver(repositories: List<String>,
|
||||
|
||||
// This is the place where we specify the order of library search.
|
||||
override val searchRoots: List<File> by lazy {
|
||||
(listOf(currentDirHead) + repoRoots + listOf(localHead, distHead)).filterNotNull()
|
||||
(listOf(currentDirHead) + repoRoots + listOf(localHead, distHead, distPlatformHead)).filterNotNull()
|
||||
}
|
||||
|
||||
private fun found(candidate: File): File? {
|
||||
@@ -145,7 +158,7 @@ class KonanLibrarySearchPathResolver(repositories: List<String>,
|
||||
|
||||
// The libraries from the default root are linked automatically.
|
||||
val defaultRoot: File?
|
||||
get() = if (distHead?.exists ?: false) distHead else null
|
||||
get() = if (distPlatformHead?.exists ?: false) distPlatformHead else null
|
||||
|
||||
override fun defaultLinks(nostdlib: Boolean, noDefaultLibs: Boolean): List<File> {
|
||||
val defaultLibs = defaultRoot?.listFiles.orEmpty()
|
||||
|
||||
@@ -11,13 +11,14 @@ buildscript {
|
||||
def taskName = "${gradle.startParameter.projectProperties['name']}"
|
||||
String konanHome = gradle.startParameter.projectProperties['konan.home']
|
||||
List<String> libraries = gradle.startParameter.projectProperties.libraries.split(" ").findAll { !it.isEmpty() }
|
||||
String targetName = gradle.startParameter.projectProperties.target
|
||||
|
||||
konanInterop {
|
||||
"$taskName" {
|
||||
defFile gradle.startParameter.projectProperties.defFile
|
||||
target gradle.startParameter.projectProperties.target
|
||||
target targetName
|
||||
noDefaultLibs true
|
||||
extraOpts libraries.collectMany { ["-library", "$konanHome/klib/$it"] }
|
||||
extraOpts libraries.collectMany { ["-library", "$konanHome/klib/$targetName/$it"] }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +26,15 @@ def suffix = gradle.startParameter.projectProperties['suffix']
|
||||
def klibProgram = suffix?"$konanHome/bin/klib.$suffix" : "$konanHome/bin/klib"
|
||||
|
||||
task klibInstall(type:Exec) {
|
||||
String repo = "$konanHome/klib/$targetName"
|
||||
doFirst {
|
||||
new File(repo).mkdirs()
|
||||
}
|
||||
|
||||
dependsOn konanInterop["$taskName"].interopProcessingTask
|
||||
commandLine klibProgram,
|
||||
'install',
|
||||
konanInterop["$taskName"].interopProcessingTask.klib,
|
||||
'-repository',
|
||||
"$konanHome/klib"
|
||||
repo
|
||||
}
|
||||
|
||||
@@ -133,17 +133,33 @@ class Library(val name: String, val requestedRepository: String?, val target: St
|
||||
val currentAbiVersion = 1
|
||||
|
||||
fun libraryInRepo(repository: File, name: String): File {
|
||||
val resolver = KonanLibrarySearchPathResolver(listOf(repository.absolutePath), null, null, skipCurrentDir = true)
|
||||
val resolver = KonanLibrarySearchPathResolver(
|
||||
repositories = listOf(repository.absolutePath),
|
||||
targetManager = null,
|
||||
distributionKlib = null,
|
||||
localKonanDir = null,
|
||||
skipCurrentDir = true
|
||||
)
|
||||
return resolver.resolve(name)
|
||||
}
|
||||
|
||||
fun libraryInCurrentDir(name: String): File {
|
||||
val resolver = KonanLibrarySearchPathResolver(emptyList(), null, null)
|
||||
val resolver = KonanLibrarySearchPathResolver(
|
||||
repositories = emptyList(),
|
||||
targetManager = null,
|
||||
distributionKlib = null,
|
||||
localKonanDir = null
|
||||
)
|
||||
return resolver.resolve(name)
|
||||
}
|
||||
|
||||
fun libraryInRepoOrCurrentDir(repository: File, name: String): File {
|
||||
val resolver = KonanLibrarySearchPathResolver(listOf(repository.absolutePath), null, null)
|
||||
val resolver = KonanLibrarySearchPathResolver(
|
||||
repositories = listOf(repository.absolutePath),
|
||||
targetManager = null,
|
||||
distributionKlib = null,
|
||||
localKonanDir = null
|
||||
)
|
||||
return resolver.resolve(name)
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ data class File constructor(internal val javaPath: Path) {
|
||||
return result
|
||||
}
|
||||
|
||||
fun child(name: String) = File(this, name)
|
||||
|
||||
fun copyTo(destination: File) {
|
||||
Files.copy(javaPath, destination.javaPath, StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user