[WASM] Add w3c bindings

This commit is contained in:
Igor Yakovlev
2022-09-19 20:11:31 +02:00
committed by teamcity
parent 4bafa2c9db
commit b6eb2b3620
30 changed files with 14005 additions and 7 deletions
+12 -3
View File
@@ -1,5 +1,5 @@
plugins {
kotlin("jvm") version "1.6.10"
kotlin("jvm") version "1.7.20"
}
repositories {
@@ -8,7 +8,7 @@ repositories {
}
dependencies {
implementation("org.jetbrains.dukat:dukat:0.5.8-rc.4")
implementation("org.jetbrains.dukat:dukat:0.5.8-rc.5")
implementation("org.jsoup:jsoup:1.14.2")
}
@@ -19,7 +19,16 @@ task("downloadIDL", JavaExec::class) {
}
task("generateStdlibFromIDL", JavaExec::class) {
main = "org.jetbrains.kotlin.tools.dukat.LaunchKt"
main = "org.jetbrains.kotlin.tools.dukat.LaunchJsKt"
classpath = sourceSets["main"].runtimeClasspath
dependsOn(":dukat:build")
systemProperty("line.separator", "\n")
}
// Configured version of Dukat creates incorrect declarations for kotlin/wasm, pathed version located in yakovlev/dynamicAsType
// After patched version be published we need to update dukat version in dependencies here.
task("generateWasmStdlibFromIDL", JavaExec::class) {
main = "org.jetbrains.kotlin.tools.dukat.LaunchWasmKt"
classpath = sourceSets["main"].runtimeClasspath
dependsOn(":dukat:build")
systemProperty("line.separator", "\n")
@@ -37,12 +37,21 @@ private fun getHeader(): String {
return copyrightNotice + LINE_SEPARATOR + note + LINE_SEPARATOR
}
fun main() {
internal fun launch(outputDirectory: String, dynamicAsType: Boolean, useStaticGetters: Boolean) {
val input = "../../stdlib/js/idl/org.w3c.dom.idl"
val outputDirectory = "../../stdlib/js/src/org.w3c/"
org.jetbrains.dukat.cli.main("-d", outputDirectory, input)
val args = mutableListOf<String>()
args.add("-d")
args.add(outputDirectory)
args.add(input)
if (dynamicAsType) {
args.add("--dynamic-as-type")
}
if (useStaticGetters) {
args.add("--use-static-getters")
}
org.jetbrains.dukat.cli.main(*args.toTypedArray())
for (file in File(outputDirectory).listFiles { name ->
name.extension == "kt"
@@ -0,0 +1,14 @@
/*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.tools.dukat
fun main() {
launch(
outputDirectory = "../../stdlib/js/src/org.w3c/",
dynamicAsType = false,
useStaticGetters = false
)
}
@@ -0,0 +1,14 @@
/*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.tools.dukat
fun main() {
launch(
outputDirectory = "../../stdlib/wasm/src/org.w3c/",
dynamicAsType = true,
useStaticGetters = true
)
}