JVM_IR: Add test for compiling against cross-platform Klib

This commit is contained in:
Georgy Bronnikov
2019-11-26 17:53:00 +03:00
parent f1b5198b86
commit 8f4b4007fe
16 changed files with 235 additions and 7 deletions
@@ -302,6 +302,13 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
)
var emitJvmTypeAnnotations: Boolean by FreezableVar(false)
@Argument(
value = "-Xklib",
valueDescription = "<path>",
description = "Paths to cross-platform libraries in .klib format"
)
val klibLibraries: String? by NullableStringFreezableVar(null)
override fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
val result = super.configureAnalysisFlags(collector)
result[JvmAnalysisFlags.strictMetadataVersionSemantics] = strictMetadataVersionSemantics
@@ -75,6 +75,7 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
configuration.configureExplicitContentRoots(arguments)
configuration.configureStandardLibs(paths, arguments)
configuration.configureAdvancedJvmOptions(arguments)
configuration.configureKlibPaths(arguments)
if (arguments.buildFile == null && !arguments.version && !arguments.allowNoSourceFiles &&
(arguments.script || arguments.expression != null || arguments.freeArgs.isEmpty())) {
@@ -138,7 +138,6 @@ fun KotlinCoreEnvironment.registerJavacIfNeeded(
return true
}
fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerArguments) {
put(JVMConfigurationKeys.PARAMETERS_METADATA, arguments.javaParameters)
@@ -199,3 +198,11 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
arguments.declarationsOutputPath?.let { put(JVMConfigurationKeys.DECLARATIONS_JSON_PATH, it) }
}
fun CompilerConfiguration.configureKlibPaths(arguments: K2JVMCompilerArguments) {
assert(arguments.useIR || arguments.klibLibraries == null) { "Klib libraries can only be used with IR backend" }
arguments.klibLibraries?.split(File.pathSeparator.toRegex())
?.toTypedArray()
?.filterNot { it.isEmpty() }
?.let { put(JVMConfigurationKeys.KLIB_PATHS, it) }
}