add kjsm option for kotlin js command line compiler

This commit is contained in:
Michael Nedzelsky
2015-11-20 15:59:11 +03:00
parent 24e473f47b
commit c80c33efb6
13 changed files with 69 additions and 12 deletions
@@ -43,5 +43,16 @@ public class SimpleOutputFile(
override fun asByteArray(): ByteArray = content.toByteArray()
override fun asText(): String = content
override fun toString() = "$relativePath (compiled from $sourceFiles)"
}
public class SimpleOutputBinaryFile(
override val sourceFiles: List<File>,
override val relativePath: String,
private val content: ByteArray
) : OutputFile {
override fun asByteArray(): ByteArray = content
override fun asText(): String = String(content)
override fun toString() = "$relativePath (compiled from $sourceFiles)"
}
@@ -41,6 +41,9 @@ public class K2JSCompilerArguments extends CommonCompilerArguments {
@Argument(value = "meta-info", description = "Generate metadata")
public boolean metaInfo;
@Argument(value = "kjsm", description = "Generate kjsm-files (for creating libraries)")
public boolean kjsm;
@Argument(value = "target", description = "Generate JS files for specific ECMA version (only ECMA 5 is supported)")
@ValueDescription("<version>")
public String target;
@@ -264,6 +264,7 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
.sourceMap(arguments.sourceMap)
.inlineEnabled(inlineEnabled)
.metaInfo(arguments.metaInfo)
.kjsm(arguments.kjsm)
.build();
}
+5
View File
@@ -0,0 +1,5 @@
compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/jslib-example/LibraryExample.kt
-no-stdlib
-kjsm
-output
$TEMP_DIR$/jslib-example.js
+1
View File
@@ -0,0 +1 @@
OK
+1
View File
@@ -1,5 +1,6 @@
compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/jslib-example/LibraryExample.kt
-no-stdlib
-meta-info
-kjsm
-output
$TEMP_DIR$/jslib-example.js
+1
View File
@@ -5,6 +5,7 @@ where possible options include:
-library-files <path[,]> Path to zipped library sources or kotlin files separated by commas
-source-map Generate source map
-meta-info Generate metadata
-kjsm Generate kjsm-files (for creating libraries)
-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)
-output-prefix <path> Path to file which will be added to the beginning of output file
@@ -274,6 +274,12 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/cli/js"), Pattern.compile("^(.+)\\.args$"), false);
}
@TestMetadata("createKjsm.args")
public void testCreateKjsm() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/js/createKjsm.args");
doJsTest(fileName);
}
@TestMetadata("createMetadata.args")
public void testCreateMetadata() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/js/createMetadata.args");
@@ -97,6 +97,15 @@ public class K2JsCliTest extends CliBaseTest {
Assert.assertTrue(new File(tmpdir.getTmpDir(), "jslib-example.meta.js").isFile());
Assert.assertTrue(new File(tmpdir.getTmpDir(), "jslib-example.js").isFile());
Assert.assertTrue(new File(tmpdir.getTmpDir(), "jslib-example/library/sample/classA.kjsm").isFile());
}
@Test
public void createKjsm() throws Exception {
executeCompilerCompareOutputJS();
Assert.assertTrue(new File(tmpdir.getTmpDir(), "jslib-example.js").isFile());
Assert.assertTrue(new File(tmpdir.getTmpDir(), "jslib-example/library/sample/classA.kjsm").isFile());
}
@Test