diff --git a/build.gradle b/build.gradle index 26c7043b2a8..2cd35cb60b4 100644 --- a/build.gradle +++ b/build.gradle @@ -301,9 +301,6 @@ targetList.each { target -> task("${target}PlatformLibs") { dependsOn ":platformLibs:${target}Install" - if (target == 'wasm32') { - dependsOn 'Interop:JsRuntime:installJsRuntime' - } } task("${target}CrossDist") { diff --git a/runtime/build.gradle b/runtime/build.gradle index 228368e9b93..5eb2af6c05e 100644 --- a/runtime/build.gradle +++ b/runtime/build.gradle @@ -51,3 +51,29 @@ task clean { delete buildDir } } + +task generateJsMath { + dependsOn ':dist' + doLast { + def jsinteropScript = isWindows() ? "jsinterop.bat" : "jsinterop" + def jsinterop = "$distDir/bin/$jsinteropScript" + def targetDir = "$buildDir/generated" + def firstLine = true + "$jsinterop -pkg kotlinx.interop.wasm.math -o $targetDir/math -target wasm32".execute().waitFor() + copy { + from("$targetDir/math-build/natives/js_stubs.js") + into('src/main/js') + rename { "math.js" } + filter { line -> + if (firstLine) { + firstLine = false + return "// NOTE: THIS FILE IS AUTO-GENERATED!\n" + + "// Run ':runtime:generateJsMath' to re-generate it.\n\n" + + "$line" + } else { + return line + } + } + } + } +} diff --git a/runtime/src/main/js/math.js b/runtime/src/main/js/math.js index 50d7137405e..019aace7d1f 100644 --- a/runtime/src/main/js/math.js +++ b/runtime/src/main/js/math.js @@ -1,18 +1,5 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// NOTE: THIS FILE IS AUTO-GENERATED! +// Run ':runtime:generateJsMath' to re-generate it. konan.libraries.push ({