Drop "-src" in kotlinc-jvm
Free arguments should be used instead
This commit is contained in:
@@ -566,8 +566,7 @@
|
|||||||
<assertions>
|
<assertions>
|
||||||
<enable/>
|
<enable/>
|
||||||
</assertions>
|
</assertions>
|
||||||
<arg value="-src"/>
|
<arg line="@{src}"/>
|
||||||
<arg value="@{src}"/>
|
|
||||||
<arg value="-output"/>
|
<arg value="-output"/>
|
||||||
<arg value="@{output}"/>
|
<arg value="@{output}"/>
|
||||||
<arg value="-noStdlib"/>
|
<arg value="-noStdlib"/>
|
||||||
@@ -577,7 +576,7 @@
|
|||||||
</sequential>
|
</sequential>
|
||||||
</macrodef>
|
</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"
|
output="${output}/classes/runtime"
|
||||||
classpath="${basedir}/core/runtime.jvm/src"/>
|
classpath="${basedir}/core/runtime.jvm/src"/>
|
||||||
|
|
||||||
|
|||||||
-4
@@ -24,10 +24,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("UnusedDeclaration")
|
@SuppressWarnings("UnusedDeclaration")
|
||||||
public class K2JVMCompilerArguments extends CommonCompilerArguments {
|
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")
|
@Argument(value = "jar", description = "Resulting .jar file path")
|
||||||
@ValueDescription("<path>")
|
@ValueDescription("<path>")
|
||||||
public String jar;
|
public String jar;
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package org.jetbrains.jet.cli.jvm;
|
|||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.intellij.openapi.Disposable;
|
import com.intellij.openapi.Disposable;
|
||||||
import com.intellij.openapi.util.text.StringUtil;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.cli.common.CLICompiler;
|
import org.jetbrains.jet.cli.common.CLICompiler;
|
||||||
import org.jetbrains.jet.cli.common.CLIConfigurationKeys;
|
import org.jetbrains.jet.cli.common.CLIConfigurationKeys;
|
||||||
@@ -44,7 +43,6 @@ import org.jetbrains.jet.utils.KotlinPathsFromHomeDir;
|
|||||||
import org.jetbrains.jet.utils.PathUtil;
|
import org.jetbrains.jet.utils.PathUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -86,7 +84,6 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
|
|||||||
|
|
||||||
if (!arguments.script &&
|
if (!arguments.script &&
|
||||||
arguments.module == null &&
|
arguments.module == null &&
|
||||||
arguments.src == null &&
|
|
||||||
arguments.freeArgs.isEmpty() &&
|
arguments.freeArgs.isEmpty() &&
|
||||||
!arguments.version
|
!arguments.version
|
||||||
) {
|
) {
|
||||||
@@ -99,19 +96,12 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
|
|||||||
configuration.add(CommonConfigurationKeys.SOURCE_ROOTS_KEY, arguments.freeArgs.get(0));
|
configuration.add(CommonConfigurationKeys.SOURCE_ROOTS_KEY, arguments.freeArgs.get(0));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (arguments.src != null) {
|
configuration.addAll(CommonConfigurationKeys.SOURCE_ROOTS_KEY, arguments.freeArgs);
|
||||||
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.put(JVMConfigurationKeys.SCRIPT_PARAMETERS, arguments.script
|
configuration.put(JVMConfigurationKeys.SCRIPT_PARAMETERS, arguments.script
|
||||||
? CommandLineScriptUtils.scriptParameters()
|
? CommandLineScriptUtils.scriptParameters()
|
||||||
: Collections.<AnalyzerScriptParameter>emptyList());
|
: Collections.<AnalyzerScriptParameter>emptyList());
|
||||||
|
|
||||||
configuration.put(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, arguments.notNullAssertions);
|
configuration.put(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, arguments.notNullAssertions);
|
||||||
configuration.put(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, arguments.notNullParamAssertions);
|
configuration.put(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, arguments.notNullParamAssertions);
|
||||||
|
|||||||
@@ -59,14 +59,14 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase {
|
|||||||
public void compilationFailed() throws Exception {
|
public void compilationFailed() throws Exception {
|
||||||
String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "smoke.jar";
|
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
|
@Test
|
||||||
public void syntaxErrors() throws Exception {
|
public void syntaxErrors() throws Exception {
|
||||||
String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "smoke.jar";
|
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
|
@Test
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
-src
|
|
||||||
$TESTDATA_DIR$/classpath.kt
|
$TESTDATA_DIR$/classpath.kt
|
||||||
-output
|
-output
|
||||||
$TEMP_DIR$
|
$TEMP_DIR$
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
-src
|
|
||||||
$TESTDATA_DIR$/conflictingOverloads.kt
|
$TESTDATA_DIR$/conflictingOverloads.kt
|
||||||
-output
|
-output
|
||||||
$TEMP_DIR$
|
$TEMP_DIR$
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
-src
|
$TESTDATA_DIR$/diagnosticsOrder1.kt
|
||||||
$TESTDATA_DIR$/diagnosticsOrder1.kt:$TESTDATA_DIR$/diagnosticsOrder2.kt
|
$TESTDATA_DIR$/diagnosticsOrder2.kt
|
||||||
-output
|
-output
|
||||||
$TEMP_DIR$
|
$TEMP_DIR$
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
Usage: kotlinc-jvm <options> <source files>
|
Usage: kotlinc-jvm <options> <source files>
|
||||||
where possible options include:
|
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
|
-jar <path> Resulting .jar file path
|
||||||
-output <path> Output directory path for .class files
|
-output <path> Output directory path for .class files
|
||||||
-classpath <path> Paths where to find user class files
|
-classpath <path> Paths where to find user class files
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
Usage: kotlinc-jvm <options> <source files>
|
Usage: kotlinc-jvm <options> <source files>
|
||||||
where possible options include:
|
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
|
-jar <path> Resulting .jar file path
|
||||||
-output <path> Output directory path for .class files
|
-output <path> Output directory path for .class files
|
||||||
-classpath <path> Paths where to find user class files
|
-classpath <path> Paths where to find user class files
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
Usage: kotlinc-jvm <options> <source files>
|
Usage: kotlinc-jvm <options> <source files>
|
||||||
where possible options include:
|
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
|
-jar <path> Resulting .jar file path
|
||||||
-output <path> Output directory path for .class files
|
-output <path> Output directory path for .class files
|
||||||
-classpath <path> Paths where to find user 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'
|
Wrong value for inline option: 'wrong'. Should be 'on'/'off' or 'true'/'false'
|
||||||
Usage: kotlinc-jvm <options> <source files>
|
Usage: kotlinc-jvm <options> <source files>
|
||||||
where possible options include:
|
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
|
-jar <path> Resulting .jar file path
|
||||||
-output <path> Output directory path for .class files
|
-output <path> Output directory path for .class files
|
||||||
-classpath <path> Paths where to find user class files
|
-classpath <path> Paths where to find user class files
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
-src
|
|
||||||
$TESTDATA_DIR$/multipleTextRangesInDiagnosticsOrder.kt
|
$TESTDATA_DIR$/multipleTextRangesInDiagnosticsOrder.kt
|
||||||
-output
|
-output
|
||||||
$TEMP_DIR$
|
$TEMP_DIR$
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
-src
|
|
||||||
$TESTDATA_DIR$/simple.kt
|
$TESTDATA_DIR$/simple.kt
|
||||||
-classpath
|
-classpath
|
||||||
not/existing/path
|
not/existing/path
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
-src
|
|
||||||
not/existing/path
|
not/existing/path
|
||||||
-output
|
-output
|
||||||
$TEMP_DIR$
|
$TEMP_DIR$
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
-src
|
|
||||||
$TESTDATA_DIR$/signatureClash.kt
|
$TESTDATA_DIR$/signatureClash.kt
|
||||||
-output
|
-output
|
||||||
$TEMP_DIR$
|
$TEMP_DIR$
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
-src
|
|
||||||
$TESTDATA_DIR$/simple.kt
|
$TESTDATA_DIR$/simple.kt
|
||||||
-output
|
-output
|
||||||
$TEMP_DIR$
|
$TEMP_DIR$
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
-src
|
|
||||||
$TESTDATA_DIR$/../warnings.kt
|
$TESTDATA_DIR$/../warnings.kt
|
||||||
-suppress
|
-suppress
|
||||||
warnings
|
warnings
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
-src
|
|
||||||
$TESTDATA_DIR$/../warnings.kt
|
$TESTDATA_DIR$/../warnings.kt
|
||||||
-suppress
|
-suppress
|
||||||
WaRnInGs
|
WaRnInGs
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
-src
|
|
||||||
$TESTDATA_DIR$/wrongAbiVersion.kt
|
$TESTDATA_DIR$/wrongAbiVersion.kt
|
||||||
-classpath
|
-classpath
|
||||||
$TESTDATA_DIR$/wrongAbiVersionLib
|
$TESTDATA_DIR$/wrongAbiVersionLib
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
Invalid argument: -wrongArgument
|
Invalid argument: -wrongArgument
|
||||||
Usage: kotlinc-jvm <options> <source files>
|
Usage: kotlinc-jvm <options> <source files>
|
||||||
where possible options include:
|
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
|
-jar <path> Resulting .jar file path
|
||||||
-output <path> Output directory path for .class files
|
-output <path> Output directory path for .class files
|
||||||
-classpath <path> Paths where to find user class files
|
-classpath <path> Paths where to find user class files
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
-src
|
|
||||||
$TESTDATA_DIR$/wrongKotlinSignature.kt
|
$TESTDATA_DIR$/wrongKotlinSignature.kt
|
||||||
-classpath
|
-classpath
|
||||||
$TESTDATA_DIR$/wrongKotlinSignatureLib
|
$TESTDATA_DIR$/wrongKotlinSignatureLib
|
||||||
|
|||||||
@@ -96,9 +96,10 @@ public class MockLibraryUtil {
|
|||||||
Method execMethod = compilerClass.getMethod("exec", PrintStream.class, String[].class);
|
Method execMethod = compilerClass.getMethod("exec", PrintStream.class, String[].class);
|
||||||
|
|
||||||
//noinspection IOResourceOpenedButNotSafelyClosed
|
//noinspection IOResourceOpenedButNotSafelyClosed
|
||||||
Enum<?> invocationResult = (Enum<?>) execMethod
|
Enum<?> invocationResult = (Enum<?>) execMethod.invoke(
|
||||||
.invoke(compilerObject, new PrintStream(outStream),
|
compilerObject, new PrintStream(outStream),
|
||||||
new String[] {"-src", sourcesPath, "-output", outDir.getAbsolutePath(), "-classpath", sourcesPath});
|
new String[] {sourcesPath, "-output", outDir.getAbsolutePath(), "-classpath", sourcesPath}
|
||||||
|
);
|
||||||
|
|
||||||
assertEquals(new String(outStream.toByteArray()), ExitCode.OK.name(), invocationResult.name());
|
assertEquals(new String(outStream.toByteArray()), ExitCode.OK.name(), invocationResult.name());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
package org.jetbrains.jet.codegen.forTestCompile;
|
package org.jetbrains.jet.codegen.forTestCompile;
|
||||||
|
|
||||||
import com.intellij.openapi.util.io.FileUtil;
|
import com.intellij.openapi.util.io.FileUtil;
|
||||||
|
import com.intellij.util.ArrayUtil;
|
||||||
|
import kotlin.KotlinPackage;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
import org.jetbrains.jet.cli.common.ExitCode;
|
import org.jetbrains.jet.cli.common.ExitCode;
|
||||||
@@ -57,8 +59,9 @@ public class ForTestCompileRuntime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void compileBuiltIns(@NotNull File destDir) throws IOException {
|
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,
|
||||||
compileKotlinToJvm("built-ins", destDir, src, src);
|
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(
|
JetTestUtils.compileJavaFiles(
|
||||||
javaFilesUnder(RUNTIME_JVM_SRC_PATH),
|
javaFilesUnder(RUNTIME_JVM_SRC_PATH),
|
||||||
@@ -75,25 +78,25 @@ public class ForTestCompileRuntime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void compileStdlib(@NotNull File destDir) throws IOException {
|
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(
|
private static void compileKotlinToJvm(
|
||||||
@NotNull String debugName,
|
@NotNull String debugName,
|
||||||
@NotNull File destDir,
|
@NotNull File destDir,
|
||||||
@NotNull String src,
|
@NotNull String classPath,
|
||||||
@NotNull String classPath
|
@NotNull String... src
|
||||||
) {
|
) {
|
||||||
ExitCode exitCode = new K2JVMCompiler().exec(
|
List<String> args = KotlinPackage.arrayListOf(
|
||||||
System.out,
|
|
||||||
"-output", destDir.getPath(),
|
"-output", destDir.getPath(),
|
||||||
"-src", src,
|
|
||||||
"-noStdlib",
|
"-noStdlib",
|
||||||
"-noJdkAnnotations",
|
"-noJdkAnnotations",
|
||||||
"-suppress", "warnings",
|
"-suppress", "warnings",
|
||||||
"-annotations", JetTestUtils.getJdkAnnotationsJar().getAbsolutePath(),
|
"-annotations", JetTestUtils.getJdkAnnotationsJar().getAbsolutePath(),
|
||||||
"-classpath", classPath
|
"-classpath", classPath
|
||||||
);
|
);
|
||||||
|
args.addAll(Arrays.asList(src));
|
||||||
|
ExitCode exitCode = new K2JVMCompiler().exec(System.out, ArrayUtil.toStringArray(args));
|
||||||
if (exitCode != ExitCode.OK) {
|
if (exitCode != ExitCode.OK) {
|
||||||
throw new IllegalStateException("Compilation of " + debugName + " failed: " + exitCode);
|
throw new IllegalStateException("Compilation of " + debugName + " failed: " + exitCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,13 +79,16 @@ public class CompileEnvironmentTest extends TestCase {
|
|||||||
File out = new File(tempDir, "out");
|
File out = new File(tempDir, "out");
|
||||||
File stdlib = ForTestCompileRuntime.runtimeJarForTests();
|
File stdlib = ForTestCompileRuntime.runtimeJarForTests();
|
||||||
File jdkAnnotations = JetTestUtils.getJdkAnnotationsJar();
|
File jdkAnnotations = JetTestUtils.getJdkAnnotationsJar();
|
||||||
ExitCode exitCode = new K2JVMCompiler()
|
ExitCode exitCode = new K2JVMCompiler().exec(
|
||||||
.exec(System.out, "-src", JetTestCaseBuilder.getTestDataPathBase() + "/compiler/smoke/Smoke.kt",
|
System.out,
|
||||||
"-output", out.getAbsolutePath(),
|
JetTestCaseBuilder.getTestDataPathBase() +
|
||||||
"-noStdlib",
|
"/compiler/smoke/Smoke.kt",
|
||||||
"-classpath", stdlib.getAbsolutePath(),
|
"-output", out.getAbsolutePath(),
|
||||||
"-noJdkAnnotations",
|
"-noStdlib",
|
||||||
"-annotations", jdkAnnotations.getAbsolutePath());
|
"-classpath", stdlib.getAbsolutePath(),
|
||||||
|
"-noJdkAnnotations",
|
||||||
|
"-annotations", jdkAnnotations.getAbsolutePath()
|
||||||
|
);
|
||||||
Assert.assertEquals(ExitCode.OK, exitCode);
|
Assert.assertEquals(ExitCode.OK, exitCode);
|
||||||
assertEquals(1, out.listFiles().length);
|
assertEquals(1, out.listFiles().length);
|
||||||
assertEquals(2, out.listFiles()[0].listFiles().length);
|
assertEquals(2, out.listFiles()[0].listFiles().length);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class KDocCompiler() : K2JVMCompiler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override fun usage(target : PrintStream) {
|
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]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user