Drop "-sourceFiles" in kotlinc-js

Use free arguments instead, as is done in kotlinc-jvm and all sensible
compilers everywhere

Also fix some cases of AntTaskTest to be able to run them locally
This commit is contained in:
Alexander Udalov
2014-07-22 17:16:37 +04:00
parent 125c5e2942
commit 87439b8e0b
14 changed files with 22 additions and 39 deletions
@@ -35,10 +35,6 @@ public class K2JSCompilerArguments extends CommonCompilerArguments {
@ValueDescription("<path[,]>")
public String[] libraryFiles;
@Argument(value = "sourceFiles", description = "Source files or directories separated by commas")
@ValueDescription("<path[,]>")
public String[] sourceFiles;
@Argument(value = "sourcemap", description = "Generate SourceMap")
public boolean sourcemap;
@@ -76,13 +76,13 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
@NotNull MessageCollector messageCollector,
@NotNull Disposable rootDisposable
) {
if (arguments.sourceFiles == null) {
messageCollector.report(CompilerMessageSeverity.ERROR, "Specify sources location via -sourceFiles", NO_LOCATION);
if (arguments.freeArgs.isEmpty()) {
messageCollector.report(CompilerMessageSeverity.ERROR, "Specify at least one source file or directory", NO_LOCATION);
return ExitCode.INTERNAL_ERROR;
}
CompilerConfiguration configuration = new CompilerConfiguration();
configuration.addAll(CommonConfigurationKeys.SOURCE_ROOTS_KEY, Arrays.asList(arguments.sourceFiles));
configuration.addAll(CommonConfigurationKeys.SOURCE_ROOTS_KEY, arguments.freeArgs);
JetCoreEnvironment environmentForJS = JetCoreEnvironment.createForProduction(rootDisposable, configuration);
Project project = environmentForJS.getProject();
@@ -50,9 +50,8 @@ public class AntTaskTest extends KotlinIntegrationTestBase {
doAntTest(SUCCESSFUL, extraJavaArgs);
String jar = getOutputFileByName(JVM_OUT_FILE).getAbsolutePath();
String runtime = getKotlinRuntimePath();
runJava("hello.run", "-cp", jar + File.pathSeparator + runtime, "hello.HelloPackage");
runJava("hello.run", "-cp", jar + File.pathSeparator + getKotlinRuntimePath(), "hello.HelloPackage");
}
private void doJsAntTest() throws Exception {
@@ -107,20 +106,20 @@ public class AntTaskTest extends KotlinIntegrationTestBase {
@Test
public void javacCompiler() throws Exception {
doJvmAntTest("-cp", getKotlinAntPath(),
doJvmAntTest("-cp", getClassPathForAnt(),
"-Dkotlin.home", getCompilerLib().getAbsolutePath());
}
@Test
public void externalAnnotations() throws Exception {
doJvmAntTest("-cp", getKotlinAntPath(),
doJvmAntTest("-cp", getClassPathForAnt(),
"-Didea.sdk", getIdeaSdkHome(),
"-Dkotlin.home", getCompilerLib().getAbsolutePath());
}
@Test
public void kotlinCompiler() throws Exception {
doJvmAntTest("-cp", getKotlinAntPath(),
doJvmAntTest("-cp", getClassPathForAnt(),
"-Didea.sdk", getIdeaSdkHome(),
"-Dkotlin.home", getCompilerLib().getAbsolutePath());
}
@@ -203,8 +202,8 @@ public class AntTaskTest extends KotlinIntegrationTestBase {
return runJava(logName, ArrayUtil.toStringArray(strings));
}
private static String getKotlinAntPath() {
return getCompilerLib() + File.separator + "kotlin-ant.jar";
private static String getClassPathForAnt() {
return getCompilerLib() + File.separator + "kotlin-ant.jar" + File.pathSeparator + getKotlinRuntimePath();
}
private static String getIdeaSdkHome() {
@@ -2,7 +2,7 @@ OUT:
Buildfile: [TestData]/build.xml
build:
[kotlin2js] Compiling [[TestData]/root1,[TestData]/bar.kt,[TestData]/root2/Foo.kt] => [[Temp]/out.js]
[kotlin2js] Compiling [[TestData]/root1, [TestData]/bar.kt, [TestData]/root2/Foo.kt] => [[Temp]/out.js]
BUILD SUCCESSFUL
Total time: [time]
-1
View File
@@ -2,7 +2,6 @@ Usage: kotlinc-js <options> <source files>
where possible options include:
-output <path> Output file path
-libraryFiles <path[,]> Path to zipped library sources or kotlin files separated by commas
-sourceFiles <path[,]> Source files or directories separated by commas
-sourcemap Generate SourceMap
-target <version> Generate JS files for specific ECMA version (only ECMA 5 is supported)
-main {call,noCall} Whether a main function should be called; default 'call' (main function will be auto detected)
@@ -1,6 +1,5 @@
-sourceFiles
$TESTDATA_DIR$/simple2js.kt
-output
$TEMP_DIR$/out.js
-outputPostfix
not/existing/path
not/existing/path
@@ -1,6 +1,5 @@
-sourceFiles
$TESTDATA_DIR$/simple2js.kt
-output
$TEMP_DIR$/out.js
-outputPrefix
not/existing/path
not/existing/path
+1 -2
View File
@@ -1,4 +1,3 @@
-sourceFiles
$TESTDATA_DIR$/simple2js.kt
-output
$TEMP_DIR$/out.js
$TEMP_DIR$/out.js
@@ -1,6 +1,5 @@
-sourceFiles
$TESTDATA_DIR$/../warnings.kt
-suppress
WaRnInGs
-output
$TEMP_DIR$/out.js
$TEMP_DIR$/out.js