diff --git a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/CommonCompilerArguments.java b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/CommonCompilerArguments.java index f46fd1442c2..dbc649a2e50 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/CommonCompilerArguments.java +++ b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/CommonCompilerArguments.java @@ -41,6 +41,9 @@ public abstract class CommonCompilerArguments { @ValueDescription(SUPPRESS_WARNINGS) public String suppress; + @Argument(value = "X", description = "Print a synopsis of advanced options") + public boolean extraHelp; + public List freeArgs = new SmartList(); public boolean suppressAllWarnings() { diff --git a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/K2JVMCompilerArguments.java b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/K2JVMCompilerArguments.java index 106d7b3bd88..0869147f316 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/K2JVMCompilerArguments.java +++ b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/K2JVMCompilerArguments.java @@ -48,12 +48,6 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments { @Argument(value = "noJdkAnnotations", description = "Don't include JDK external annotations into classpath") public boolean noJdkAnnotations; - @Argument(value = "notNullAssertions", description = "Generate not-null assertion after each invocation of method returning not-null") - public boolean notNullAssertions; - - @Argument(value = "notNullParamAssertions", description = "Generate not-null assertions on parameters of methods accessible from Java") - public boolean notNullParamAssertions; - @Argument(value = "module", description = "Path to the module file to compile") @ValueDescription("") public String module; @@ -65,13 +59,19 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments { @ValueDescription("") public String kotlinHome; - @Argument(value = "inline", description = "Inlining mode (default is on)") - @ValueDescription("{on,off}") - public String inline; + // Advanced options - @Argument(value = "optimize", description = "Optimization mode (default is on)") - @ValueDescription("{on,off}") - public String optimize; + @Argument(value = "Xno-call-assertions", description = "Don't generate not-null assertion after each invocation of method returning not-null") + public boolean noCallAssertions; + + @Argument(value = "Xno-param-assertions", description = "Don't generate not-null assertions on parameters of methods accessible from Java") + public boolean noParamAssertions; + + @Argument(value = "Xno-inline", description = "Disable method inlining") + public boolean noInline; + + @Argument(value = "Xno-optimize", description = "Disable optimizations") + public boolean noOptimize; @Override @NotNull diff --git a/compiler/cli/src/org/jetbrains/jet/cli/common/CLICompiler.java b/compiler/cli/src/org/jetbrains/jet/cli/common/CLICompiler.java index 3e1ab10e3e3..f36acbd4795 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/common/CLICompiler.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/common/CLICompiler.java @@ -61,12 +61,11 @@ public abstract class CLICompiler { protected boolean parseArguments(@NotNull PrintStream errStream, @NotNull A arguments, @NotNull String[] args) { try { arguments.freeArgs = Args.parse(arguments, args); - checkArguments(arguments); return true; } catch (IllegalArgumentException e) { errStream.println(e.getMessage()); - usage(errStream); + usage(errStream, false); } catch (Throwable t) { // Always use tags @@ -75,15 +74,11 @@ public abstract class CLICompiler { return false; } - protected void checkArguments(@NotNull A argument) { - - } - /** * Allow derived classes to add additional command line arguments */ - protected void usage(@NotNull PrintStream target) { - Usage.print(target, createArguments()); + protected void usage(@NotNull PrintStream target, boolean extraHelp) { + Usage.print(target, createArguments(), extraHelp); } /** @@ -102,8 +97,8 @@ public abstract class CLICompiler { */ @NotNull public ExitCode exec(@NotNull PrintStream errStream, @NotNull A arguments) { - if (arguments.help) { - usage(errStream); + if (arguments.help || arguments.extraHelp) { + usage(errStream, arguments.extraHelp); return OK; } diff --git a/compiler/cli/src/org/jetbrains/jet/cli/common/Usage.java b/compiler/cli/src/org/jetbrains/jet/cli/common/Usage.java index d6d53997bce..a648742a494 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/common/Usage.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/common/Usage.java @@ -29,35 +29,39 @@ class Usage { // The magic number 29 corresponds to the similar padding width in javac and scalac command line compilers private static final int OPTION_NAME_PADDING_WIDTH = 29; - public static void print(@NotNull PrintStream target, @NotNull CommonCompilerArguments arguments) { + public static void print(@NotNull PrintStream target, @NotNull CommonCompilerArguments arguments, boolean extraHelp) { target.println("Usage: " + arguments.executableScriptFileName() + " "); - target.println("where possible options include:"); + target.println("where " + (extraHelp ? "advanced" : "possible") + " options include:"); for (Class clazz = arguments.getClass(); clazz != null; clazz = clazz.getSuperclass()) { for (Field field : clazz.getDeclaredFields()) { - String usage = fieldUsage(field); + String usage = fieldUsage(field, extraHelp); if (usage != null) { target.println(usage); } } } + + if (extraHelp) { + target.println(); + target.println("Advanced options are non-standard and may be changed or removed without any notice."); + } } @Nullable - private static String fieldUsage(@NotNull Field field) { + private static String fieldUsage(@NotNull Field field, boolean extraHelp) { Argument argument = field.getAnnotation(Argument.class); if (argument == null) return null; ValueDescription description = field.getAnnotation(ValueDescription.class); + String value = argument.value(); + boolean extraOption = value.startsWith("X") && value.length() > 1; + if (extraHelp != extraOption) return null; + String prefix = argument.prefix(); StringBuilder sb = new StringBuilder(" "); sb.append(prefix); - if (argument.value().isEmpty()) { - sb.append(field.getName()); - } - else { - sb.append(argument.value()); - } + sb.append(value); if (!argument.alias().isEmpty()) { sb.append(" ("); sb.append(prefix); diff --git a/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java b/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java index f94397b641a..9473e50dce1 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java @@ -23,7 +23,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.cli.common.CLICompiler; import org.jetbrains.jet.cli.common.CLIConfigurationKeys; import org.jetbrains.jet.cli.common.ExitCode; -import org.jetbrains.jet.cli.common.arguments.CompilerArgumentsUtil; import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments; import org.jetbrains.jet.cli.common.messages.*; import org.jetbrains.jet.cli.common.modules.ModuleScriptData; @@ -33,8 +32,6 @@ import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment; import org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler; import org.jetbrains.jet.cli.jvm.repl.ReplFromTerminal; import org.jetbrains.jet.codegen.CompilationException; -import org.jetbrains.jet.codegen.inline.InlineCodegenUtil; -import org.jetbrains.jet.codegen.optimization.OptimizationUtils; import org.jetbrains.jet.config.CommonConfigurationKeys; import org.jetbrains.jet.config.CompilerConfiguration; import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter; @@ -103,12 +100,10 @@ public class K2JVMCompiler extends CLICompiler { ? CommandLineScriptUtils.scriptParameters() : Collections.emptyList()); - configuration.put(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, arguments.notNullAssertions); - configuration.put(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, arguments.notNullParamAssertions); - configuration.put(JVMConfigurationKeys.ENABLE_INLINE, - CompilerArgumentsUtil.optionToBooleanFlag(arguments.inline, InlineCodegenUtil.DEFAULT_INLINE_FLAG)); - configuration.put(JVMConfigurationKeys.ENABLE_OPTIMIZATION, - CompilerArgumentsUtil.optionToBooleanFlag(arguments.optimize, OptimizationUtils.DEFAULT_OPTIMIZATION_FLAG)); + configuration.put(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, !arguments.noCallAssertions); + configuration.put(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, !arguments.noParamAssertions); + configuration.put(JVMConfigurationKeys.ENABLE_INLINE, !arguments.noInline); + configuration.put(JVMConfigurationKeys.ENABLE_OPTIMIZATION, !arguments.noOptimize); configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector); @@ -208,18 +203,4 @@ public class K2JVMCompiler extends CLICompiler { } return annotationsPath; } - - @Override - protected void checkArguments(@NotNull K2JVMCompilerArguments argument) { - super.checkArguments(argument); - - if (!CompilerArgumentsUtil.checkOption(argument.inline)) { - throw new IllegalArgumentException(CompilerArgumentsUtil.getWrongCheckOptionErrorMessage("inline", argument.inline)); - } - - if (!CompilerArgumentsUtil.checkOption(argument.optimize)) { - throw new IllegalArgumentException(CompilerArgumentsUtil.getWrongCheckOptionErrorMessage("optimize", argument.optimize)); - } - } - } diff --git a/compiler/testData/cli/js/jsExtraHelp.args b/compiler/testData/cli/js/jsExtraHelp.args new file mode 100644 index 00000000000..653774072c9 --- /dev/null +++ b/compiler/testData/cli/js/jsExtraHelp.args @@ -0,0 +1 @@ +-X diff --git a/compiler/testData/cli/js/jsExtraHelp.out b/compiler/testData/cli/js/jsExtraHelp.out new file mode 100644 index 00000000000..c5870f3991c --- /dev/null +++ b/compiler/testData/cli/js/jsExtraHelp.out @@ -0,0 +1,5 @@ +Usage: kotlinc-js +where advanced options include: + +Advanced options are non-standard and may be changed or removed without any notice. +OK \ No newline at end of file diff --git a/compiler/testData/cli/js/jsHelp.out b/compiler/testData/cli/js/jsHelp.out index 3a8d8e3b134..5af695b917c 100644 --- a/compiler/testData/cli/js/jsHelp.out +++ b/compiler/testData/cli/js/jsHelp.out @@ -12,4 +12,5 @@ where possible options include: -version Display compiler version -help (-h) Print a synopsis of standard options -suppress warnings Suppress all compiler warnings + -X Print a synopsis of advanced options OK \ No newline at end of file diff --git a/compiler/testData/cli/jvm/extraHelp.args b/compiler/testData/cli/jvm/extraHelp.args new file mode 100644 index 00000000000..653774072c9 --- /dev/null +++ b/compiler/testData/cli/jvm/extraHelp.args @@ -0,0 +1 @@ +-X diff --git a/compiler/testData/cli/jvm/extraHelp.out b/compiler/testData/cli/jvm/extraHelp.out new file mode 100644 index 00000000000..f38fe8f7b3a --- /dev/null +++ b/compiler/testData/cli/jvm/extraHelp.out @@ -0,0 +1,9 @@ +Usage: kotlinc-jvm +where advanced options include: + -Xno-call-assertions Don't generate not-null assertion after each invocation of method returning not-null + -Xno-param-assertions Don't generate not-null assertions on parameters of methods accessible from Java + -Xno-inline Disable method inlining + -Xno-optimize Disable optimizations + +Advanced options are non-standard and may be changed or removed without any notice. +OK \ No newline at end of file diff --git a/compiler/testData/cli/jvm/help.out b/compiler/testData/cli/jvm/help.out index cd706e88ca8..3ef5ae13c10 100644 --- a/compiler/testData/cli/jvm/help.out +++ b/compiler/testData/cli/jvm/help.out @@ -7,16 +7,13 @@ where possible options include: -noJdk Don't include Java runtime into classpath -noStdlib Don't include Kotlin runtime into classpath -noJdkAnnotations Don't include JDK external annotations into classpath - -notNullAssertions Generate not-null assertion after each invocation of method returning not-null - -notNullParamAssertions Generate not-null assertions on parameters of methods accessible from Java -module Path to the module file to compile -script Evaluate the script file -kotlinHome Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery - -inline {on,off} Inlining mode (default is on) - -optimize {on,off} Optimization mode (default is on) -tags Demarcate each compilation message (error, warning, etc) with an open and close tag -verbose Enable verbose logging output -version Display compiler version -help (-h) Print a synopsis of standard options -suppress warnings Suppress all compiler warnings + -X Print a synopsis of advanced options OK \ No newline at end of file diff --git a/compiler/testData/cli/jvm/inline/off.args b/compiler/testData/cli/jvm/inline/off.args deleted file mode 100644 index e903efa52a7..00000000000 --- a/compiler/testData/cli/jvm/inline/off.args +++ /dev/null @@ -1,3 +0,0 @@ --inline -off --help diff --git a/compiler/testData/cli/jvm/inline/off.out b/compiler/testData/cli/jvm/inline/off.out deleted file mode 100644 index cd706e88ca8..00000000000 --- a/compiler/testData/cli/jvm/inline/off.out +++ /dev/null @@ -1,22 +0,0 @@ -Usage: kotlinc-jvm -where possible options include: - -d Destination for generated class files - -classpath Paths where to find user class files - -annotations Paths to external annotations - -includeRuntime Include Kotlin runtime in to resulting .jar - -noJdk Don't include Java runtime into classpath - -noStdlib Don't include Kotlin runtime into classpath - -noJdkAnnotations Don't include JDK external annotations into classpath - -notNullAssertions Generate not-null assertion after each invocation of method returning not-null - -notNullParamAssertions Generate not-null assertions on parameters of methods accessible from Java - -module Path to the module file to compile - -script Evaluate the script file - -kotlinHome Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery - -inline {on,off} Inlining mode (default is on) - -optimize {on,off} Optimization mode (default is on) - -tags Demarcate each compilation message (error, warning, etc) with an open and close tag - -verbose Enable verbose logging output - -version Display compiler version - -help (-h) Print a synopsis of standard options - -suppress warnings Suppress all compiler warnings -OK \ No newline at end of file diff --git a/compiler/testData/cli/jvm/inline/on.args b/compiler/testData/cli/jvm/inline/on.args deleted file mode 100644 index e9f8ee4a108..00000000000 --- a/compiler/testData/cli/jvm/inline/on.args +++ /dev/null @@ -1,3 +0,0 @@ --inline -on --help diff --git a/compiler/testData/cli/jvm/inline/on.out b/compiler/testData/cli/jvm/inline/on.out deleted file mode 100644 index cd706e88ca8..00000000000 --- a/compiler/testData/cli/jvm/inline/on.out +++ /dev/null @@ -1,22 +0,0 @@ -Usage: kotlinc-jvm -where possible options include: - -d Destination for generated class files - -classpath Paths where to find user class files - -annotations Paths to external annotations - -includeRuntime Include Kotlin runtime in to resulting .jar - -noJdk Don't include Java runtime into classpath - -noStdlib Don't include Kotlin runtime into classpath - -noJdkAnnotations Don't include JDK external annotations into classpath - -notNullAssertions Generate not-null assertion after each invocation of method returning not-null - -notNullParamAssertions Generate not-null assertions on parameters of methods accessible from Java - -module Path to the module file to compile - -script Evaluate the script file - -kotlinHome Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery - -inline {on,off} Inlining mode (default is on) - -optimize {on,off} Optimization mode (default is on) - -tags Demarcate each compilation message (error, warning, etc) with an open and close tag - -verbose Enable verbose logging output - -version Display compiler version - -help (-h) Print a synopsis of standard options - -suppress warnings Suppress all compiler warnings -OK \ No newline at end of file diff --git a/compiler/testData/cli/jvm/inline/wrong.args b/compiler/testData/cli/jvm/inline/wrong.args deleted file mode 100644 index 5b16e6872f1..00000000000 --- a/compiler/testData/cli/jvm/inline/wrong.args +++ /dev/null @@ -1,2 +0,0 @@ --inline -wrong diff --git a/compiler/testData/cli/jvm/inline/wrong.out b/compiler/testData/cli/jvm/inline/wrong.out deleted file mode 100644 index ea2e1515c81..00000000000 --- a/compiler/testData/cli/jvm/inline/wrong.out +++ /dev/null @@ -1,23 +0,0 @@ -Wrong value for inline option: 'wrong'. Should be 'on'/'off' or 'true'/'false' -Usage: kotlinc-jvm -where possible options include: - -d Destination for generated class files - -classpath Paths where to find user class files - -annotations Paths to external annotations - -includeRuntime Include Kotlin runtime in to resulting .jar - -noJdk Don't include Java runtime into classpath - -noStdlib Don't include Kotlin runtime into classpath - -noJdkAnnotations Don't include JDK external annotations into classpath - -notNullAssertions Generate not-null assertion after each invocation of method returning not-null - -notNullParamAssertions Generate not-null assertions on parameters of methods accessible from Java - -module Path to the module file to compile - -script Evaluate the script file - -kotlinHome Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery - -inline {on,off} Inlining mode (default is on) - -optimize {on,off} Optimization mode (default is on) - -tags Demarcate each compilation message (error, warning, etc) with an open and close tag - -verbose Enable verbose logging output - -version Display compiler version - -help (-h) Print a synopsis of standard options - -suppress warnings Suppress all compiler warnings -INTERNAL_ERROR \ No newline at end of file diff --git a/compiler/testData/cli/jvm/wrongArgument.out b/compiler/testData/cli/jvm/wrongArgument.out index 059eba87542..dc538750f39 100644 --- a/compiler/testData/cli/jvm/wrongArgument.out +++ b/compiler/testData/cli/jvm/wrongArgument.out @@ -8,16 +8,13 @@ where possible options include: -noJdk Don't include Java runtime into classpath -noStdlib Don't include Kotlin runtime into classpath -noJdkAnnotations Don't include JDK external annotations into classpath - -notNullAssertions Generate not-null assertion after each invocation of method returning not-null - -notNullParamAssertions Generate not-null assertions on parameters of methods accessible from Java -module Path to the module file to compile -script Evaluate the script file -kotlinHome Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery - -inline {on,off} Inlining mode (default is on) - -optimize {on,off} Optimization mode (default is on) -tags Demarcate each compilation message (error, warning, etc) with an open and close tag -verbose Enable verbose logging output -version Display compiler version -help (-h) Print a synopsis of standard options -suppress warnings Suppress all compiler warnings + -X Print a synopsis of advanced options INTERNAL_ERROR \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/cli/KotlincExecutableTestGenerated.java b/compiler/tests/org/jetbrains/jet/cli/KotlincExecutableTestGenerated.java index 937f6a0ed59..e0708dafba3 100644 --- a/compiler/tests/org/jetbrains/jet/cli/KotlincExecutableTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/cli/KotlincExecutableTestGenerated.java @@ -33,7 +33,7 @@ import org.jetbrains.jet.cli.AbstractKotlincExecutableTest; @InnerTestClasses({KotlincExecutableTestGenerated.Jvm.class, KotlincExecutableTestGenerated.Js.class}) public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTest { @TestMetadata("compiler/testData/cli/jvm") - @InnerTestClasses({Jvm.Inline.class, Jvm.WrongAbiVersionLib.class}) + @InnerTestClasses({Jvm.WrongAbiVersionLib.class}) public static class Jvm extends AbstractKotlincExecutableTest { public void testAllFilesPresentInJvm() throws Exception { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/cli/jvm"), Pattern.compile("^(.+)\\.args$"), true); @@ -54,6 +54,11 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes doJvmTest("compiler/testData/cli/jvm/diagnosticsOrder.args"); } + @TestMetadata("extraHelp.args") + public void testExtraHelp() throws Exception { + doJvmTest("compiler/testData/cli/jvm/extraHelp.args"); + } + @TestMetadata("help.args") public void testHelp() throws Exception { doJvmTest("compiler/testData/cli/jvm/help.args"); @@ -109,29 +114,6 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes doJvmTest("compiler/testData/cli/jvm/wrongKotlinSignature.args"); } - @TestMetadata("compiler/testData/cli/jvm/inline") - public static class Inline extends AbstractKotlincExecutableTest { - public void testAllFilesPresentInInline() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/cli/jvm/inline"), Pattern.compile("^(.+)\\.args$"), true); - } - - @TestMetadata("off.args") - public void testOff() throws Exception { - doJvmTest("compiler/testData/cli/jvm/inline/off.args"); - } - - @TestMetadata("on.args") - public void testOn() throws Exception { - doJvmTest("compiler/testData/cli/jvm/inline/on.args"); - } - - @TestMetadata("wrong.args") - public void testWrong() throws Exception { - doJvmTest("compiler/testData/cli/jvm/inline/wrong.args"); - } - - } - @TestMetadata("compiler/testData/cli/jvm/wrongAbiVersionLib") @InnerTestClasses({}) public static class WrongAbiVersionLib extends AbstractKotlincExecutableTest { @@ -149,7 +131,6 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes public static Test innerSuite() { TestSuite suite = new TestSuite("Jvm"); suite.addTestSuite(Jvm.class); - suite.addTestSuite(Inline.class); suite.addTest(WrongAbiVersionLib.innerSuite()); return suite; } @@ -161,6 +142,11 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/cli/js"), Pattern.compile("^(.+)\\.args$"), true); } + @TestMetadata("jsExtraHelp.args") + public void testJsExtraHelp() throws Exception { + doJsTest("compiler/testData/cli/js/jsExtraHelp.args"); + } + @TestMetadata("jsHelp.args") public void testJsHelp() throws Exception { doJsTest("compiler/testData/cli/js/jsHelp.args"); diff --git a/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/KotlinCompilerRunner.java b/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/KotlinCompilerRunner.java index 3d9cadb9635..aaffb8bf770 100644 --- a/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/KotlinCompilerRunner.java +++ b/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/KotlinCompilerRunner.java @@ -142,8 +142,6 @@ public class KotlinCompilerRunner { setupCommonSettings(settings); settings.module = moduleFile.getAbsolutePath(); - settings.notNullAssertions = true; - settings.notNullParamAssertions = true; settings.noStdlib = true; settings.noJdkAnnotations = true; settings.noJdk = true; diff --git a/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/KDocCompiler.kt b/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/KDocCompiler.kt index a29b8d52893..f03c61f11e2 100644 --- a/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/KDocCompiler.kt +++ b/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/KDocCompiler.kt @@ -33,7 +33,7 @@ class KDocCompiler() : K2JVMCompiler() { return KDocArguments() } - protected override fun usage(target : PrintStream) { + protected override fun usage(target: PrintStream, extraHelp: Boolean) { target.println("Usage: KDocCompiler -docOutput -d [|] [-stdlib ] [|-module ] [-includeRuntime]"); } } diff --git a/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt b/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt index 994d1279493..c0f733b4ffb 100644 --- a/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt +++ b/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt @@ -28,7 +28,6 @@ import org.jetbrains.kotlin.gradle.plugin.* import org.jetbrains.kotlin.doc.KDocConfig import java.util.concurrent.Callable import org.gradle.api.Project -import org.jetbrains.jet.cli.common.arguments.CompilerArgumentsUtil public open class KotlinCompile(): AbstractCompile() { @@ -116,16 +115,10 @@ public open class KotlinCompile(): AbstractCompile() { args.noStdlib = true args.noJdkAnnotations = true - args.inline = kotlinOptions.inline - args.optimize = kotlinOptions.optimize - - if (!CompilerArgumentsUtil.checkOption(args.inline)) { - throw GradleException(CompilerArgumentsUtil.getWrongCheckOptionErrorMessage("inline", args.inline)) - } - - if (!CompilerArgumentsUtil.checkOption(args.optimize)) { - throw GradleException(CompilerArgumentsUtil.getWrongCheckOptionErrorMessage("optimize", args.optimize)) - } + args.noInline = kotlinOptions.noInline + args.noOptimize = kotlinOptions.noOptimize + args.noCallAssertions = kotlinOptions.noCallAssertions + args.noParamAssertions = kotlinOptions.noParamAssertions val messageCollector = GradleMessageCollector(getLogger()) getLogger().debug("Calling compiler") diff --git a/libraries/tools/kotlin-gradle-plugin-core/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin-core/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt index ecaa7178a83..45ba7eef6b0 100644 --- a/libraries/tools/kotlin-gradle-plugin-core/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-core/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt @@ -1,16 +1,6 @@ package org.jetbrains.kotlin.gradle -import com.google.common.io.Files -import com.intellij.openapi.util.SystemInfo -import java.io.File -import java.util.Arrays -import java.util.Scanner -import org.junit.Before -import org.junit.After import org.junit.Test -import kotlin.test.assertTrue -import kotlin.test.assertEquals -import kotlin.test.fail import org.junit.Ignore import org.jetbrains.kotlin.gradle.BaseGradleIT.Project @@ -37,14 +27,8 @@ class BasicKotlinGradleIT : BaseGradleIT() { } } - Test fun testInlineDisabled() { - Project("inlineDisabled", "1.6").build("build", "-Pkotlin.gradle.plugin.version=0.1-SNAPSHOT") { - assertSuccessful() - } - } - - Test fun testOptimizationDisabled() { - Project("optimizationDisabled", "1.6").build("build", "-Pkotlin.gradle.plugin.version=0.1-SNAPSHOT") { + Test fun testAdvancedOptions() { + Project("advancedOptions", "1.6").build("build", "-Pkotlin.gradle.plugin.version=0.1-SNAPSHOT") { assertSuccessful() } } diff --git a/libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/inlineDisabled/build.gradle b/libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/advancedOptions/build.gradle similarity index 82% rename from libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/inlineDisabled/build.gradle rename to libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/advancedOptions/build.gradle index 984640fd0c2..9c360515144 100644 --- a/libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/inlineDisabled/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/advancedOptions/build.gradle @@ -40,8 +40,10 @@ test { } compileKotlin { - kotlinOptions.annotations = "externalAnnotations" - kotlinOptions.inline = false + kotlinOptions.noInline = true + kotlinOptions.noOptimize = true + kotlinOptions.noCallAssertions = true + kotlinOptions.noParamAssertions = true } diff --git a/libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/inlineDisabled/src/helloWorld.kt b/libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/advancedOptions/src/helloWorld.kt similarity index 100% rename from libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/inlineDisabled/src/helloWorld.kt rename to libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/advancedOptions/src/helloWorld.kt diff --git a/libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/inlineDisabled/externalAnnotations/com/google/common/base/annotations.xml b/libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/inlineDisabled/externalAnnotations/com/google/common/base/annotations.xml deleted file mode 100644 index fd541a7e6e5..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/inlineDisabled/externalAnnotations/com/google/common/base/annotations.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/optimizationDisabled/build.gradle b/libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/optimizationDisabled/build.gradle deleted file mode 100644 index f57d96ee448..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/optimizationDisabled/build.gradle +++ /dev/null @@ -1,50 +0,0 @@ -buildscript { - repositories { - mavenCentral() - maven { - url 'file://' + pathToKotlinPlugin - } - } - dependencies { - classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin-core:0.1-SNAPSHOT' - } -} - -import org.jetbrains.kotlin.gradle.plugin.KotlinPlugin - -apply plugin: KotlinPlugin - -sourceSets { - main { - kotlin { - srcDir 'src' - } - } -} - -repositories { - maven { - url 'file://' + pathToKotlinPlugin - } - mavenCentral() -} - -dependencies { - compile 'com.google.guava:guava:12.0' - testCompile 'org.testng:testng:6.8' - testRuntime 'org.jetbrains.kotlin:kotlin-stdlib:0.1-SNAPSHOT' -} - -test { - useTestNG() -} - -compileKotlin { - kotlinOptions.annotations = "externalAnnotations" - kotlinOptions.optimize = false -} - - -task wrapper(type: Wrapper) { - gradleVersion="1.4" -} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/optimizationDisabled/externalAnnotations/com/google/common/base/annotations.xml b/libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/optimizationDisabled/externalAnnotations/com/google/common/base/annotations.xml deleted file mode 100644 index fd541a7e6e5..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/optimizationDisabled/externalAnnotations/com/google/common/base/annotations.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/optimizationDisabled/src/helloWorld.kt b/libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/optimizationDisabled/src/helloWorld.kt deleted file mode 100644 index 5bb8e316ef5..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-core/src/test/resources/testProject/optimizationDisabled/src/helloWorld.kt +++ /dev/null @@ -1,13 +0,0 @@ -package demo - -import java.util.ArrayList - -class KotlinGreetingJoiner() { - - val names = ArrayList() - - fun addName(name : String?): Unit{ - names.add(name) - } -} - diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java index 409ca251bbe..8f294bd4c07 100644 --- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java +++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java @@ -28,25 +28,19 @@ import org.jetbrains.jet.cli.common.CLICompiler; import org.jetbrains.jet.cli.common.ExitCode; import org.jetbrains.jet.cli.common.KotlinVersion; import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments; +import org.jetbrains.jet.cli.common.arguments.CompilerArgumentsUtil; import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments; import org.jetbrains.jet.cli.common.messages.CompilerMessageLocation; import org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity; import org.jetbrains.jet.cli.common.messages.MessageCollector; import org.jetbrains.jet.cli.jvm.K2JVMCompiler; -import org.jetbrains.jet.cli.common.arguments.CompilerArgumentsUtil; -import org.jetbrains.jet.codegen.inline.InlineCodegenUtil; -import org.jetbrains.jet.codegen.optimization.OptimizationUtils; import java.io.File; import java.io.IOException; import java.lang.reflect.Field; import java.net.URL; import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Enumeration; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -321,24 +315,23 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo { arguments.noJdkAnnotations = true; arguments.annotations = getFullAnnotationsPath(log, annotationPaths); log.info("Using kotlin annotations from " + arguments.annotations); - arguments.inline = inline; - arguments.optimize = optimize; + arguments.noInline = !CompilerArgumentsUtil.optionToBooleanFlag(inline, true); + arguments.noOptimize = !CompilerArgumentsUtil.optionToBooleanFlag(optimize, true); - if (!CompilerArgumentsUtil.checkOption(arguments.inline)) { - throw new MojoExecutionException(CompilerArgumentsUtil.getWrongCheckOptionErrorMessage("inline", arguments.inline)); + if (!CompilerArgumentsUtil.checkOption(inline)) { + throw new MojoExecutionException(CompilerArgumentsUtil.getWrongCheckOptionErrorMessage("inline", inline)); } - if (!CompilerArgumentsUtil.checkOption(arguments.optimize)) { - throw new MojoExecutionException(CompilerArgumentsUtil.getWrongCheckOptionErrorMessage("optimize", arguments.optimize)); + if (!CompilerArgumentsUtil.checkOption(optimize)) { + throw new MojoExecutionException(CompilerArgumentsUtil.getWrongCheckOptionErrorMessage("optimize", optimize)); } - log.info("Method inlining is " + CompilerArgumentsUtil.optionToBooleanFlag(arguments.inline, InlineCodegenUtil.DEFAULT_INLINE_FLAG)); - log.info( - "Optimization mode is " + CompilerArgumentsUtil.optionToBooleanFlag( - arguments.optimize, - OptimizationUtils.DEFAULT_OPTIMIZATION_FLAG - ) - ); + if (arguments.noInline) { + log.info("Method inlining is turned off"); + } + if (arguments.noOptimize) { + log.info("Optimization is turned off"); + } } protected String getFullAnnotationsPath(Log log, List annotations) {