From b90207edb9443aa548c27bd3cab53cf6191c4773 Mon Sep 17 00:00:00 2001 From: Sebastian Sellmair Date: Mon, 27 Feb 2023 12:23:24 +0100 Subject: [PATCH] [Gradle] Rename -Xdepends-on to -Xfragment-refines and use ':' for -Xfragment-sources instead of ';' ^KT-56210 Verification Pending --- .../arguments/CommonCompilerArguments.kt | 8 ++--- .../jetbrains/kotlin/cli/common/arguments.kt | 32 +++++++++++-------- compiler/testData/cli/js/jsExtraHelp.out | 6 ++-- compiler/testData/cli/js/successfulHmpp.args | 10 +++--- compiler/testData/cli/jvm/extraHelp.out | 6 ++-- .../cli/jvm/hmpp/cycleInDependencies.args | 12 +++---- .../hmpp/fragmentSourcesIncorrectSyntax.out | 2 +- .../cli/jvm/hmpp/missingFragment.args | 4 +-- .../testData/cli/jvm/hmpp/missingFragment.out | 2 +- ...leModule.args => refinesSingleModule.args} | 4 +-- ...ngleModule.out => refinesSingleModule.out} | 2 +- ...ents.args => refinesWithoutFragments.args} | 2 +- ...odules.out => refinesWithoutFragments.out} | 2 +- ...ragments.out => refinesWithoutModules.out} | 2 +- .../hmpp/sameSourceInDifferentFragments.args | 6 ++-- .../cli/jvm/hmpp/sourceNotInAnyFragment.args | 2 +- .../cli/jvm/hmpp/successfulCompilation.args | 10 +++--- .../cli/jvm/hmpp/successfulCompilation2.args | 4 +-- .../testData/cli/metadata/successfulHmpp.args | 10 +++--- .../kotlin/cli/CliTestGenerated.java | 20 ++++++------ ...nCompilationK2MultiplatformConfigurator.kt | 4 +-- .../tasks/KotlinNativeCompilerArgBuilder.kt | 2 +- .../gradle/tasks/K2MultiplatformStructure.kt | 12 +++---- .../unitTests/K2MultiplatformStructureTest.kt | 22 ++++++------- 24 files changed, 96 insertions(+), 90 deletions(-) rename compiler/testData/cli/jvm/hmpp/{dependsOnSingleModule.args => refinesSingleModule.args} (61%) rename compiler/testData/cli/jvm/hmpp/{dependsOnSingleModule.out => refinesSingleModule.out} (83%) rename compiler/testData/cli/jvm/hmpp/{dependsOnWithoutFragments.args => refinesWithoutFragments.args} (80%) rename compiler/testData/cli/jvm/hmpp/{dependsOnWithoutModules.out => refinesWithoutFragments.out} (86%) rename compiler/testData/cli/jvm/hmpp/{dependsOnWithoutFragments.out => refinesWithoutModules.out} (86%) diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt index b4ba1f0e4e9..3f695391499 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt @@ -725,7 +725,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() { @Argument( value = "-Xfragment-sources", - valueDescription = ";", + valueDescription = ":", description = "Adds sources to a specific fragment of a multiplatform compilation", ) var fragmentSources: Array? = null @@ -735,11 +735,11 @@ abstract class CommonCompilerArguments : CommonToolArguments() { } @Argument( - value = "-Xdepends-on", + value = "-Xfragment-refines", valueDescription = ":", - description = "Declares that depends on with dependsOn relation", + description = "Declares that refines with dependsOn/refines relation", ) - var dependsOnDependencies: Array? = null + var fragmentRefines: Array? = null set(value) { checkFrozen() field = value diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/arguments.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/common/arguments.kt index 0a9019257ea..58bfd8d1a12 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/arguments.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/arguments.kt @@ -132,7 +132,7 @@ private fun MessageCollector.reportUnsafeInternalArgum private fun CompilerConfiguration.buildHmppModuleStructure(arguments: CommonCompilerArguments): HmppCliModuleStructure? { val rawFragments = arguments.fragments val rawFragmentSources = arguments.fragmentSources - val rawDependencies = arguments.dependsOnDependencies + val rawFragmentRefines = arguments.fragmentRefines val messageCollector = getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY) @@ -145,8 +145,8 @@ private fun CompilerConfiguration.buildHmppModuleStructure(arguments: CommonComp } if (rawFragments == null) { - if (rawDependencies != null) { - reportError("-Xdepends-on flag can not be used without -Xfragments") + if (rawFragmentRefines != null) { + reportError("-Xfragment-refines flag can not be used without -Xfragments") } return null } @@ -159,11 +159,11 @@ private fun CompilerConfiguration.buildHmppModuleStructure(arguments: CommonComp val sourcesByFragmentName: Map> = rawFragments.associateWith { mutableSetOf() }.apply { rawFragmentSources.orEmpty().forEach { rawFragmentSourceArg -> - val split = rawFragmentSourceArg.split(";") - if (split.size != 2) { + val split = rawFragmentSourceArg.split(":", limit = 2) + if (split.size < 2) { reportError( "Incorrect syntax for -Xfragment-sources argument. " + - "`;` expected but got `$rawFragmentSourceArg`" + "`:` expected but got `$rawFragmentSourceArg`" ) return@forEach } @@ -171,7 +171,10 @@ private fun CompilerConfiguration.buildHmppModuleStructure(arguments: CommonComp val fragmentSource = split[1] getOrElse(fragmentName) { - reportError("fragment `$fragmentName` of source file $fragmentSource is not specified in -Xfragments") + reportError( + "Passed $rawFragmentSourceArg, " + + "but fragment `$fragmentName` of source file $fragmentSource is not specified in -Xfragments" + ) return@forEach }.add(fragmentSource) } @@ -218,8 +221,8 @@ private fun CompilerConfiguration.buildHmppModuleStructure(arguments: CommonComp } if (modules.size == 1) { - if (rawDependencies?.isNotEmpty() == true) { - reportError("-Xdepends-on flag is specified but there is only one module declared") + if (rawFragmentRefines?.isNotEmpty() == true) { + reportError("-Xfragment-refines flag is specified but there is only one module declared") } return HmppCliModuleStructure(modules, emptyMap()) } @@ -233,10 +236,13 @@ private fun CompilerConfiguration.buildHmppModuleStructure(arguments: CommonComp val moduleByName = modules.associateBy { it.name } - val dependenciesMap = rawDependencies.orEmpty().mapNotNull { - val split = it.split(":") + val dependenciesMap = rawFragmentRefines.orEmpty().mapNotNull { rawFragmentRefinesEdge -> + val split = rawFragmentRefinesEdge.split(":") if (split.size != 2) { - reportError("Incorrect syntax for -Xdepends-on argument. Expected : but got `$it`") + reportError( + "Incorrect syntax for -Xfragment-refines argument. " + + "Expected : but got `$rawFragmentRefines`" + ) return@mapNotNull null } val moduleName1 = split[0] @@ -245,7 +251,7 @@ private fun CompilerConfiguration.buildHmppModuleStructure(arguments: CommonComp fun findModule(name: String): HmppCliModule? { return moduleByName[name].also { module -> if (module == null) { - reportError("Module `$name` not found in -Xfragments arguments") + reportError("`-Xfragment-refines=$rawFragmentRefinesEdge` Fragment `$name` not found in -Xfragments arguments") } } } diff --git a/compiler/testData/cli/js/jsExtraHelp.out b/compiler/testData/cli/js/jsExtraHelp.out index bf08e1fab95..b81706ecd8a 100644 --- a/compiler/testData/cli/js/jsExtraHelp.out +++ b/compiler/testData/cli/js/jsExtraHelp.out @@ -63,8 +63,6 @@ where advanced options include: -Xcommon-sources= Sources of the common module that need to be compiled together with this module in the multi-platform mode. Should be a subset of sources passed as free arguments -Xcontext-receivers Enable experimental context receivers - -Xdepends-on=: - Declares that depends on with dependsOn relation -Xdisable-default-scripting-plugin Do not enable scripting plugin by default -Xdisable-phases Disable backend phases @@ -83,7 +81,9 @@ where advanced options include: Use 'warning' level to issue warnings instead of errors. -Xextended-compiler-checks Enable additional compiler checks that might provide verbose diagnostic information for certain errors. Warning: this mode is not backward-compatible and might cause compilation errors in previously compiled code. - -Xfragment-sources=; + -Xfragment-refines=: + Declares that refines with dependsOn/refines relation + -Xfragment-sources=: Adds sources to a specific fragment of a multiplatform compilation -Xfragments= Declares all known fragments of a multiplatform compilation -Xenable-incremental-compilation diff --git a/compiler/testData/cli/js/successfulHmpp.args b/compiler/testData/cli/js/successfulHmpp.args index df5a44f5e90..0ff0034ea2e 100644 --- a/compiler/testData/cli/js/successfulHmpp.args +++ b/compiler/testData/cli/js/successfulHmpp.args @@ -9,8 +9,8 @@ fir-hmpp 2.0 -XXLanguage\:+MultiPlatformProjects -Xfragments=a,b,c --Xfragment-sources=a;$TESTDATA_DIR$/../jvm/hmpp/src/a.kt --Xfragment-sources=b;$TESTDATA_DIR$/../jvm/hmpp/src/b.kt --Xfragment-sources=c;$TESTDATA_DIR$/../jvm/hmpp/src/c.kt --Xdepends-on=b\:a --Xdepends-on=c\:b +-Xfragment-sources=a\:$TESTDATA_DIR$/../jvm/hmpp/src/a.kt +-Xfragment-sources=b\:$TESTDATA_DIR$/../jvm/hmpp/src/b.kt +-Xfragment-sources=c\:$TESTDATA_DIR$/../jvm/hmpp/src/c.kt +-Xfragment-refines=b\:a +-Xfragment-refines=c\:b diff --git a/compiler/testData/cli/jvm/extraHelp.out b/compiler/testData/cli/jvm/extraHelp.out index cf6457bb9c2..3abb36901ca 100644 --- a/compiler/testData/cli/jvm/extraHelp.out +++ b/compiler/testData/cli/jvm/extraHelp.out @@ -169,8 +169,6 @@ where advanced options include: -Xcommon-sources= Sources of the common module that need to be compiled together with this module in the multi-platform mode. Should be a subset of sources passed as free arguments -Xcontext-receivers Enable experimental context receivers - -Xdepends-on=: - Declares that depends on with dependsOn relation -Xdisable-default-scripting-plugin Do not enable scripting plugin by default -Xdisable-phases Disable backend phases @@ -189,7 +187,9 @@ where advanced options include: Use 'warning' level to issue warnings instead of errors. -Xextended-compiler-checks Enable additional compiler checks that might provide verbose diagnostic information for certain errors. Warning: this mode is not backward-compatible and might cause compilation errors in previously compiled code. - -Xfragment-sources=; + -Xfragment-refines=: + Declares that refines with dependsOn/refines relation + -Xfragment-sources=: Adds sources to a specific fragment of a multiplatform compilation -Xfragments= Declares all known fragments of a multiplatform compilation -Xenable-incremental-compilation diff --git a/compiler/testData/cli/jvm/hmpp/cycleInDependencies.args b/compiler/testData/cli/jvm/hmpp/cycleInDependencies.args index f738f885f54..2efdae0dfd8 100644 --- a/compiler/testData/cli/jvm/hmpp/cycleInDependencies.args +++ b/compiler/testData/cli/jvm/hmpp/cycleInDependencies.args @@ -7,9 +7,9 @@ $TEMP_DIR$ 2.0 -XXLanguage\:+MultiPlatformProjects -Xfragments=a,b,c --Xfragment-sources=a;$TESTDATA_DIR$/src/a.kt --Xfragment-sources=b;$TESTDATA_DIR$/src/b.kt --Xfragment-sources=c;$TESTDATA_DIR$/src/c.kt --Xdepends-on=b\:a --Xdepends-on=c\:b --Xdepends-on=a\:c +-Xfragment-sources=a\:$TESTDATA_DIR$/src/a.kt +-Xfragment-sources=b\:$TESTDATA_DIR$/src/b.kt +-Xfragment-sources=c\:$TESTDATA_DIR$/src/c.kt +-Xfragment-refines=b\:a +-Xfragment-refines=c\:b +-Xfragment-refines=a\:c diff --git a/compiler/testData/cli/jvm/hmpp/fragmentSourcesIncorrectSyntax.out b/compiler/testData/cli/jvm/hmpp/fragmentSourcesIncorrectSyntax.out index 5259245ab71..fb3022797ee 100644 --- a/compiler/testData/cli/jvm/hmpp/fragmentSourcesIncorrectSyntax.out +++ b/compiler/testData/cli/jvm/hmpp/fragmentSourcesIncorrectSyntax.out @@ -8,7 +8,7 @@ as no stability/compatibility guarantees are given on compiler or generated code. Use it at your own risk! warning: language version 2.0 is experimental, there are no backwards compatibility guarantees for new language and library features -error: incorrect syntax for -Xfragment-sources argument. `;` expected but got `a;a.kt;` +error: incorrect syntax for -Xfragment-sources argument. `:` expected but got `a;a.kt;` error: source '$TESTDATA_DIR$/src/a.kt' does not belong to any module error: source '$TESTDATA_DIR$/src/b.kt' does not belong to any module COMPILATION_ERROR diff --git a/compiler/testData/cli/jvm/hmpp/missingFragment.args b/compiler/testData/cli/jvm/hmpp/missingFragment.args index 06e701b4a68..aa136d0ff9d 100644 --- a/compiler/testData/cli/jvm/hmpp/missingFragment.args +++ b/compiler/testData/cli/jvm/hmpp/missingFragment.args @@ -6,5 +6,5 @@ $TEMP_DIR$ 2.0 -XXLanguage\:+MultiPlatformProjects -Xfragments=a,b --Xfragment-sources=a;$TESTDATA_DIR$/src/a.kt,b;$TESTDATA_DIR$/src/b.kt --Xdepends-on=c\:a +-Xfragment-sources=a\:$TESTDATA_DIR$/src/a.kt,b\:$TESTDATA_DIR$/src/b.kt +-Xfragment-refines=c\:a diff --git a/compiler/testData/cli/jvm/hmpp/missingFragment.out b/compiler/testData/cli/jvm/hmpp/missingFragment.out index 5d25de3b052..b37f23fb68f 100644 --- a/compiler/testData/cli/jvm/hmpp/missingFragment.out +++ b/compiler/testData/cli/jvm/hmpp/missingFragment.out @@ -8,5 +8,5 @@ as no stability/compatibility guarantees are given on compiler or generated code. Use it at your own risk! warning: language version 2.0 is experimental, there are no backwards compatibility guarantees for new language and library features -error: module `c` not found in -Xfragments arguments +error: `-Xfragment-refines=c:a` Fragment `c` not found in -Xfragments arguments COMPILATION_ERROR diff --git a/compiler/testData/cli/jvm/hmpp/dependsOnSingleModule.args b/compiler/testData/cli/jvm/hmpp/refinesSingleModule.args similarity index 61% rename from compiler/testData/cli/jvm/hmpp/dependsOnSingleModule.args rename to compiler/testData/cli/jvm/hmpp/refinesSingleModule.args index 7ab57b889a1..737101014aa 100644 --- a/compiler/testData/cli/jvm/hmpp/dependsOnSingleModule.args +++ b/compiler/testData/cli/jvm/hmpp/refinesSingleModule.args @@ -5,5 +5,5 @@ $TEMP_DIR$ 2.0 -XXLanguage\:+MultiPlatformProjects -Xfragments=a --Xfragment-sources=a;$TESTDATA_DIR$/src/a.kt --Xdepends-on=b\:a +-Xfragment-sources=a\:$TESTDATA_DIR$/src/a.kt +-Xfragment-refines=b\:a diff --git a/compiler/testData/cli/jvm/hmpp/dependsOnSingleModule.out b/compiler/testData/cli/jvm/hmpp/refinesSingleModule.out similarity index 83% rename from compiler/testData/cli/jvm/hmpp/dependsOnSingleModule.out rename to compiler/testData/cli/jvm/hmpp/refinesSingleModule.out index edd058e2761..63292d96b33 100644 --- a/compiler/testData/cli/jvm/hmpp/dependsOnSingleModule.out +++ b/compiler/testData/cli/jvm/hmpp/refinesSingleModule.out @@ -8,5 +8,5 @@ as no stability/compatibility guarantees are given on compiler or generated code. Use it at your own risk! warning: language version 2.0 is experimental, there are no backwards compatibility guarantees for new language and library features -error: -Xdepends-on flag is specified but there is only one module declared +error: -Xfragment-refines flag is specified but there is only one module declared COMPILATION_ERROR diff --git a/compiler/testData/cli/jvm/hmpp/dependsOnWithoutFragments.args b/compiler/testData/cli/jvm/hmpp/refinesWithoutFragments.args similarity index 80% rename from compiler/testData/cli/jvm/hmpp/dependsOnWithoutFragments.args rename to compiler/testData/cli/jvm/hmpp/refinesWithoutFragments.args index 3522423d1a1..df9f334a2ec 100644 --- a/compiler/testData/cli/jvm/hmpp/dependsOnWithoutFragments.args +++ b/compiler/testData/cli/jvm/hmpp/refinesWithoutFragments.args @@ -4,4 +4,4 @@ $TEMP_DIR$ -language-version 2.0 -XXLanguage\:+MultiPlatformProjects --Xdepends-on=a\:b +-Xfragment-refines=a\:b diff --git a/compiler/testData/cli/jvm/hmpp/dependsOnWithoutModules.out b/compiler/testData/cli/jvm/hmpp/refinesWithoutFragments.out similarity index 86% rename from compiler/testData/cli/jvm/hmpp/dependsOnWithoutModules.out rename to compiler/testData/cli/jvm/hmpp/refinesWithoutFragments.out index 41c95a7bed5..c70f305b2fc 100644 --- a/compiler/testData/cli/jvm/hmpp/dependsOnWithoutModules.out +++ b/compiler/testData/cli/jvm/hmpp/refinesWithoutFragments.out @@ -8,5 +8,5 @@ as no stability/compatibility guarantees are given on compiler or generated code. Use it at your own risk! warning: language version 2.0 is experimental, there are no backwards compatibility guarantees for new language and library features -error: -Xdepends-on flag can not be used without -Xfragments +error: -Xfragment-refines flag can not be used without -Xfragments COMPILATION_ERROR diff --git a/compiler/testData/cli/jvm/hmpp/dependsOnWithoutFragments.out b/compiler/testData/cli/jvm/hmpp/refinesWithoutModules.out similarity index 86% rename from compiler/testData/cli/jvm/hmpp/dependsOnWithoutFragments.out rename to compiler/testData/cli/jvm/hmpp/refinesWithoutModules.out index 41c95a7bed5..c70f305b2fc 100644 --- a/compiler/testData/cli/jvm/hmpp/dependsOnWithoutFragments.out +++ b/compiler/testData/cli/jvm/hmpp/refinesWithoutModules.out @@ -8,5 +8,5 @@ as no stability/compatibility guarantees are given on compiler or generated code. Use it at your own risk! warning: language version 2.0 is experimental, there are no backwards compatibility guarantees for new language and library features -error: -Xdepends-on flag can not be used without -Xfragments +error: -Xfragment-refines flag can not be used without -Xfragments COMPILATION_ERROR diff --git a/compiler/testData/cli/jvm/hmpp/sameSourceInDifferentFragments.args b/compiler/testData/cli/jvm/hmpp/sameSourceInDifferentFragments.args index fc149111a39..02e47f82028 100644 --- a/compiler/testData/cli/jvm/hmpp/sameSourceInDifferentFragments.args +++ b/compiler/testData/cli/jvm/hmpp/sameSourceInDifferentFragments.args @@ -6,6 +6,6 @@ $TEMP_DIR$ 2.0 -XXLanguage\:+MultiPlatformProjects -Xfragments=a,b --Xfragment-sources=a;$TESTDATA_DIR$/src/a.kt --Xfragment-sources=b;$TESTDATA_DIR$/src/a.kt --Xfragment-sources=b;$TESTDATA_DIR$/src/b.kt +-Xfragment-sources=a\:$TESTDATA_DIR$/src/a.kt +-Xfragment-sources=b\:$TESTDATA_DIR$/src/a.kt +-Xfragment-sources=b\:$TESTDATA_DIR$/src/b.kt diff --git a/compiler/testData/cli/jvm/hmpp/sourceNotInAnyFragment.args b/compiler/testData/cli/jvm/hmpp/sourceNotInAnyFragment.args index 9d04980e06f..2c7ee87b11e 100644 --- a/compiler/testData/cli/jvm/hmpp/sourceNotInAnyFragment.args +++ b/compiler/testData/cli/jvm/hmpp/sourceNotInAnyFragment.args @@ -6,4 +6,4 @@ $TEMP_DIR$ 2.0 -XXLanguage\:+MultiPlatformProjects -Xfragments=a,b --Xfragment-sources=a;$TESTDATA_DIR$/src/a.kt +-Xfragment-sources=a\:$TESTDATA_DIR$/src/a.kt diff --git a/compiler/testData/cli/jvm/hmpp/successfulCompilation.args b/compiler/testData/cli/jvm/hmpp/successfulCompilation.args index 2c04cc08a55..0f25822e530 100644 --- a/compiler/testData/cli/jvm/hmpp/successfulCompilation.args +++ b/compiler/testData/cli/jvm/hmpp/successfulCompilation.args @@ -9,8 +9,8 @@ $TEMP_DIR$ -Xfragments=a -Xfragments=b -Xfragments=c --Xfragment-sources=a;$TESTDATA_DIR$/src/a.kt --Xfragment-sources=b;$TESTDATA_DIR$/src/b.kt --Xfragment-sources=c;$TESTDATA_DIR$/src/c.kt --Xdepends-on=b\:a --Xdepends-on=c\:b +-Xfragment-sources=a\:$TESTDATA_DIR$/src/a.kt +-Xfragment-sources=b\:$TESTDATA_DIR$/src/b.kt +-Xfragment-sources=c\:$TESTDATA_DIR$/src/c.kt +-Xfragment-refines=b\:a +-Xfragment-refines=c\:b diff --git a/compiler/testData/cli/jvm/hmpp/successfulCompilation2.args b/compiler/testData/cli/jvm/hmpp/successfulCompilation2.args index a276514f70e..a4abd086a7b 100644 --- a/compiler/testData/cli/jvm/hmpp/successfulCompilation2.args +++ b/compiler/testData/cli/jvm/hmpp/successfulCompilation2.args @@ -7,5 +7,5 @@ $TEMP_DIR$ 2.0 -XXLanguage\:+MultiPlatformProjects -Xfragments=a,b,c --Xfragment-sources=a;$TESTDATA_DIR$/src/a.kt,b;$TESTDATA_DIR$/src/b.kt,c;$TESTDATA_DIR$/src/c.kt --Xdepends-on=b\:a,c\:b +-Xfragment-sources=a\:$TESTDATA_DIR$/src/a.kt,b\:$TESTDATA_DIR$/src/b.kt,c\:$TESTDATA_DIR$/src/c.kt +-Xfragment-refines=b\:a,c\:b diff --git a/compiler/testData/cli/metadata/successfulHmpp.args b/compiler/testData/cli/metadata/successfulHmpp.args index c5b82f4813a..7599069f856 100644 --- a/compiler/testData/cli/metadata/successfulHmpp.args +++ b/compiler/testData/cli/metadata/successfulHmpp.args @@ -7,8 +7,8 @@ $TEMP_DIR$ 2.0 -XXLanguage\:+MultiPlatformProjects -Xfragments=a,b,c --Xfragment-sources=a;$TESTDATA_DIR$/../jvm/hmpp/src/a.kt --Xfragment-sources=b;$TESTDATA_DIR$/../jvm/hmpp/src/b.kt --Xfragment-sources=c;$TESTDATA_DIR$/../jvm/hmpp/src/c.kt --Xdepends-on=b\:a --Xdepends-on=c\:b +-Xfragment-sources=a\:$TESTDATA_DIR$/../jvm/hmpp/src/a.kt +-Xfragment-sources=b\:$TESTDATA_DIR$/../jvm/hmpp/src/b.kt +-Xfragment-sources=c\:$TESTDATA_DIR$/../jvm/hmpp/src/c.kt +-Xfragment-refines=b\:a +-Xfragment-refines=c\:b diff --git a/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java index 92d98ed2a09..db6032c2f16 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java @@ -122,16 +122,6 @@ public class CliTestGenerated extends AbstractCliTest { runTest("compiler/testData/cli/jvm/hmpp/cycleInDependencies.args"); } - @TestMetadata("dependsOnSingleModule.args") - public void testDependsOnSingleModule() throws Exception { - runTest("compiler/testData/cli/jvm/hmpp/dependsOnSingleModule.args"); - } - - @TestMetadata("dependsOnWithoutFragments.args") - public void testDependsOnWithoutFragments() throws Exception { - runTest("compiler/testData/cli/jvm/hmpp/dependsOnWithoutFragments.args"); - } - @TestMetadata("duplicatedFragments.args") public void testDuplicatedFragments() throws Exception { runTest("compiler/testData/cli/jvm/hmpp/duplicatedFragments.args"); @@ -157,6 +147,16 @@ public class CliTestGenerated extends AbstractCliTest { runTest("compiler/testData/cli/jvm/hmpp/missingFragment.args"); } + @TestMetadata("refinesSingleModule.args") + public void testRefinesSingleModule() throws Exception { + runTest("compiler/testData/cli/jvm/hmpp/refinesSingleModule.args"); + } + + @TestMetadata("refinesWithoutFragments.args") + public void testRefinesWithoutFragments() throws Exception { + runTest("compiler/testData/cli/jvm/hmpp/refinesWithoutFragments.args"); + } + @TestMetadata("sameSourceInDifferentFragments.args") public void testSameSourceInDifferentFragments() throws Exception { runTest("compiler/testData/cli/jvm/hmpp/sameSourceInDifferentFragments.args"); diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/compilationImpl/KotlinCompilationK2MultiplatformConfigurator.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/compilationImpl/KotlinCompilationK2MultiplatformConfigurator.kt index 24350f7cad7..8b408bf1255 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/compilationImpl/KotlinCompilationK2MultiplatformConfigurator.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/compilationImpl/KotlinCompilationK2MultiplatformConfigurator.kt @@ -15,10 +15,10 @@ internal object KotlinCompilationK2MultiplatformConfigurator : KotlinCompilation if (compileTask.name != compilation.compileKotlinTaskName) return@configureEach if (compileTask !is K2CompileTask) return@configureEach - compileTask.multiplatformStructure.dependsOnEdges.set(compilation.project.provider { + compileTask.multiplatformStructure.refinesEdges.set(compilation.project.provider { compilation.allKotlinSourceSets.flatMap { sourceSet -> sourceSet.dependsOn.map { dependsOn -> - K2MultiplatformStructure.DependsOnEdge(sourceSet.name, dependsOn.name) + K2MultiplatformStructure.RefinesEdge(sourceSet.name, dependsOn.name) } } }) diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeCompilerArgBuilder.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeCompilerArgBuilder.kt index 2f013a9a73c..c64b82cf662 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeCompilerArgBuilder.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeCompilerArgBuilder.kt @@ -88,7 +88,7 @@ internal fun buildKotlinNativeKlibCompilerArgs( if (sharedCompilationData == null) { add("-Xfragments=${k2MultiplatformCompilationData.fragmentsCompilerArgs.joinToString(",")}") add("-Xfragment-sources=${k2MultiplatformCompilationData.fragmentSourcesCompilerArgs.joinToString(",")}") - add("-Xdepends-on=${k2MultiplatformCompilationData.dependsOnCompilerArgs.joinToString(",")}") + add("-Xfragment-refines=${k2MultiplatformCompilationData.fragmentRefinesCompilerArgs.joinToString(",")}") } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/tasks/K2MultiplatformStructure.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/tasks/K2MultiplatformStructure.kt index 1c094f8cf0a..b76a4587c71 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/tasks/K2MultiplatformStructure.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/tasks/K2MultiplatformStructure.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.gradle.dsl.usesK2 abstract class K2MultiplatformStructure { @InternalKotlinGradlePluginApi - data class DependsOnEdge( + data class RefinesEdge( @Input val fromFragmentName: String, @Input @@ -41,7 +41,7 @@ abstract class K2MultiplatformStructure { ) @get:Nested - abstract val dependsOnEdges: SetProperty + abstract val refinesEdges: SetProperty @get:Nested abstract val fragments: ListProperty @@ -52,18 +52,18 @@ internal val K2MultiplatformStructure.fragmentsCompilerArgs: Array internal val K2MultiplatformStructure.fragmentSourcesCompilerArgs: Array get() = fragments.get().flatMap { sourceSet -> - sourceSet.sources.files.map { sourceFile -> "${sourceSet.fragmentName};${sourceFile.absolutePath}" } + sourceSet.sources.files.map { sourceFile -> "${sourceSet.fragmentName}:${sourceFile.absolutePath}" } }.toTypedArray() -internal val K2MultiplatformStructure.dependsOnCompilerArgs: Array - get() = dependsOnEdges.get().map { edge -> +internal val K2MultiplatformStructure.fragmentRefinesCompilerArgs: Array + get() = refinesEdges.get().map { edge -> "${edge.fromFragmentName}:${edge.toFragmentName}" }.toTypedArray() internal fun CommonCompilerArguments.configureK2Multiplatform(multiplatformStructure: K2MultiplatformStructure) { fragments = multiplatformStructure.fragmentsCompilerArgs fragmentSources = multiplatformStructure.fragmentSourcesCompilerArgs - dependsOnDependencies = multiplatformStructure.dependsOnCompilerArgs + fragmentRefines = multiplatformStructure.fragmentRefinesCompilerArgs } internal fun CommonCompilerArguments.configureMultiplatform( diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/K2MultiplatformStructureTest.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/K2MultiplatformStructureTest.kt index bd03c4b3d6e..e34d7b2d9be 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/K2MultiplatformStructureTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/K2MultiplatformStructureTest.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.IR import org.jetbrains.kotlin.gradle.tasks.K2CompileTask import org.jetbrains.kotlin.gradle.tasks.K2MultiplatformStructure -import org.jetbrains.kotlin.gradle.tasks.K2MultiplatformStructure.DependsOnEdge +import org.jetbrains.kotlin.gradle.tasks.K2MultiplatformStructure.RefinesEdge import org.jetbrains.kotlin.gradle.tasks.K2MultiplatformStructure.Fragment import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile import org.jetbrains.kotlin.gradle.tasks.configureK2Multiplatform @@ -43,7 +43,7 @@ class K2MultiplatformStructureTest { @Test fun `test - configureK2Multiplatform - then parse arguments`() { val structure = project.objects.newInstance() - structure.dependsOnEdges.set(listOf(DependsOnEdge("a", "b"), DependsOnEdge("b", "c"))) + structure.refinesEdges.set(listOf(RefinesEdge("a", "b"), RefinesEdge("b", "c"))) structure.fragments.set( listOf( Fragment("a", project.files("a.kt")), @@ -65,13 +65,13 @@ class K2MultiplatformStructureTest { val fragmentSources = parsedArguments.fragmentSources ?: fail("Missing ${CommonCompilerArguments::fragmentSources.name}") assertEquals( listOf( - "a;${project.file("a.kt").absolutePath}", - "b;${project.file("b.kt").absolutePath}" + "a:${project.file("a.kt").absolutePath}", + "b:${project.file("b.kt").absolutePath}" ), fragmentSources.toList() ) - val dependsOn = parsedArguments.dependsOnDependencies ?: fail("Missing ${CommonCompilerArguments::dependsOnDependencies.name}") + val dependsOn = parsedArguments.fragmentRefines ?: fail("Missing ${CommonCompilerArguments::fragmentRefines.name}") assertEquals(listOf("a:b", "b:c"), dependsOn.toList()) } @@ -116,11 +116,11 @@ class K2MultiplatformStructureTest { /* check dependsOnEdges */ assertEquals( setOf( - DependsOnEdge(defaultSourceSet.name, "commonMain"), - DependsOnEdge(defaultSourceSet.name, "intermediateMain"), - DependsOnEdge("intermediateMain", "commonMain") + RefinesEdge(defaultSourceSet.name, "commonMain"), + RefinesEdge(defaultSourceSet.name, "intermediateMain"), + RefinesEdge("intermediateMain", "commonMain") ), - compileTask.multiplatformStructure.dependsOnEdges.get().toSet() + compileTask.multiplatformStructure.refinesEdges.get().toSet() ) /* check source files */ @@ -149,8 +149,8 @@ class K2MultiplatformStructureTest { fail("Missing ${CommonCompilerArguments::fragmentSources.name} in K2 compilation") } - if (args.dependsOnDependencies == null) { - fail("Missing ${CommonCompilerArguments::dependsOnDependencies.name} in K2 compilation") + if (args.fragmentRefines == null) { + fail("Missing ${CommonCompilerArguments::fragmentRefines.name} in K2 compilation") } } }