CLI: Support "-X" advanced options, simplify some boolean options
This commit is contained in:
+3
@@ -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<String> freeArgs = new SmartList<String>();
|
||||
|
||||
public boolean suppressAllWarnings() {
|
||||
|
||||
+12
-12
@@ -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("<path>")
|
||||
public String module;
|
||||
@@ -65,13 +59,19 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments {
|
||||
@ValueDescription("<path>")
|
||||
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
|
||||
|
||||
@@ -61,12 +61,11 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
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<A extends CommonCompilerArguments> {
|
||||
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<A extends CommonCompilerArguments> {
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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() + " <options> <source files>");
|
||||
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);
|
||||
|
||||
@@ -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<K2JVMCompilerArguments> {
|
||||
? CommandLineScriptUtils.scriptParameters()
|
||||
: Collections.<AnalyzerScriptParameter>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<K2JVMCompilerArguments> {
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
-X
|
||||
@@ -0,0 +1,5 @@
|
||||
Usage: kotlinc-js <options> <source files>
|
||||
where advanced options include:
|
||||
|
||||
Advanced options are non-standard and may be changed or removed without any notice.
|
||||
OK
|
||||
@@ -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
|
||||
@@ -0,0 +1 @@
|
||||
-X
|
||||
@@ -0,0 +1,9 @@
|
||||
Usage: kotlinc-jvm <options> <source files>
|
||||
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
|
||||
@@ -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> Path to the module file to compile
|
||||
-script Evaluate the script file
|
||||
-kotlinHome <path> 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
|
||||
@@ -1,3 +0,0 @@
|
||||
-inline
|
||||
off
|
||||
-help
|
||||
@@ -1,22 +0,0 @@
|
||||
Usage: kotlinc-jvm <options> <source files>
|
||||
where possible options include:
|
||||
-d <directory|jar> Destination for generated class files
|
||||
-classpath <path> Paths where to find user class files
|
||||
-annotations <path> 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> Path to the module file to compile
|
||||
-script Evaluate the script file
|
||||
-kotlinHome <path> 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
|
||||
@@ -1,3 +0,0 @@
|
||||
-inline
|
||||
on
|
||||
-help
|
||||
@@ -1,22 +0,0 @@
|
||||
Usage: kotlinc-jvm <options> <source files>
|
||||
where possible options include:
|
||||
-d <directory|jar> Destination for generated class files
|
||||
-classpath <path> Paths where to find user class files
|
||||
-annotations <path> 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> Path to the module file to compile
|
||||
-script Evaluate the script file
|
||||
-kotlinHome <path> 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
|
||||
@@ -1,2 +0,0 @@
|
||||
-inline
|
||||
wrong
|
||||
@@ -1,23 +0,0 @@
|
||||
Wrong value for inline option: 'wrong'. Should be 'on'/'off' or 'true'/'false'
|
||||
Usage: kotlinc-jvm <options> <source files>
|
||||
where possible options include:
|
||||
-d <directory|jar> Destination for generated class files
|
||||
-classpath <path> Paths where to find user class files
|
||||
-annotations <path> 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> Path to the module file to compile
|
||||
-script Evaluate the script file
|
||||
-kotlinHome <path> 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
|
||||
@@ -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> Path to the module file to compile
|
||||
-script Evaluate the script file
|
||||
-kotlinHome <path> 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
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 <docOutputDir> -d [<outputDir>|<jarFileName>] [-stdlib <path to runtime.jar>] [<filename or dirname>|-module <module file>] [-includeRuntime]");
|
||||
}
|
||||
}
|
||||
|
||||
+4
-11
@@ -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")
|
||||
|
||||
+2
-18
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -40,8 +40,10 @@ test {
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.annotations = "externalAnnotations"
|
||||
kotlinOptions.inline = false
|
||||
kotlinOptions.noInline = true
|
||||
kotlinOptions.noOptimize = true
|
||||
kotlinOptions.noCallAssertions = true
|
||||
kotlinOptions.noParamAssertions = true
|
||||
}
|
||||
|
||||
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
<root>
|
||||
<item name='com.google.common.base.Joiner com.google.common.base.Joiner on(java.lang.String)'>
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name='com.google.common.base.Joiner com.google.common.base.Joiner.MapJoiner withKeyValueSeparator(java.lang.String)'>
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name='com.google.common.base.Joiner com.google.common.base.Joiner skipNulls()'>
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
</root>
|
||||
-50
@@ -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"
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
<root>
|
||||
<item name='com.google.common.base.Joiner com.google.common.base.Joiner on(java.lang.String)'>
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name='com.google.common.base.Joiner com.google.common.base.Joiner.MapJoiner withKeyValueSeparator(java.lang.String)'>
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name='com.google.common.base.Joiner com.google.common.base.Joiner skipNulls()'>
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
</root>
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
package demo
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
class KotlinGreetingJoiner() {
|
||||
|
||||
val names = ArrayList<String?>()
|
||||
|
||||
fun addName(name : String?): Unit{
|
||||
names.add(name)
|
||||
}
|
||||
}
|
||||
|
||||
+14
-21
@@ -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<String> annotations) {
|
||||
|
||||
Reference in New Issue
Block a user