Drop "-src" in kotlinc-jvm

Free arguments should be used instead
This commit is contained in:
Alexander Udalov
2014-07-22 17:50:41 +04:00
parent 917938e57b
commit de0fd3818c
25 changed files with 47 additions and 71 deletions
+2 -3
View File
@@ -566,8 +566,7 @@
<assertions>
<enable/>
</assertions>
<arg value="-src"/>
<arg value="@{src}"/>
<arg line="@{src}"/>
<arg value="-output"/>
<arg value="@{output}"/>
<arg value="-noStdlib"/>
@@ -577,7 +576,7 @@
</sequential>
</macrodef>
<new_kotlinc src="${basedir}/core/builtins/src${path.separator}${basedir}/core/runtime.jvm/src${path.separator}${basedir}/core/reflection/src"
<new_kotlinc src="${basedir}/core/builtins/src ${basedir}/core/runtime.jvm/src ${basedir}/core/reflection/src"
output="${output}/classes/runtime"
classpath="${basedir}/core/runtime.jvm/src"/>
@@ -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("<path>")
public String src;
@Argument(value = "jar", description = "Resulting .jar file path")
@ValueDescription("<path>")
public String jar;
@@ -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<K2JVMCompilerArguments> {
if (!arguments.script &&
arguments.module == null &&
arguments.src == null &&
arguments.freeArgs.isEmpty() &&
!arguments.version
) {
@@ -99,19 +96,12 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
configuration.add(CommonConfigurationKeys.SOURCE_ROOTS_KEY, arguments.freeArgs.get(0));
}
else {
if (arguments.src != null) {
List<String> 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.<AnalyzerScriptParameter>emptyList());
? CommandLineScriptUtils.scriptParameters()
: Collections.<AnalyzerScriptParameter>emptyList());
configuration.put(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, arguments.notNullAssertions);
configuration.put(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, arguments.notNullParamAssertions);
@@ -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
+1 -2
View File
@@ -1,4 +1,3 @@
-src
$TESTDATA_DIR$/classpath.kt
-output
$TEMP_DIR$
$TEMP_DIR$
@@ -1,4 +1,3 @@
-src
$TESTDATA_DIR$/conflictingOverloads.kt
-output
$TEMP_DIR$
$TEMP_DIR$
@@ -1,4 +1,4 @@
-src
$TESTDATA_DIR$/diagnosticsOrder1.kt:$TESTDATA_DIR$/diagnosticsOrder2.kt
$TESTDATA_DIR$/diagnosticsOrder1.kt
$TESTDATA_DIR$/diagnosticsOrder2.kt
-output
$TEMP_DIR$
$TEMP_DIR$
-1
View File
@@ -1,6 +1,5 @@
Usage: kotlinc-jvm <options> <source files>
where possible options include:
-src <path> Source file or directory (allows many paths separated by the system path separator)
-jar <path> Resulting .jar file path
-output <path> Output directory path for .class files
-classpath <path> Paths where to find user class files
-1
View File
@@ -1,6 +1,5 @@
Usage: kotlinc-jvm <options> <source files>
where possible options include:
-src <path> Source file or directory (allows many paths separated by the system path separator)
-jar <path> Resulting .jar file path
-output <path> Output directory path for .class files
-classpath <path> Paths where to find user class files
-1
View File
@@ -1,6 +1,5 @@
Usage: kotlinc-jvm <options> <source files>
where possible options include:
-src <path> Source file or directory (allows many paths separated by the system path separator)
-jar <path> Resulting .jar file path
-output <path> Output directory path for .class files
-classpath <path> Paths where to find user class files
@@ -1,7 +1,6 @@
Wrong value for inline option: 'wrong'. Should be 'on'/'off' or 'true'/'false'
Usage: kotlinc-jvm <options> <source files>
where possible options include:
-src <path> Source file or directory (allows many paths separated by the system path separator)
-jar <path> Resulting .jar file path
-output <path> Output directory path for .class files
-classpath <path> Paths where to find user class files
@@ -1,4 +1,3 @@
-src
$TESTDATA_DIR$/multipleTextRangesInDiagnosticsOrder.kt
-output
$TEMP_DIR$
$TEMP_DIR$
@@ -1,8 +1,7 @@
-src
$TESTDATA_DIR$/simple.kt
-classpath
not/existing/path
-annotations
yet/another/not/existing/path
-output
$TEMP_DIR$
$TEMP_DIR$
@@ -1,4 +1,3 @@
-src
not/existing/path
-output
$TEMP_DIR$
$TEMP_DIR$
@@ -1,4 +1,3 @@
-src
$TESTDATA_DIR$/signatureClash.kt
-output
$TEMP_DIR$
$TEMP_DIR$
+1 -2
View File
@@ -1,4 +1,3 @@
-src
$TESTDATA_DIR$/simple.kt
-output
$TEMP_DIR$
$TEMP_DIR$
@@ -1,6 +1,5 @@
-src
$TESTDATA_DIR$/../warnings.kt
-suppress
warnings
-output
$TEMP_DIR$
$TEMP_DIR$
@@ -1,6 +1,5 @@
-src
$TESTDATA_DIR$/../warnings.kt
-suppress
WaRnInGs
-output
$TEMP_DIR$
$TEMP_DIR$
@@ -1,6 +1,5 @@
-src
$TESTDATA_DIR$/wrongAbiVersion.kt
-classpath
$TESTDATA_DIR$/wrongAbiVersionLib
-output
$TEMP_DIR$
$TEMP_DIR$
@@ -1,7 +1,6 @@
Invalid argument: -wrongArgument
Usage: kotlinc-jvm <options> <source files>
where possible options include:
-src <path> Source file or directory (allows many paths separated by the system path separator)
-jar <path> Resulting .jar file path
-output <path> Output directory path for .class files
-classpath <path> Paths where to find user class files
@@ -1,6 +1,5 @@
-src
$TESTDATA_DIR$/wrongKotlinSignature.kt
-classpath
$TESTDATA_DIR$/wrongKotlinSignatureLib
-output
$TEMP_DIR$
$TEMP_DIR$
@@ -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());
}
@@ -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<String> 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);
}
@@ -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);
@@ -34,7 +34,7 @@ class KDocCompiler() : K2JVMCompiler() {
}
protected override fun usage(target : PrintStream) {
target.println("Usage: KDocCompiler -docOutput <docOutputDir> [-output <outputDir>|-jar <jarFileName>] [-stdlib <path to runtime.jar>] [-src <filename or dirname>|-module <module file>] [-includeRuntime]");
target.println("Usage: KDocCompiler -docOutput <docOutputDir> [-output <outputDir>|-jar <jarFileName>] [-stdlib <path to runtime.jar>] [<filename or dirname>|-module <module file>] [-includeRuntime]");
}
}