Skip to content

Commit b04de02

Browse files
Abduqodiri Qurbonzodaqurbonzoda
authored andcommitted
Annotate NativeBenchmarkExec properties appropriately
1 parent 4c81038 commit b04de02

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

plugin/main/src/kotlinx/benchmark/gradle/NativeMultiplatformTasks.kt

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,18 @@ fun Project.createNativeBenchmarkExecTask(
115115
val linkTask = binary.linkTask
116116
onlyIf { linkTask.enabled }
117117

118+
dependsOn(linkTask)
119+
118120
val executableFile = linkTask.outputFile.get()
119-
executable = executableFile.absolutePath
120-
this.config = config
121-
this.workingDir = target.workingDir?.let { File(it) }
121+
onlyIf { executableFile.exists() }
122+
123+
this.executable = executableFile
124+
this.nativeFork = config.nativeFork
125+
this.workingDir = target.workingDir
122126
this.benchProgressPath = createTempFile("bench", ".txt").absolutePath
123127

124-
onlyIf { executableFile.exists() }
125128
benchsDescriptionDir = file(project.buildDir.resolve(target.extension.benchsDescriptionDir).resolve(config.name))
126129

127-
dependsOn(linkTask)
128-
129130
reportFile = setupReporting(target, config)
130131
configFile = writeParameters(target.name, reportFile, traceFormat(), config)
131132

@@ -141,32 +142,36 @@ open class NativeBenchmarkExec() : DefaultTask() {
141142
@Option(option = "filter", description = "Configures the filter for benchmarks to run.")
142143
var filter: String? = null
143144
*/
144-
@Input
145-
lateinit var executable: String
146-
147-
var workingDir: File? = null
145+
@InputFile
146+
lateinit var executable: File
148147

149148
@Input
149+
@Optional
150+
var workingDir: String? = null
151+
152+
@InputFile
150153
lateinit var configFile: File
151154

152155
@Input
153-
lateinit var config: BenchmarkConfiguration
156+
@Optional
157+
var nativeFork: String? = null
154158

155-
@Input
159+
@OutputFile
156160
lateinit var reportFile: File
157161

158-
@Input
162+
@Internal
159163
lateinit var benchsDescriptionDir: File
160164

161-
@Input
165+
@Internal
162166
lateinit var benchProgressPath: String
163167

164168
private fun execute(args: Collection<String>) {
165169
project.exec {
166-
it.executable = executable
170+
it.executable = executable.absolutePath
167171
it.args(args)
168-
if (workingDir != null)
169-
it.workingDir = workingDir
172+
workingDir?.let { dir ->
173+
it.workingDir = File(dir)
174+
}
170175
}
171176
}
172177

@@ -178,7 +183,7 @@ open class NativeBenchmarkExec() : DefaultTask() {
178183
val detailedConfigFiles = project.fileTree(benchsDescriptionDir).files.sortedBy { it.absolutePath }
179184
val runResults = mutableMapOf<String, String>()
180185

181-
val forkPerBenchmark = config.nativeFork.let { it == null || it == "perBenchmark" }
186+
val forkPerBenchmark = nativeFork.let { it == null || it == "perBenchmark" }
182187

183188
detailedConfigFiles.forEach { runConfig ->
184189
val runConfigPath = runConfig.absolutePath

0 commit comments

Comments
 (0)