From de0fd3818cd61f340653cdb07f9edb0a3189cf7f Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 22 Jul 2014 17:50:41 +0400 Subject: [PATCH] Drop "-src" in kotlinc-jvm Free arguments should be used instead --- build.xml | 5 ++--- .../arguments/K2JVMCompilerArguments.java | 4 ---- .../jetbrains/jet/cli/jvm/K2JVMCompiler.java | 16 +++------------- .../jetbrains/kotlin/CompilerSmokeTest.java | 4 ++-- compiler/testData/cli/jvm/classpath.args | 3 +-- .../cli/jvm/conflictingOverloads.args | 3 +-- .../testData/cli/jvm/diagnosticsOrder.args | 6 +++--- compiler/testData/cli/jvm/help.out | 1 - compiler/testData/cli/jvm/inline/off.out | 1 - compiler/testData/cli/jvm/inline/on.out | 1 - compiler/testData/cli/jvm/inline/wrong.out | 1 - .../multipleTextRangesInDiagnosticsOrder.args | 3 +-- ...onExistingClassPathAndAnnotationsPath.args | 3 +-- .../cli/jvm/nonExistingSourcePath.args | 3 +-- compiler/testData/cli/jvm/signatureClash.args | 3 +-- compiler/testData/cli/jvm/simple.args | 3 +-- .../cli/jvm/suppressAllWarningsLowercase.args | 3 +-- .../cli/jvm/suppressAllWarningsMixedCase.args | 3 +-- .../testData/cli/jvm/wrongAbiVersion.args | 3 +-- compiler/testData/cli/jvm/wrongArgument.out | 1 - .../cli/jvm/wrongKotlinSignature.args | 3 +-- .../org/jetbrains/jet/MockLibraryUtil.java | 7 ++++--- .../forTestCompile/ForTestCompileRuntime.java | 19 +++++++++++-------- .../jvm/compiler/CompileEnvironmentTest.java | 17 ++++++++++------- .../org/jetbrains/kotlin/doc/KDocCompiler.kt | 2 +- 25 files changed, 47 insertions(+), 71 deletions(-) diff --git a/build.xml b/build.xml index 9cdfd9a0ed7..b72093b7739 100644 --- a/build.xml +++ b/build.xml @@ -566,8 +566,7 @@ - - + @@ -577,7 +576,7 @@ - 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 5e781af25d9..05129b028e8 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 @@ -24,10 +24,6 @@ import org.jetbrains.annotations.NotNull; */ @SuppressWarnings("UnusedDeclaration") public class K2JVMCompilerArguments extends CommonCompilerArguments { - @Argument(value = "src", description = "Source file or directory (allows many paths separated by the system path separator)") - @ValueDescription("") - public String src; - @Argument(value = "jar", description = "Resulting .jar file path") @ValueDescription("") public String jar; 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 65a0695ef4e..709c20898e9 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java @@ -19,7 +19,6 @@ package org.jetbrains.jet.cli.jvm; import com.google.common.base.Splitter; import com.google.common.collect.Lists; import com.intellij.openapi.Disposable; -import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.cli.common.CLICompiler; import org.jetbrains.jet.cli.common.CLIConfigurationKeys; @@ -44,7 +43,6 @@ import org.jetbrains.jet.utils.KotlinPathsFromHomeDir; import org.jetbrains.jet.utils.PathUtil; import java.io.File; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -86,7 +84,6 @@ public class K2JVMCompiler extends CLICompiler { if (!arguments.script && arguments.module == null && - arguments.src == null && arguments.freeArgs.isEmpty() && !arguments.version ) { @@ -99,19 +96,12 @@ public class K2JVMCompiler extends CLICompiler { configuration.add(CommonConfigurationKeys.SOURCE_ROOTS_KEY, arguments.freeArgs.get(0)); } else { - if (arguments.src != null) { - List sourcePathsSplitByPathSeparator - = Arrays.asList(arguments.src.split(StringUtil.escapeToRegexp(File.pathSeparator))); - configuration.addAll(CommonConfigurationKeys.SOURCE_ROOTS_KEY, sourcePathsSplitByPathSeparator); - } - for (String freeArg : arguments.freeArgs) { - configuration.add(CommonConfigurationKeys.SOURCE_ROOTS_KEY, freeArg); - } + configuration.addAll(CommonConfigurationKeys.SOURCE_ROOTS_KEY, arguments.freeArgs); } configuration.put(JVMConfigurationKeys.SCRIPT_PARAMETERS, arguments.script - ? CommandLineScriptUtils.scriptParameters() - : Collections.emptyList()); + ? CommandLineScriptUtils.scriptParameters() + : Collections.emptyList()); configuration.put(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, arguments.notNullAssertions); configuration.put(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, arguments.notNullParamAssertions); diff --git a/compiler/integration-tests/src/org/jetbrains/kotlin/CompilerSmokeTest.java b/compiler/integration-tests/src/org/jetbrains/kotlin/CompilerSmokeTest.java index 52f039ec650..519c2994d6b 100644 --- a/compiler/integration-tests/src/org/jetbrains/kotlin/CompilerSmokeTest.java +++ b/compiler/integration-tests/src/org/jetbrains/kotlin/CompilerSmokeTest.java @@ -59,14 +59,14 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase { public void compilationFailed() throws Exception { String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "smoke.jar"; - runCompiler("hello.compile", "-src", "hello.kt", "-jar", jar); + runCompiler("hello.compile", "hello.kt", "-jar", jar); } @Test public void syntaxErrors() throws Exception { String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "smoke.jar"; - runCompiler("test.compile", "-src", "test.kt", "-jar", jar); + runCompiler("test.compile", "test.kt", "-jar", jar); } @Test diff --git a/compiler/testData/cli/jvm/classpath.args b/compiler/testData/cli/jvm/classpath.args index c63be1c520d..76f5eeb4053 100644 --- a/compiler/testData/cli/jvm/classpath.args +++ b/compiler/testData/cli/jvm/classpath.args @@ -1,4 +1,3 @@ --src $TESTDATA_DIR$/classpath.kt -output -$TEMP_DIR$ \ No newline at end of file +$TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/conflictingOverloads.args b/compiler/testData/cli/jvm/conflictingOverloads.args index aab851ab01f..7e9dfcea5a3 100644 --- a/compiler/testData/cli/jvm/conflictingOverloads.args +++ b/compiler/testData/cli/jvm/conflictingOverloads.args @@ -1,4 +1,3 @@ --src $TESTDATA_DIR$/conflictingOverloads.kt -output -$TEMP_DIR$ \ No newline at end of file +$TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/diagnosticsOrder.args b/compiler/testData/cli/jvm/diagnosticsOrder.args index 160c5ba6928..539695486ca 100644 --- a/compiler/testData/cli/jvm/diagnosticsOrder.args +++ b/compiler/testData/cli/jvm/diagnosticsOrder.args @@ -1,4 +1,4 @@ --src -$TESTDATA_DIR$/diagnosticsOrder1.kt:$TESTDATA_DIR$/diagnosticsOrder2.kt +$TESTDATA_DIR$/diagnosticsOrder1.kt +$TESTDATA_DIR$/diagnosticsOrder2.kt -output -$TEMP_DIR$ \ No newline at end of file +$TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/help.out b/compiler/testData/cli/jvm/help.out index 15e4e57c349..07b188b8a5e 100644 --- a/compiler/testData/cli/jvm/help.out +++ b/compiler/testData/cli/jvm/help.out @@ -1,6 +1,5 @@ Usage: kotlinc-jvm where possible options include: - -src Source file or directory (allows many paths separated by the system path separator) -jar Resulting .jar file path -output Output directory path for .class files -classpath Paths where to find user class files diff --git a/compiler/testData/cli/jvm/inline/off.out b/compiler/testData/cli/jvm/inline/off.out index 15e4e57c349..07b188b8a5e 100644 --- a/compiler/testData/cli/jvm/inline/off.out +++ b/compiler/testData/cli/jvm/inline/off.out @@ -1,6 +1,5 @@ Usage: kotlinc-jvm where possible options include: - -src Source file or directory (allows many paths separated by the system path separator) -jar Resulting .jar file path -output Output directory path for .class files -classpath Paths where to find user class files diff --git a/compiler/testData/cli/jvm/inline/on.out b/compiler/testData/cli/jvm/inline/on.out index 15e4e57c349..07b188b8a5e 100644 --- a/compiler/testData/cli/jvm/inline/on.out +++ b/compiler/testData/cli/jvm/inline/on.out @@ -1,6 +1,5 @@ Usage: kotlinc-jvm where possible options include: - -src Source file or directory (allows many paths separated by the system path separator) -jar Resulting .jar file path -output Output directory path for .class files -classpath Paths where to find user class files diff --git a/compiler/testData/cli/jvm/inline/wrong.out b/compiler/testData/cli/jvm/inline/wrong.out index 5ea4db25645..86951a49e25 100644 --- a/compiler/testData/cli/jvm/inline/wrong.out +++ b/compiler/testData/cli/jvm/inline/wrong.out @@ -1,7 +1,6 @@ Wrong value for inline option: 'wrong'. Should be 'on'/'off' or 'true'/'false' Usage: kotlinc-jvm where possible options include: - -src Source file or directory (allows many paths separated by the system path separator) -jar Resulting .jar file path -output Output directory path for .class files -classpath Paths where to find user class files diff --git a/compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.args b/compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.args index 12915cba3b6..0e82a6f807c 100644 --- a/compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.args +++ b/compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.args @@ -1,4 +1,3 @@ --src $TESTDATA_DIR$/multipleTextRangesInDiagnosticsOrder.kt -output -$TEMP_DIR$ \ No newline at end of file +$TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/nonExistingClassPathAndAnnotationsPath.args b/compiler/testData/cli/jvm/nonExistingClassPathAndAnnotationsPath.args index a99bf8c0359..327c77342f4 100644 --- a/compiler/testData/cli/jvm/nonExistingClassPathAndAnnotationsPath.args +++ b/compiler/testData/cli/jvm/nonExistingClassPathAndAnnotationsPath.args @@ -1,8 +1,7 @@ --src $TESTDATA_DIR$/simple.kt -classpath not/existing/path -annotations yet/another/not/existing/path -output -$TEMP_DIR$ \ No newline at end of file +$TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/nonExistingSourcePath.args b/compiler/testData/cli/jvm/nonExistingSourcePath.args index 79d1e80bd75..22686fad711 100644 --- a/compiler/testData/cli/jvm/nonExistingSourcePath.args +++ b/compiler/testData/cli/jvm/nonExistingSourcePath.args @@ -1,4 +1,3 @@ --src not/existing/path -output -$TEMP_DIR$ \ No newline at end of file +$TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/signatureClash.args b/compiler/testData/cli/jvm/signatureClash.args index e1c67753c89..aff3e8edf91 100644 --- a/compiler/testData/cli/jvm/signatureClash.args +++ b/compiler/testData/cli/jvm/signatureClash.args @@ -1,4 +1,3 @@ --src $TESTDATA_DIR$/signatureClash.kt -output -$TEMP_DIR$ \ No newline at end of file +$TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/simple.args b/compiler/testData/cli/jvm/simple.args index 99d41888d68..dcd428eee26 100644 --- a/compiler/testData/cli/jvm/simple.args +++ b/compiler/testData/cli/jvm/simple.args @@ -1,4 +1,3 @@ --src $TESTDATA_DIR$/simple.kt -output -$TEMP_DIR$ \ No newline at end of file +$TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/suppressAllWarningsLowercase.args b/compiler/testData/cli/jvm/suppressAllWarningsLowercase.args index 3f9f9353aff..4939309f3d7 100644 --- a/compiler/testData/cli/jvm/suppressAllWarningsLowercase.args +++ b/compiler/testData/cli/jvm/suppressAllWarningsLowercase.args @@ -1,6 +1,5 @@ --src $TESTDATA_DIR$/../warnings.kt -suppress warnings -output -$TEMP_DIR$ \ No newline at end of file +$TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/suppressAllWarningsMixedCase.args b/compiler/testData/cli/jvm/suppressAllWarningsMixedCase.args index 072c0c29cf5..da78a29e104 100644 --- a/compiler/testData/cli/jvm/suppressAllWarningsMixedCase.args +++ b/compiler/testData/cli/jvm/suppressAllWarningsMixedCase.args @@ -1,6 +1,5 @@ --src $TESTDATA_DIR$/../warnings.kt -suppress WaRnInGs -output -$TEMP_DIR$ \ No newline at end of file +$TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/wrongAbiVersion.args b/compiler/testData/cli/jvm/wrongAbiVersion.args index 8a843010987..c6220651a44 100644 --- a/compiler/testData/cli/jvm/wrongAbiVersion.args +++ b/compiler/testData/cli/jvm/wrongAbiVersion.args @@ -1,6 +1,5 @@ --src $TESTDATA_DIR$/wrongAbiVersion.kt -classpath $TESTDATA_DIR$/wrongAbiVersionLib -output -$TEMP_DIR$ \ No newline at end of file +$TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/wrongArgument.out b/compiler/testData/cli/jvm/wrongArgument.out index ab56530c4ce..abd6e5c9793 100644 --- a/compiler/testData/cli/jvm/wrongArgument.out +++ b/compiler/testData/cli/jvm/wrongArgument.out @@ -1,7 +1,6 @@ Invalid argument: -wrongArgument Usage: kotlinc-jvm where possible options include: - -src Source file or directory (allows many paths separated by the system path separator) -jar Resulting .jar file path -output Output directory path for .class files -classpath Paths where to find user class files diff --git a/compiler/testData/cli/jvm/wrongKotlinSignature.args b/compiler/testData/cli/jvm/wrongKotlinSignature.args index 152602e4770..e9d7639ff43 100644 --- a/compiler/testData/cli/jvm/wrongKotlinSignature.args +++ b/compiler/testData/cli/jvm/wrongKotlinSignature.args @@ -1,6 +1,5 @@ --src $TESTDATA_DIR$/wrongKotlinSignature.kt -classpath $TESTDATA_DIR$/wrongKotlinSignatureLib -output -$TEMP_DIR$ \ No newline at end of file +$TEMP_DIR$ diff --git a/compiler/tests/org/jetbrains/jet/MockLibraryUtil.java b/compiler/tests/org/jetbrains/jet/MockLibraryUtil.java index 17ef44cad13..1df01ad5bea 100644 --- a/compiler/tests/org/jetbrains/jet/MockLibraryUtil.java +++ b/compiler/tests/org/jetbrains/jet/MockLibraryUtil.java @@ -96,9 +96,10 @@ public class MockLibraryUtil { Method execMethod = compilerClass.getMethod("exec", PrintStream.class, String[].class); //noinspection IOResourceOpenedButNotSafelyClosed - Enum invocationResult = (Enum) execMethod - .invoke(compilerObject, new PrintStream(outStream), - new String[] {"-src", sourcesPath, "-output", outDir.getAbsolutePath(), "-classpath", sourcesPath}); + Enum invocationResult = (Enum) execMethod.invoke( + compilerObject, new PrintStream(outStream), + new String[] {sourcesPath, "-output", outDir.getAbsolutePath(), "-classpath", sourcesPath} + ); assertEquals(new String(outStream.toByteArray()), ExitCode.OK.name(), invocationResult.name()); } diff --git a/compiler/tests/org/jetbrains/jet/codegen/forTestCompile/ForTestCompileRuntime.java b/compiler/tests/org/jetbrains/jet/codegen/forTestCompile/ForTestCompileRuntime.java index 95648907a82..84a44315ffc 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/forTestCompile/ForTestCompileRuntime.java +++ b/compiler/tests/org/jetbrains/jet/codegen/forTestCompile/ForTestCompileRuntime.java @@ -17,6 +17,8 @@ package org.jetbrains.jet.codegen.forTestCompile; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.util.ArrayUtil; +import kotlin.KotlinPackage; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.JetTestUtils; import org.jetbrains.jet.cli.common.ExitCode; @@ -57,8 +59,9 @@ public class ForTestCompileRuntime { } private static void compileBuiltIns(@NotNull File destDir) throws IOException { - String src = BUILT_INS_SRC_PATH + File.pathSeparator + RUNTIME_JVM_SRC_PATH + File.pathSeparator + REFLECTION_SRC_PATH; - compileKotlinToJvm("built-ins", destDir, src, src); + compileKotlinToJvm("built-ins", destDir, + BUILT_INS_SRC_PATH + File.pathSeparator + RUNTIME_JVM_SRC_PATH + File.pathSeparator + REFLECTION_SRC_PATH, + BUILT_INS_SRC_PATH, RUNTIME_JVM_SRC_PATH, REFLECTION_SRC_PATH); JetTestUtils.compileJavaFiles( javaFilesUnder(RUNTIME_JVM_SRC_PATH), @@ -75,25 +78,25 @@ public class ForTestCompileRuntime { } private static void compileStdlib(@NotNull File destDir) throws IOException { - compileKotlinToJvm("stdlib", destDir, "libraries/stdlib/src", destDir.getPath()); + compileKotlinToJvm("stdlib", destDir, destDir.getPath(), "libraries/stdlib/src"); } private static void compileKotlinToJvm( @NotNull String debugName, @NotNull File destDir, - @NotNull String src, - @NotNull String classPath + @NotNull String classPath, + @NotNull String... src ) { - ExitCode exitCode = new K2JVMCompiler().exec( - System.out, + List args = KotlinPackage.arrayListOf( "-output", destDir.getPath(), - "-src", src, "-noStdlib", "-noJdkAnnotations", "-suppress", "warnings", "-annotations", JetTestUtils.getJdkAnnotationsJar().getAbsolutePath(), "-classpath", classPath ); + args.addAll(Arrays.asList(src)); + ExitCode exitCode = new K2JVMCompiler().exec(System.out, ArrayUtil.toStringArray(args)); if (exitCode != ExitCode.OK) { throw new IllegalStateException("Compilation of " + debugName + " failed: " + exitCode); } diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileEnvironmentTest.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileEnvironmentTest.java index c27085db452..37614329756 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileEnvironmentTest.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileEnvironmentTest.java @@ -79,13 +79,16 @@ public class CompileEnvironmentTest extends TestCase { File out = new File(tempDir, "out"); File stdlib = ForTestCompileRuntime.runtimeJarForTests(); File jdkAnnotations = JetTestUtils.getJdkAnnotationsJar(); - ExitCode exitCode = new K2JVMCompiler() - .exec(System.out, "-src", JetTestCaseBuilder.getTestDataPathBase() + "/compiler/smoke/Smoke.kt", - "-output", out.getAbsolutePath(), - "-noStdlib", - "-classpath", stdlib.getAbsolutePath(), - "-noJdkAnnotations", - "-annotations", jdkAnnotations.getAbsolutePath()); + ExitCode exitCode = new K2JVMCompiler().exec( + System.out, + JetTestCaseBuilder.getTestDataPathBase() + + "/compiler/smoke/Smoke.kt", + "-output", out.getAbsolutePath(), + "-noStdlib", + "-classpath", stdlib.getAbsolutePath(), + "-noJdkAnnotations", + "-annotations", jdkAnnotations.getAbsolutePath() + ); Assert.assertEquals(ExitCode.OK, exitCode); assertEquals(1, out.listFiles().length); assertEquals(2, out.listFiles()[0].listFiles().length); 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 a5dd677014d..ec4148c4472 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 @@ -34,7 +34,7 @@ class KDocCompiler() : K2JVMCompiler() { } protected override fun usage(target : PrintStream) { - target.println("Usage: KDocCompiler -docOutput [-output |-jar ] [-stdlib ] [-src |-module ] [-includeRuntime]"); + target.println("Usage: KDocCompiler -docOutput [-output |-jar ] [-stdlib ] [|-module ] [-includeRuntime]"); } }