Skip to content

Commit

Permalink
[Wasm] Remove redundant methods in subtarget because binary has its info
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgonmic authored and qodana-bot committed Dec 9, 2024
1 parent 86f47a8 commit eacf69f
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3732,9 +3732,6 @@ public final class org/jetbrains/kotlin/gradle/targets/js/ir/KotlinBrowserJsIr$C

public abstract class org/jetbrains/kotlin/gradle/targets/js/ir/KotlinD8Ir : org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrSubTarget, org/jetbrains/kotlin/gradle/targets/js/dsl/KotlinWasmD8Dsl {
public fun <init> (Lorg/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTarget;)V
public fun binaryInputFile (Lorg/jetbrains/kotlin/gradle/targets/js/ir/JsIrBinary;)Lorg/gradle/api/provider/Provider;
public fun binarySyncOutput (Lorg/jetbrains/kotlin/gradle/targets/js/ir/JsIrBinary;)Lorg/gradle/api/provider/Provider;
public fun binarySyncTaskName (Lorg/jetbrains/kotlin/gradle/targets/js/ir/JsIrBinary;)Ljava/lang/String;
public fun configureDefaultTestFramework (Lorg/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest;)V
public fun configureTestDependencies (Lorg/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest;Lorg/jetbrains/kotlin/gradle/targets/js/ir/JsIrBinary;)V
public fun getTestTaskDescription ()Ljava/lang/String;
Expand Down Expand Up @@ -3847,9 +3844,6 @@ public abstract class org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrLink :

public abstract class org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrNpmBasedSubTarget : org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrSubTarget {
public fun <init> (Lorg/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTarget;Ljava/lang/String;)V
public fun binaryInputFile (Lorg/jetbrains/kotlin/gradle/targets/js/ir/JsIrBinary;)Lorg/gradle/api/provider/Provider;
public fun binarySyncOutput (Lorg/jetbrains/kotlin/gradle/targets/js/ir/JsIrBinary;)Lorg/gradle/api/provider/Provider;
public fun binarySyncTaskName (Lorg/jetbrains/kotlin/gradle/targets/js/ir/JsIrBinary;)Ljava/lang/String;
}

public final class org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrOutputGranularity : java/lang/Enum {
Expand All @@ -3876,9 +3870,6 @@ public abstract class org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrSubTar
public static final field DISTRIBUTION_TASK_NAME Ljava/lang/String;
public static final field RUN_TASK_NAME Ljava/lang/String;
public fun <init> (Lorg/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTarget;Ljava/lang/String;)V
public abstract fun binaryInputFile (Lorg/jetbrains/kotlin/gradle/targets/js/ir/JsIrBinary;)Lorg/gradle/api/provider/Provider;
public abstract fun binarySyncOutput (Lorg/jetbrains/kotlin/gradle/targets/js/ir/JsIrBinary;)Lorg/gradle/api/provider/Provider;
public abstract fun binarySyncTaskName (Lorg/jetbrains/kotlin/gradle/targets/js/ir/JsIrBinary;)Ljava/lang/String;
public abstract fun configureDefaultTestFramework (Lorg/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest;)V
public abstract fun configureTestDependencies (Lorg/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest;Lorg/jetbrains/kotlin/gradle/targets/js/ir/JsIrBinary;)V
public fun distribution (Lorg/gradle/api/Action;)V
Expand Down Expand Up @@ -3972,9 +3963,6 @@ public final class org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTargetPre

public abstract class org/jetbrains/kotlin/gradle/targets/js/ir/KotlinNodeJsIr : org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrNpmBasedSubTarget, org/jetbrains/kotlin/gradle/targets/js/dsl/KotlinJsNodeDsl {
public fun <init> (Lorg/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTarget;)V
public fun binaryInputFile (Lorg/jetbrains/kotlin/gradle/targets/js/ir/JsIrBinary;)Lorg/gradle/api/provider/Provider;
public fun binarySyncOutput (Lorg/jetbrains/kotlin/gradle/targets/js/ir/JsIrBinary;)Lorg/gradle/api/provider/Provider;
public fun binarySyncTaskName (Lorg/jetbrains/kotlin/gradle/targets/js/ir/JsIrBinary;)Ljava/lang/String;
public fun configureDefaultTestFramework (Lorg/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest;)V
public fun configureTestDependencies (Lorg/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest;Lorg/jetbrains/kotlin/gradle/targets/js/ir/JsIrBinary;)V
public fun getTestTaskDescription ()Ljava/lang/String;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class D8EnvironmentConfigurator(subTarget: KotlinJsIrSubTarget) :

return D8Exec.register(binary.compilation, binaryRunName) {
group = subTarget.taskGroupName
dependsOn(project.tasks.named(subTarget.binarySyncTaskName(binary)))
dependsOn(binary.linkSyncTask)
val inputFile = project.objects.fileProperty().value(
binary.mainFileSyncPath
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ abstract class JsEnvironmentConfigurator<RunTask : Task>(protected val subTarget
val assembleTask = if (subTarget.target.wasmTargetType == KotlinWasmTargetType.WASI) {
(productionExecutable as WasmBinary).optimizeTask
} else {
project.tasks.named(subTarget.binarySyncTaskName(productionExecutable))
productionExecutable.linkSyncTask
}

if (compilation.isMain()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@
package org.jetbrains.kotlin.gradle.targets.js.ir

import org.gradle.api.Action
import org.gradle.api.file.Directory
import org.gradle.api.file.RegularFile
import org.gradle.api.provider.Provider
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.targets.js.d8.D8Exec
import org.jetbrains.kotlin.gradle.targets.js.d8.D8Plugin
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinWasmD8Dsl
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinWasmD8
import org.jetbrains.kotlin.gradle.utils.getFile
import org.jetbrains.kotlin.gradle.utils.withType
import javax.inject.Inject

Expand Down Expand Up @@ -47,17 +43,4 @@ abstract class KotlinD8Ir @Inject constructor(target: KotlinJsIrTarget) :
}
}

override fun binaryInputFile(binary: JsIrBinary): Provider<RegularFile> {
return binary.mainFileSyncPath
}

override fun binarySyncTaskName(binary: JsIrBinary): String {
return binary.linkSyncTaskName
}

override fun binarySyncOutput(binary: JsIrBinary): Provider<Directory> {
return project.objects.directoryProperty().fileProvider(
binary.linkTask.map { it.destinationDirectory.getFile().parentFile.resolve(disambiguationClassifier) }
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,7 @@

package org.jetbrains.kotlin.gradle.targets.js.ir

import org.gradle.api.file.Directory
import org.gradle.api.file.RegularFile
import org.gradle.api.provider.Provider
import org.jetbrains.kotlin.gradle.targets.js.npm.npmProject

abstract class KotlinJsIrNpmBasedSubTarget(
target: KotlinJsIrTarget,
disambiguationClassifier: String,
) : KotlinJsIrSubTarget(target, disambiguationClassifier) {

override fun binaryInputFile(binary: JsIrBinary): Provider<RegularFile> {
return binary.mainFileSyncPath
}

override fun binarySyncTaskName(binary: JsIrBinary): String {
return binary.linkSyncTaskName
}

override fun binarySyncOutput(binary: JsIrBinary): Provider<Directory> {
return binary.compilation.npmProject.dist
}
}
) : KotlinJsIrSubTarget(target, disambiguationClassifier)
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
package org.jetbrains.kotlin.gradle.targets.js.ir

import org.gradle.api.*
import org.gradle.api.file.Directory
import org.gradle.api.file.RegularFile
import org.gradle.api.plugins.ExtensionAware
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.TaskProvider
import org.gradle.language.base.plugins.LifecycleBasePlugin
import org.jetbrains.kotlin.gradle.plugin.AbstractKotlinTargetConfigurator
Expand Down Expand Up @@ -167,9 +164,6 @@ abstract class KotlinJsIrSubTarget(

abstract fun configureDefaultTestFramework(test: KotlinJsTest)
abstract fun configureTestDependencies(test: KotlinJsTest, binary: JsIrBinary)
abstract fun binaryInputFile(binary: JsIrBinary): Provider<RegularFile>
abstract fun binarySyncTaskName(binary: JsIrBinary): String
abstract fun binarySyncOutput(binary: JsIrBinary): Provider<Directory>

private fun configureMainCompilation() {
target.compilations.all { compilation ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
package org.jetbrains.kotlin.gradle.targets.js.ir

import org.gradle.api.Action
import org.gradle.api.file.Directory
import org.gradle.api.file.RegularFile
import org.gradle.api.provider.Provider
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.targets.js.KotlinWasmTargetType
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalMainFunctionArgumentsDsl
Expand All @@ -19,9 +15,6 @@ import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsPlugin.Companion.kotl
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin.Companion.kotlinNodeJsRootExtension
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinWasmNode
import org.jetbrains.kotlin.gradle.tasks.IncrementalSyncTask
import org.jetbrains.kotlin.gradle.utils.getFile
import org.jetbrains.kotlin.gradle.utils.named
import org.jetbrains.kotlin.gradle.utils.withType
import javax.inject.Inject

Expand Down Expand Up @@ -62,40 +55,6 @@ abstract class KotlinNodeJsIr @Inject constructor(target: KotlinJsIrTarget) :
test.dependsOn(binary.linkTask)
}

override fun binaryInputFile(binary: JsIrBinary): Provider<RegularFile> {
return if (target.wasmTargetType != KotlinWasmTargetType.WASI) {
super.binaryInputFile(binary)
} else {
project.objects.fileProperty().fileProvider(
project.tasks.named<IncrementalSyncTask>(binarySyncTaskName(binary)).map {
it.destinationDirectory.get().resolve(binary.mainFileName.get())
}
)
}
}

override fun binarySyncTaskName(binary: JsIrBinary): String {
return if (target.wasmTargetType != KotlinWasmTargetType.WASI) {
super.binarySyncTaskName(binary)
} else {
disambiguateCamelCased(
binary.compilation.name.takeIf { it != KotlinCompilation.MAIN_COMPILATION_NAME },
binary.name,
COMPILE_SYNC
)
}
}

override fun binarySyncOutput(binary: JsIrBinary): Provider<Directory> {
return if (target.wasmTargetType != KotlinWasmTargetType.WASI) {
super.binarySyncOutput(binary)
} else {
project.objects.directoryProperty().fileProvider(
binary.linkTask.map { it.destinationDirectory.getFile().parentFile.resolve(disambiguationClassifier) }
)
}
}

override fun configureDefaultTestFramework(test: KotlinJsTest) {
if (target.platformType != KotlinPlatformType.wasm) {
val nodeJsRoot = project.rootProject.kotlinNodeJsRootExtension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class WebpackConfigurator(private val subTarget: KotlinJsIrSubTarget) : SubTarge
val mode = binary.mode
val archivesName = project.archivesName

val linkSyncTask = compilation.target.project.tasks.named<IncrementalSyncTask>(subTarget.binarySyncTaskName(binary))
val linkSyncTask = binary.linkSyncTask

val webpackTask = subTarget.registerSubTargetTask<KotlinWebpack>(
subTarget.disambiguateCamelCased(
Expand Down Expand Up @@ -127,7 +127,7 @@ class WebpackConfigurator(private val subTarget: KotlinJsIrSubTarget) : SubTarge
val mode = binary.mode
val archivesName = project.archivesName

val linkSyncTask = compilation.target.project.tasks.named<IncrementalSyncTask>(subTarget.binarySyncTaskName(binary))
val linkSyncTask = binary.linkSyncTask

subTarget.registerSubTargetTask<KotlinWebpack>(
subTarget.disambiguateCamelCased(
Expand Down

0 comments on commit eacf69f

Please sign in to comment.