diff --git a/repo/gradle-build-conventions/binaryen-configuration/build.gradle.kts b/repo/gradle-build-conventions/binaryen-configuration/build.gradle.kts new file mode 100644 index 0000000000000..212ffe419ea83 --- /dev/null +++ b/repo/gradle-build-conventions/binaryen-configuration/build.gradle.kts @@ -0,0 +1,27 @@ +plugins { + `kotlin-dsl` + id("org.jetbrains.kotlin.jvm") +} + +repositories { + maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") + mavenCentral() + gradlePluginPortal() + + extra["bootstrapKotlinRepo"]?.let { + maven(url = it) + } +} + +kotlin { + jvmToolchain(8) + + compilerOptions { + allWarningsAsErrors.set(true) + } +} + +dependencies { + compileOnly(kotlin("stdlib", embeddedKotlinVersion)) + compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}") +} diff --git a/repo/gradle-build-conventions/binaryen-configuration/src/main/kotlin/binaryen-configuration.gradle.kts b/repo/gradle-build-conventions/binaryen-configuration/src/main/kotlin/binaryen-configuration.gradle.kts new file mode 100644 index 0000000000000..58673aa25571a --- /dev/null +++ b/repo/gradle-build-conventions/binaryen-configuration/src/main/kotlin/binaryen-configuration.gradle.kts @@ -0,0 +1,9 @@ +import org.jetbrains.kotlin.build.binaryen.BinaryenExtension +import org.jetbrains.kotlin.gradle.targets.js.binaryen.BinaryenRootPlugin + +val binaryenRoot = BinaryenRootPlugin.apply(project.rootProject) + +extensions.create( + "binaryenKotlinBuild", + binaryenRoot, +) \ No newline at end of file diff --git a/repo/gradle-build-conventions/binaryen-configuration/src/main/kotlin/org/jetbrains/kotlin/build/binaryen/BinaryenExtension.kt b/repo/gradle-build-conventions/binaryen-configuration/src/main/kotlin/org/jetbrains/kotlin/build/binaryen/BinaryenExtension.kt new file mode 100644 index 0000000000000..3b403b766d5bb --- /dev/null +++ b/repo/gradle-build-conventions/binaryen-configuration/src/main/kotlin/org/jetbrains/kotlin/build/binaryen/BinaryenExtension.kt @@ -0,0 +1,23 @@ +/* + * Copyright 2010-2024 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.build.binaryen + +import org.gradle.api.tasks.testing.Test +import org.jetbrains.kotlin.gradle.targets.js.binaryen.BinaryenRootExtension + +abstract class BinaryenExtension( + private val binaryenRoot: BinaryenRootExtension +) { + fun Test.setupBinaryen() { + dependsOn(binaryenRoot.setupTaskProvider) + val binaryenExecutablePath = project.provider { + binaryenRoot.requireConfigured().executablePath.absolutePath + } + doFirst { + systemProperty("binaryen.path", binaryenExecutablePath.get()) + } + } +} \ No newline at end of file diff --git a/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/setupBinaryen.kt b/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/setupBinaryen.kt deleted file mode 100644 index b6d8fa3b9c800..0000000000000 --- a/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/setupBinaryen.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2010-2023 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. - */ -import org.gradle.api.Project -import org.gradle.api.tasks.testing.Test -import org.jetbrains.kotlin.gradle.targets.js.binaryen.BinaryenRootExtension -import org.jetbrains.kotlin.gradle.targets.js.binaryen.BinaryenRootPlugin - -private object BinaryenUtils { - lateinit var binaryenPlugin: BinaryenRootExtension - - fun useBinaryenPlugin(project: Project) { - binaryenPlugin = BinaryenRootPlugin.apply(project.rootProject) - } -} - -fun Project.useBinaryenPlugin() { - BinaryenUtils.useBinaryenPlugin(this) -} - -fun Test.setupBinaryen() { - dependsOn(BinaryenUtils.binaryenPlugin.setupTaskProvider) - val binaryenExecutablePath = project.provider { - BinaryenUtils.binaryenPlugin.requireConfigured().executablePath.absolutePath - } - doFirst { - systemProperty("binaryen.path", binaryenExecutablePath.get()) - } -} diff --git a/repo/gradle-build-conventions/settings.gradle.kts b/repo/gradle-build-conventions/settings.gradle.kts index 01bcaf9cd03aa..50733c87f9fdd 100644 --- a/repo/gradle-build-conventions/settings.gradle.kts +++ b/repo/gradle-build-conventions/settings.gradle.kts @@ -35,4 +35,5 @@ include(":asm-deprecating-transformer") include(":binary-compatibility-extended") include(":gradle-plugins-documentation") include(":gradle-plugins-common") -include(":d8-configuration") \ No newline at end of file +include(":d8-configuration") +include(":binaryen-configuration") \ No newline at end of file diff --git a/wasm/wasm.tests/build.gradle.kts b/wasm/wasm.tests/build.gradle.kts index af23c161992de..e7f8779ab4b2f 100644 --- a/wasm/wasm.tests/build.gradle.kts +++ b/wasm/wasm.tests/build.gradle.kts @@ -1,6 +1,7 @@ import org.gradle.internal.os.OperatingSystem import java.net.URI import com.github.gradle.node.npm.task.NpmTask +import org.jetbrains.kotlin.build.binaryen.BinaryenExtension import org.jetbrains.kotlin.build.d8.D8Extension import java.nio.file.Files import java.util.* @@ -10,6 +11,7 @@ plugins { id("jps-compatible") alias(libs.plugins.gradle.node) id("d8-configuration") + id("binaryen-configuration") } node { @@ -125,7 +127,6 @@ dependencies { val generationRoot = projectDir.resolve("tests-gen") useNodeJsPlugin() -useBinaryenPlugin() optInToExperimentalCompilerApi() sourceSets { @@ -283,7 +284,9 @@ fun Project.wasmProjectTest( setupV8() } setupNodeJs() - setupBinaryen() + with(project.the()) { + setupBinaryen() + } setupSpiderMonkey() setupWasmEdge() useJUnitPlatform()