mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-04 23:53:01 +00:00
Update to Gradle 8.x
- Update to Loom 1.2 and FG 6.0. ForgeGradle has changed how it generates the runXyz tasks, which makes running our tests much harder. I've raised an issue upstream, but for now we do some nasty poking of internals. - Fix Sodium/Iris tests. Loom 1.1 changed how remapped configurations are generated - we create a dummy source set and associate the remapped configuration with that. All nasty stuff. - Publish the common library. I'm not a fan of this, but given how much internals I'm poking elsewhere, should probably get off my high horse. - Add renderdoc support to the client gametests, enabled with -Prenderdoc.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
// SPDX-FileCopyrightText: 2023 The CC: Tweaked Developers
|
||||
//
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package cc.tweaked.gradle
|
||||
|
||||
import net.minecraftforge.gradle.common.util.RunConfig
|
||||
import net.minecraftforge.gradle.common.util.runs.setRunConfigInternal
|
||||
import org.gradle.api.plugins.JavaPluginExtension
|
||||
import org.gradle.api.tasks.JavaExec
|
||||
import org.gradle.jvm.toolchain.JavaToolchainService
|
||||
import java.nio.file.Files
|
||||
|
||||
/**
|
||||
* Set [JavaExec] task to run a given [RunConfig].
|
||||
*/
|
||||
fun JavaExec.setRunConfig(config: RunConfig) {
|
||||
dependsOn("prepareRuns")
|
||||
setRunConfigInternal(project, this, config)
|
||||
doFirst("Create working directory") { Files.createDirectories(workingDir.toPath().parent) }
|
||||
|
||||
javaLauncher.set(
|
||||
project.extensions.getByType(JavaToolchainService::class.java)
|
||||
.launcherFor(project.extensions.getByType(JavaPluginExtension::class.java).toolchain),
|
||||
)
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class IlluaminatePlugin : Plugin<Project> {
|
||||
|
||||
/** Define a dependency for illuaminate from a version number and the current operating system. */
|
||||
private fun illuaminateArtifact(project: Project, version: String): Dependency {
|
||||
val osName = System.getProperty("os.name").toLowerCase()
|
||||
val osName = System.getProperty("os.name").lowercase()
|
||||
val (os, suffix) = when {
|
||||
osName.contains("windows") -> Pair("windows", ".exe")
|
||||
osName.contains("mac os") || osName.contains("darwin") -> Pair("macos", "")
|
||||
@@ -68,7 +68,7 @@ class IlluaminatePlugin : Plugin<Project> {
|
||||
else -> error("Unsupported OS $osName for illuaminate")
|
||||
}
|
||||
|
||||
val osArch = System.getProperty("os.arch").toLowerCase()
|
||||
val osArch = System.getProperty("os.arch").lowercase()
|
||||
val arch = when {
|
||||
// On macOS the x86_64 binary will work for both ARM and Intel Macs through Rosetta.
|
||||
os == "macos" -> "x86_64"
|
||||
|
||||
@@ -32,11 +32,14 @@ abstract class ClientJavaExec : JavaExec() {
|
||||
usesService(clientRunner)
|
||||
}
|
||||
|
||||
@get:Input
|
||||
val renderdoc get() = project.hasProperty("renderdoc")
|
||||
|
||||
/**
|
||||
* When [false], tests will not be run automatically, allowing the user to debug rendering.
|
||||
*/
|
||||
@get:Input
|
||||
val clientDebug get() = project.hasProperty("clientDebug")
|
||||
val clientDebug get() = renderdoc || project.hasProperty("clientDebug")
|
||||
|
||||
/**
|
||||
* When [false], tests will not run under a framebuffer.
|
||||
@@ -63,6 +66,7 @@ abstract class ClientJavaExec : JavaExec() {
|
||||
task.copyToFull(this)
|
||||
|
||||
if (!clientDebug) systemProperty("cctest.client", "")
|
||||
if (renderdoc) environment("LD_PRELOAD", "/usr/lib/librenderdoc.so")
|
||||
systemProperty("cctest.gametest-report", testResults.get().asFile.absoluteFile)
|
||||
workingDir(project.buildDir.resolve("gametest").resolve(name))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
// SPDX-FileCopyrightText: 2023 The CC: Tweaked Developers
|
||||
//
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package net.minecraftforge.gradle.common.util.runs
|
||||
|
||||
import net.minecraftforge.gradle.common.util.RunConfig
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.process.JavaExecSpec
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Set up a [JavaExecSpec] to execute a [RunConfig].
|
||||
*
|
||||
* [MinecraftRunTask] sets up all its properties when the task is executed, rather than when configured. As such, it's
|
||||
* not possible to use [cc.tweaked.gradle.copyToFull] like we do for Fabric. Instead, we set up the task manually.
|
||||
*
|
||||
* Unfortunately most of the functionality we need is package-private, and so we have to put our code into the package.
|
||||
*/
|
||||
internal fun setRunConfigInternal(project: Project, spec: JavaExecSpec, config: RunConfig) {
|
||||
val originalTask = project.tasks.named(config.taskName, MinecraftRunTask::class.java).get()
|
||||
|
||||
spec.workingDir = File(config.workingDirectory)
|
||||
|
||||
spec.mainClass.set(config.main)
|
||||
for (source in config.allSources) spec.classpath(source.runtimeClasspath)
|
||||
|
||||
val lazyTokens = RunConfigGenerator.configureTokensLazy(
|
||||
project, config,
|
||||
RunConfigGenerator.mapModClassesToGradle(project, config),
|
||||
originalTask.minecraftArtifacts.files,
|
||||
originalTask.runtimeClasspathArtifacts.files,
|
||||
)
|
||||
|
||||
spec.args(RunConfigGenerator.getArgsStream(config, lazyTokens, false).toList())
|
||||
|
||||
spec.jvmArgs(
|
||||
(if (config.isClient) config.jvmArgs + originalTask.additionalClientArgs.get() else config.jvmArgs)
|
||||
.map { config.replace(lazyTokens, it) },
|
||||
)
|
||||
|
||||
for ((key, value) in config.environment) spec.environment(key, config.replace(lazyTokens, value))
|
||||
for ((key, value) in config.properties) spec.systemProperty(key, config.replace(lazyTokens, value))
|
||||
}
|
||||
Reference in New Issue
Block a user