[CLI] add support running scripts in js compiler, extract common code with jvm part

This commit is contained in:
Vitaliy.Tikhonov
2019-09-02 21:04:08 +03:00
committed by romanart
parent 50c08b25d3
commit f59e393e37
18 changed files with 175 additions and 122 deletions
@@ -76,6 +76,9 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
)
var progressiveMode by FreezableVar(false)
@Argument(value = "-script", description = "Evaluate the script file")
var script: Boolean by FreezableVar(false)
@Argument(value = "-P", valueDescription = PLUGIN_OPTION_FORMAT, description = "Pass an option to a plugin")
var pluginOptions: Array<String>? by FreezableVar(null)
@@ -304,6 +307,9 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
)
var useFir: Boolean by FreezableVar(false)
@Argument(value = "-Xdisable-default-scripting-plugin", description = "Do not enable scripting plugin by default")
var disableDefaultScriptingPlugin: Boolean by FreezableVar(false)
open fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
return HashMap<AnalysisFlag<*>, Any>().apply {
put(AnalysisFlags.skipMetadataVersionCheck, skipMetadataVersionCheck)
@@ -137,4 +137,7 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
@Argument(value = "-Xmetadata-only", description = "Generate *.meta.js and *.kjsm files only")
var metadataOnly: Boolean by FreezableVar(false)
@Argument(value = "-Xenable-js-scripting", description = "Enable experimental support of .kts files using K/JS (with -Xir only)")
var enableJsScripting: Boolean by FreezableVar(false)
}
@@ -45,9 +45,6 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
@Argument(value = "-no-reflect", description = "Don't include kotlin-reflect.jar into classpath")
var noReflect: Boolean by FreezableVar(false)
@Argument(value = "-script", description = "Evaluate the script file")
var script: Boolean by FreezableVar(false)
@Argument(
value = "-script-templates",
valueDescription = "<fully qualified class name[,]>",
@@ -254,9 +251,6 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
)
var jvmDefault: String by FreezableVar(JvmDefaultMode.DEFAULT.description)
@Argument(value = "-Xdisable-default-scripting-plugin", description = "Do not enable scripting plugin by default")
var disableDefaultScriptingPlugin: Boolean by FreezableVar(false)
@Argument(value = "-Xdisable-standard-script", description = "Disable standard kotlin script support")
var disableStandardScript: Boolean by FreezableVar(false)