Rename -module argument to -Xbuild-file

To prevent confusion with Java 9 module-related arguments

 #KT-18754 Fixed
This commit is contained in:
Alexander Udalov
2017-06-23 20:59:01 +03:00
parent 6200d07808
commit 55468735df
15 changed files with 71 additions and 69 deletions
@@ -51,9 +51,6 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments {
@Argument(value = "-no-reflect", description = "Don't include Kotlin reflection implementation into classpath")
public boolean noReflect;
@Argument(value = "-module", valueDescription = "<path>", description = "Path to the module file to compile")
public String module;
@Argument(value = "-script", description = "Evaluate the script file")
public boolean script;
@@ -111,6 +108,9 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments {
@Argument(value = "-Xreport-perf", description = "Report detailed performance statistics")
public boolean reportPerf;
@Argument(value = "-Xbuild-file", deprecatedName = "-module", valueDescription = "<path>", description = "Path to the .xml build file to compile")
public String buildFile;
@Argument(value = "-Xmultifile-parts-inherit", description = "Compile multifile classes as a hierarchy of parts and facade")
public boolean inheritMultifileParts;
@@ -23,6 +23,7 @@ import java.util.*
annotation class Argument(
val value: String,
val shortName: String = "",
val deprecatedName: String = "",
val delimiter: String = ",",
val valueDescription: String = "",
val description: String
@@ -44,7 +45,10 @@ data class ArgumentParseErrors(
// Non-boolean arguments which have been passed multiple times, possibly with different values.
// The key in the map is the name of the argument, the value is the last passed value.
val duplicateArguments: MutableMap<String, String> = LinkedHashMap<String, String>(),
val duplicateArguments: MutableMap<String, String> = mutableMapOf(),
// Arguments where [Argument.deprecatedName] was used; the key is the deprecated name, the value is the new name ([Argument.value])
val deprecatedArguments: MutableMap<String, String> = mutableMapOf(),
var argumentWithoutValue: String? = null
)
@@ -62,6 +66,23 @@ fun <A : CommonToolArguments> parseCommandLineArguments(args: Array<out String>,
val visitedArgs = mutableSetOf<String>()
var freeArgsStarted = false
fun ArgumentField.matches(arg: String): Boolean {
if (argument.deprecatedName.takeUnless(String::isEmpty) == arg) {
errors.deprecatedArguments[argument.deprecatedName] = argument.value
return true
}
if (argument.value == arg) {
if (argument.isAdvanced && field.type != Boolean::class.java) {
errors.extraArgumentsPassedInObsoleteForm.add(arg)
}
return true
}
return argument.shortName.takeUnless(String::isEmpty) == arg ||
(argument.isAdvanced && arg.startsWith(argument.value + "="))
}
var i = 0
loop@ while (i < args.size) {
val arg = args[i++]
@@ -75,12 +96,7 @@ fun <A : CommonToolArguments> parseCommandLineArguments(args: Array<out String>,
continue
}
val argumentField = fields.firstOrNull { (_, argument) ->
argument.value == arg ||
argument.shortName.takeUnless(String::isEmpty) == arg ||
(argument.isAdvanced && arg.startsWith(argument.value + "="))
}
val argumentField = fields.firstOrNull { it.matches(arg) }
if (argumentField == null) {
when {
arg.startsWith(ADVANCED_ARGUMENT_PREFIX) -> errors.unknownExtraFlags.add(arg)
@@ -96,17 +112,12 @@ fun <A : CommonToolArguments> parseCommandLineArguments(args: Array<out String>,
argument.isAdvanced && arg.startsWith(argument.value + "=") -> {
arg.substring(argument.value.length + 1)
}
i == args.size -> {
errors.argumentWithoutValue = arg
break@loop
}
else -> {
if (i == args.size) {
errors.argumentWithoutValue = arg
break@loop
}
else {
if (argument.isAdvanced) {
errors.extraArgumentsPassedInObsoleteForm.add(arg)
}
args[i++]
}
args[i++]
}
}