[Commonizer] Process endorsed libraries in CLI
This commit is contained in:
+2
@@ -34,6 +34,8 @@ fun main(args: Array<String>) {
|
|||||||
repository = repository,
|
repository = repository,
|
||||||
targets = targets,
|
targets = targets,
|
||||||
destination = destination,
|
destination = destination,
|
||||||
|
copyStdlib = true,
|
||||||
|
copyEndorsedLibs = true,
|
||||||
withStats = withStats,
|
withStats = withStats,
|
||||||
handleError = ::printErrorAndExit,
|
handleError = ::printErrorAndExit,
|
||||||
log = ::println
|
log = ::println
|
||||||
|
|||||||
+19
-10
@@ -34,6 +34,8 @@ class NativeDistributionCommonizer(
|
|||||||
private val repository: File,
|
private val repository: File,
|
||||||
private val targets: List<KonanTarget>,
|
private val targets: List<KonanTarget>,
|
||||||
private val destination: File,
|
private val destination: File,
|
||||||
|
private val copyStdlib: Boolean,
|
||||||
|
private val copyEndorsedLibs: Boolean,
|
||||||
private val withStats: Boolean,
|
private val withStats: Boolean,
|
||||||
private val handleError: (String) -> Nothing,
|
private val handleError: (String) -> Nothing,
|
||||||
private val log: (String) -> Unit
|
private val log: (String) -> Unit
|
||||||
@@ -181,16 +183,23 @@ class NativeDistributionCommonizer(
|
|||||||
originalModulesByTargets: Map<InputTarget, List<NativeModuleForCommonization>>,
|
originalModulesByTargets: Map<InputTarget, List<NativeModuleForCommonization>>,
|
||||||
result: CommonizationPerformed
|
result: CommonizationPerformed
|
||||||
) {
|
) {
|
||||||
// optimization: stdlib effectively remains the same across all Kotlin/Native targets,
|
// optimization: stdlib and endorsed libraries effectively remain the same across all Kotlin/Native targets,
|
||||||
// so it can be just copied to the new destination without running serializer
|
// so they can be just copied to the new destination without running serializer
|
||||||
val stdlibOrigin = originalModulesByTargets.values.asSequence()
|
if (copyStdlib || copyEndorsedLibs) {
|
||||||
.flatten()
|
repository.resolve(KONAN_DISTRIBUTION_KLIB_DIR)
|
||||||
.filterIsInstance<DeserializedModule>()
|
.resolve(KONAN_DISTRIBUTION_COMMON_LIBS_DIR)
|
||||||
.map { it.location }
|
.listFiles()
|
||||||
.first { it.endsWith(KONAN_STDLIB_NAME) }
|
?.filter { it.isDirectory }
|
||||||
|
?.let {
|
||||||
val stdlibDestination = destination.resolve(KONAN_DISTRIBUTION_COMMON_LIBS_DIR).resolve(KONAN_STDLIB_NAME)
|
if (copyStdlib) {
|
||||||
stdlibOrigin.copyRecursively(stdlibDestination)
|
if (copyEndorsedLibs) it else it.filter { dir -> dir.endsWith(KONAN_STDLIB_NAME) }
|
||||||
|
} else
|
||||||
|
it.filter { dir -> !dir.endsWith(KONAN_STDLIB_NAME) }
|
||||||
|
}?.forEach { libraryOrigin ->
|
||||||
|
val libraryDestination = destination.resolve(KONAN_DISTRIBUTION_COMMON_LIBS_DIR).resolve(libraryOrigin.name)
|
||||||
|
libraryOrigin.copyRecursively(libraryDestination)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val originalModulesManifestData = originalModulesByTargets.mapValues { (_, modules) ->
|
val originalModulesManifestData = originalModulesByTargets.mapValues { (_, modules) ->
|
||||||
modules.asSequence()
|
modules.asSequence()
|
||||||
|
|||||||
Reference in New Issue
Block a user