Improved Vineflower support (#238)
* update decompiler flags for vineflower we want them to match up to mache * rename decompiler stuff to vineflower * fix style * Add back support for ForgeFlower for old dev bundles * Add missing check * ignore case * Fix comment * Rename method * Remove verify merges flag --------- Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
This commit is contained in:
parent
ad931e0d37
commit
9026a4ba27
4 changed files with 47 additions and 28 deletions
|
@ -60,7 +60,7 @@ open class AllTasks(
|
|||
includes.set(listOf("/data/**", "/assets/**", "version.json", "yggdrasil_session_pubkey.der", "pack.mcmeta", "flightrecorder-config.jfc"))
|
||||
}
|
||||
|
||||
val decompileJar by tasks.registering<RunForgeFlower> {
|
||||
val decompileJar by tasks.registering<RunVineFlower> {
|
||||
executable.from(project.configurations.named(DECOMPILER_CONFIG))
|
||||
|
||||
inputJar.set(copyResources.flatMap { it.outputJar })
|
||||
|
|
|
@ -401,7 +401,7 @@ abstract class GenerateDevBundle : DefaultTask() {
|
|||
private fun createDecompileRunner(): Runner {
|
||||
return Runner(
|
||||
dep = determineMavenDep(decompilerUrl, decompilerConfig),
|
||||
args = forgeFlowerArgList
|
||||
args = vineFlowerArgList
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ package io.papermc.paperweight.tasks
|
|||
import io.papermc.paperweight.util.*
|
||||
import io.papermc.paperweight.util.constants.*
|
||||
import java.nio.file.Path
|
||||
import java.util.jar.Attributes
|
||||
import java.util.jar.Manifest
|
||||
import kotlin.io.path.*
|
||||
import org.gradle.api.file.ConfigurableFileCollection
|
||||
import org.gradle.api.file.FileCollection
|
||||
|
@ -33,29 +35,30 @@ import org.gradle.api.provider.ListProperty
|
|||
import org.gradle.api.tasks.*
|
||||
import org.gradle.jvm.toolchain.JavaLauncher
|
||||
|
||||
val forgeFlowerArgList: List<String> = listOf(
|
||||
"-ind= ",
|
||||
"-din=1",
|
||||
"-rbr=1",
|
||||
"-dgs=1",
|
||||
"-asc=1",
|
||||
"-rsy=1",
|
||||
"-iec=1",
|
||||
"-jvn=0",
|
||||
"-isl=0",
|
||||
"-iib=1",
|
||||
"-bsm=1",
|
||||
"-dcl=1",
|
||||
"-ovr=0", // We add override annotations ourselves. Vineflower's impl doesn't work as well yet and conflicts
|
||||
"-pll=999999", // High line length to effectively disable formatter (only does anything on Vineflower)
|
||||
"-log=TRACE",
|
||||
"-cfg",
|
||||
val vineFlowerArgList: List<String> = listOf(
|
||||
"--synthetic-not-set=true",
|
||||
"--ternary-constant-simplification=true",
|
||||
"--include-runtime=current",
|
||||
"--decompile-complex-constant-dynamic=true",
|
||||
"--indent-string= ",
|
||||
"--decompile-inner=true", // is default
|
||||
"--remove-bridge=true", // is default
|
||||
"--decompile-generics=true", // is default
|
||||
"--ascii-strings=false", // is default
|
||||
"--remove-synthetic=true", // is default
|
||||
"--include-classpath=true",
|
||||
"--inline-simple-lambdas=true", // is default
|
||||
"--ignore-invalid-bytecode=false", // is default
|
||||
"--bytecode-source-mapping=true",
|
||||
"--dump-code-lines=true",
|
||||
"--override-annotation=false", // We add override annotations ourselves. Vineflower's impl doesn't work as well yet and conflicts
|
||||
"-cfg", // Pass the libraries as an argument file to avoid command line length limits
|
||||
"{libraries}",
|
||||
"{input}",
|
||||
"{output}"
|
||||
)
|
||||
|
||||
private fun List<String>.createForgeFlowerArgs(
|
||||
private fun List<String>.createDecompilerArgs(
|
||||
libraries: String,
|
||||
input: String,
|
||||
output: String,
|
||||
|
@ -68,7 +71,7 @@ private fun List<String>.createForgeFlowerArgs(
|
|||
}
|
||||
}
|
||||
|
||||
fun runForgeFlower(
|
||||
fun runDecompiler(
|
||||
argsList: List<String>,
|
||||
logFile: Path,
|
||||
workingDir: Path,
|
||||
|
@ -84,15 +87,20 @@ fun runForgeFlower(
|
|||
val tempFile = createTempFile("paperweight", "txt")
|
||||
|
||||
try {
|
||||
val vineflower = isVineflower(executable)
|
||||
tempFile.bufferedWriter().use { writer ->
|
||||
for (lib in libs) {
|
||||
if (lib.isLibraryJar) {
|
||||
if (vineflower) {
|
||||
writer.appendLine("--add-external=${lib.absolutePathString()}")
|
||||
} else {
|
||||
writer.appendLine("-e=${lib.absolutePathString()}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val argList = argsList.createForgeFlowerArgs(
|
||||
val argList = argsList.createDecompilerArgs(
|
||||
tempFile.absolutePathString(),
|
||||
inputJar.absolutePathString(),
|
||||
outputJar.absolutePathString(),
|
||||
|
@ -108,8 +116,19 @@ fun runForgeFlower(
|
|||
}
|
||||
}
|
||||
|
||||
private fun isVineflower(executable: FileCollection) = executable.files.any {
|
||||
it.toPath().openZip().use { fs ->
|
||||
val manifest = fs.getPath("META-INF/MANIFEST.MF").takeIf { f -> f.isRegularFile() }?.inputStream()?.buffered()?.use { reader ->
|
||||
Manifest(reader)
|
||||
}
|
||||
manifest != null &&
|
||||
manifest.mainAttributes.containsKey(Attributes.Name("Implementation-Name")) &&
|
||||
manifest.mainAttributes.getValue("Implementation-Name").equals("Vineflower", ignoreCase = true)
|
||||
}
|
||||
}
|
||||
|
||||
@CacheableTask
|
||||
abstract class RunForgeFlower : JavaLauncherTask() {
|
||||
abstract class RunVineFlower : JavaLauncherTask() {
|
||||
|
||||
@get:Classpath
|
||||
abstract val executable: ConfigurableFileCollection
|
||||
|
@ -135,8 +154,8 @@ abstract class RunForgeFlower : JavaLauncherTask() {
|
|||
|
||||
@TaskAction
|
||||
fun run() {
|
||||
runForgeFlower(
|
||||
forgeFlowerArgList,
|
||||
runDecompiler(
|
||||
vineFlowerArgList,
|
||||
layout.cache.resolve(paperTaskOutput("log")),
|
||||
layout.cache,
|
||||
executable,
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
package io.papermc.paperweight.userdev.internal.setup.step
|
||||
|
||||
import io.papermc.paperweight.tasks.runForgeFlower
|
||||
import io.papermc.paperweight.tasks.runDecompiler
|
||||
import io.papermc.paperweight.userdev.internal.setup.SetupHandler
|
||||
import io.papermc.paperweight.userdev.internal.setup.util.HashFunctionBuilder
|
||||
import io.papermc.paperweight.userdev.internal.setup.util.siblingHashesFile
|
||||
|
@ -44,7 +44,7 @@ class DecompileMinecraft(
|
|||
override val hashFile: Path = outputJar.siblingHashesFile()
|
||||
|
||||
override fun run(context: SetupHandler.Context) {
|
||||
runForgeFlower(
|
||||
runDecompiler(
|
||||
argsList = decompileArgs,
|
||||
logFile = outputJar.siblingLogFile(),
|
||||
workingDir = cache,
|
||||
|
|
Loading…
Reference in a new issue