JS: allow js-file in library-files for cli compiler
This commit is contained in:
+2
-2
@@ -5,9 +5,9 @@
|
|||||||
<target name="build">
|
<target name="build">
|
||||||
<mkdir dir="${temp.library.path}"/>
|
<mkdir dir="${temp.library.path}"/>
|
||||||
|
|
||||||
<kotlin2js src="${library.path}" output="${temp.library.path}/jslib-example.js" metaInfo="${temp.library.path}/jslib-example.meta.js"/>
|
<kotlin2js src="${library.path}" noStdlib="true" output="${temp.library.path}/jslib-example.js" metaInfo="${temp.library.path}/jslib-example.meta.js"/>
|
||||||
|
|
||||||
<kotlin2js src="${test.data}/root1" output="${temp}/out.js" main="call">
|
<kotlin2js src="${test.data}/root1" noStdlib="true" output="${temp}/out.js" main="call">
|
||||||
<library>
|
<library>
|
||||||
<pathelement path="${temp.library.path}"/>
|
<pathelement path="${temp.library.path}"/>
|
||||||
</library>
|
</library>
|
||||||
|
|||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
OUT:
|
||||||
|
Buildfile: [TestData]/build.xml
|
||||||
|
|
||||||
|
build:
|
||||||
|
[mkdir] Created dir: [Temp]/lib
|
||||||
|
[kotlin2js] Compiling [[TestData]/jslib-example] => [[Temp]/lib/jslib-example.js]
|
||||||
|
[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js]
|
||||||
|
[copy] Copying 2 files to [Temp]
|
||||||
|
|
||||||
|
BUILD SUCCESSFUL
|
||||||
|
Total time: [time]
|
||||||
|
|
||||||
|
Return code: 0
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
<project name="Ant Task Test" default="build">
|
||||||
|
<taskdef resource="org/jetbrains/kotlin/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
|
||||||
|
<property name="library.path" value="${test.data}/jslib-example"/>
|
||||||
|
<property name="temp.library.path" value="${temp}/lib"/>
|
||||||
|
<target name="build">
|
||||||
|
<mkdir dir="${temp.library.path}"/>
|
||||||
|
|
||||||
|
<kotlin2js src="${library.path}" noStdlib="true" output="${temp.library.path}/jslib-example.js" metaInfo="${temp.library.path}/jslib-example.meta.js"/>
|
||||||
|
|
||||||
|
<kotlin2js src="${test.data}/root1" noStdlib="true" output="${temp}/out.js" main="call">
|
||||||
|
<library>
|
||||||
|
<pathelement path="${temp.library.path}/jslib-example.meta.js"/>
|
||||||
|
</library>
|
||||||
|
</kotlin2js>
|
||||||
|
<copy todir="${temp}">
|
||||||
|
<fileset dir="${temp.library.path}">
|
||||||
|
<include name="**/*.js"/>
|
||||||
|
<exclude name="META-INF/**"/>
|
||||||
|
</fileset>
|
||||||
|
</copy>
|
||||||
|
</target>
|
||||||
|
</project>
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
package library.sample
|
||||||
|
|
||||||
|
public class ClassA() {
|
||||||
|
val value: Int = 100
|
||||||
|
}
|
||||||
|
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
import library.sample.*
|
||||||
|
|
||||||
|
var ok = "FAIL"
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
val x = ClassA().value
|
||||||
|
if (x == 100) {
|
||||||
|
ok = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String = ok
|
||||||
@@ -117,6 +117,11 @@ public class AntTaskJsTest extends AntTaskBaseTest {
|
|||||||
doJsAntTest("jslib-example.js");
|
doJsAntTest("jslib-example.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void simpleWithoutStdlibAndJsFileAsAnotherLib() throws Exception {
|
||||||
|
doJsAntTest("jslib-example.js");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void simpleWithMainFQArgs() throws Exception {
|
public void simpleWithMainFQArgs() throws Exception {
|
||||||
doJsAntTest();
|
doJsAntTest();
|
||||||
|
|||||||
@@ -126,8 +126,10 @@ public object LibraryUtils {
|
|||||||
traverseArchive(lib) { (content, path) ->
|
traverseArchive(lib) { (content, path) ->
|
||||||
files.add(content)
|
files.add(content)
|
||||||
}
|
}
|
||||||
|
lib.getName().endsWith(KotlinJavascriptMetadataUtils.JS_EXT) ->
|
||||||
|
files.add(FileUtil.loadFile(lib))
|
||||||
else ->
|
else ->
|
||||||
throw IllegalArgumentException("Unknown library format (directory or zip expected): $lib")
|
throw IllegalArgumentException("Unknown library format (directory, zip or js file expected): $lib")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user