Fix a few issues in RemapPatches
This commit is contained in:
parent
5978cca674
commit
739958f3ec
4 changed files with 51 additions and 37 deletions
|
@ -516,27 +516,39 @@ class Paperweight : Plugin<Project> {
|
|||
atFile.set(spigotTasks.mergeGeneratedAts.flatMap { it.outputFile })
|
||||
}
|
||||
|
||||
/*
|
||||
* To ease the waiting time for debugging this task, all of the task dependencies have been removed (notice all
|
||||
* of those .get() calls). This means when you make changes to paperweight Gradle won't know that this task
|
||||
* technically depends on the output of all of those other tasks.
|
||||
*
|
||||
* In order to run all of the other necessary tasks before running this task in order to setup the inputs, run:
|
||||
*
|
||||
* ./gradlew patchPaper applyVanillaSrgAt
|
||||
*
|
||||
* Then you should be able to run `./gradlew remapPatches` without having to worry about all of the other tasks
|
||||
* running whenever you make changes to paperweight.
|
||||
*/
|
||||
val remapPatches by tasks.registering<RemapPatches> {
|
||||
group = "Paper"
|
||||
description = "EXPERIMENTAL & BROKEN: Attempt to remap Paper's patches from Spigot mappings to SRG."
|
||||
|
||||
inputPatchDir.set(extension.paper.unmappedSpigotServerPatchDir)
|
||||
sourceJar.set(spigotTasks.remapSpigotSources.flatMap { it.outputZip })
|
||||
sourceJar.set(spigotTasks.remapSpigotSources.flatMap { it.outputZip }.get())
|
||||
apiPatchDir.set(extension.paper.spigotApiPatchDir)
|
||||
|
||||
mappingsFile.set(spigotTasks.generateSpigotSrgs.flatMap { it.spigotToSrg })
|
||||
mappingsFile.set(spigotTasks.generateSpigotSrgs.flatMap { it.spigotToSrg }.get())
|
||||
|
||||
// Pull in as many jars as possible to reduce the possibility of type bindings not resolving
|
||||
classpathJars.add(generalTasks.downloadServerJar.flatMap { it.outputJar })
|
||||
classpathJars.add(spigotTasks.remapSpigotSources.flatMap { it.vanillaRemappedSpigotJar })
|
||||
classpathJars.add(applyVanillaSrgAt.flatMap { it.outputJar })
|
||||
classpathJars.add(generalTasks.downloadServerJar.flatMap { it.outputJar }.get())
|
||||
classpathJars.add(spigotTasks.remapSpigotSources.flatMap { it.vanillaRemappedSpigotJar }.get())
|
||||
classpathJars.add(applyVanillaSrgAt.flatMap { it.outputJar }.get())
|
||||
|
||||
spigotApiDir.set(spigotTasks.patchSpigotApi.flatMap { it.outputDir })
|
||||
spigotServerDir.set(spigotTasks.patchSpigotServer.flatMap { it.outputDir })
|
||||
spigotDecompJar.set(spigotTasks.decompileVanillaJarSpigot.flatMap { it.outputJar })
|
||||
constructors.set(initialTasks.extractMcp.flatMap { it.constructors })
|
||||
spigotApiDir.set(spigotTasks.patchSpigotApi.flatMap { it.outputDir }.get())
|
||||
spigotServerDir.set(spigotTasks.patchSpigotServer.flatMap { it.outputDir }.get())
|
||||
spigotDecompJar.set(spigotTasks.decompileVanillaJarSpigot.flatMap { it.outputJar }.get())
|
||||
constructors.set(initialTasks.extractMcp.flatMap { it.constructors }.get())
|
||||
|
||||
parameterNames.set(spigotTasks.remapSpigotSources.flatMap { it.parameterNames })
|
||||
parameterNames.set(spigotTasks.remapSpigotSources.flatMap { it.parameterNames }.get())
|
||||
|
||||
outputPatchDir.set(extension.paper.remappedSpigotServerPatchDir)
|
||||
}
|
||||
|
|
|
@ -54,15 +54,15 @@ abstract class ApplySourceAt : ZippedTask() {
|
|||
|
||||
val at = AccessTransformFormats.FML.read(atFile.path)
|
||||
|
||||
Mercury().apply {
|
||||
classPath.addAll(listOf(
|
||||
Mercury().let { merc ->
|
||||
merc.classPath.addAll(listOf(
|
||||
vanillaJar.path,
|
||||
vanillaRemappedSrgJar.path
|
||||
))
|
||||
|
||||
processors.add(AccessTransformerRewriter.create(at))
|
||||
merc.processors.add(AccessTransformerRewriter.create(at))
|
||||
|
||||
rewrite(inputDir.toPath(), outputDir.toPath())
|
||||
merc.rewrite(inputDir.toPath(), outputDir.toPath())
|
||||
}
|
||||
|
||||
// Remove input files
|
||||
|
|
|
@ -47,15 +47,15 @@ class PatchSourceRemapWorker(
|
|||
fun remap() {
|
||||
setup()
|
||||
|
||||
Mercury().apply {
|
||||
classPath.addAll(classpath)
|
||||
Mercury().let { merc ->
|
||||
merc.classPath.addAll(classpath)
|
||||
|
||||
processors.addAll(listOf(
|
||||
merc.processors.addAll(listOf(
|
||||
MercuryRemapper.create(reverseMappings),
|
||||
PatchParameterRemapper(paramNames, constructorsData)
|
||||
))
|
||||
|
||||
rewrite(inputDir, outputDir)
|
||||
merc.rewrite(inputDir, outputDir)
|
||||
}
|
||||
|
||||
cleanup()
|
||||
|
@ -64,33 +64,35 @@ class PatchSourceRemapWorker(
|
|||
fun remapBack() {
|
||||
setup()
|
||||
|
||||
Mercury().apply {
|
||||
classPath.addAll(classpath)
|
||||
Mercury().let { merc ->
|
||||
merc.classPath.addAll(classpath)
|
||||
|
||||
processors.addAll(listOf(
|
||||
merc.processors.addAll(listOf(
|
||||
MercuryRemapper.create(mappings),
|
||||
SrgParameterRemapper(mappings, constructorsData, paramNames)
|
||||
))
|
||||
|
||||
rewrite(inputDir, outputDir)
|
||||
merc.rewrite(inputDir, outputDir)
|
||||
}
|
||||
|
||||
cleanup()
|
||||
}
|
||||
|
||||
private fun setup() {
|
||||
Files.walk(outputDir).use { it.forEach(Files::delete) }
|
||||
outputDir.deleteRecursively()
|
||||
Files.createDirectories(outputDir)
|
||||
}
|
||||
|
||||
private fun cleanup() {
|
||||
Files.walk(inputDir).use { it.forEach(Files::delete) }
|
||||
Files.walk(outputDir).use {
|
||||
it.forEach { src ->
|
||||
val dest = inputDir.resolve(outputDir.relativize(src))
|
||||
Files.createDirectories(dest.parent)
|
||||
Files.copy(src, dest, REPLACE_EXISTING)
|
||||
}
|
||||
inputDir.deleteRecursively()
|
||||
Files.move(outputDir, inputDir)
|
||||
outputDir.deleteRecursively()
|
||||
}
|
||||
|
||||
private fun Path.deleteRecursively() {
|
||||
if (Files.notExists(this)) {
|
||||
return
|
||||
}
|
||||
Files.walk(this).use { stream -> stream.sorted(Comparator.reverseOrder()).forEach(Files::delete) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,8 +84,8 @@ abstract class RemapSources : ZippedTask() {
|
|||
val processAt = AccessTransformSet.create()
|
||||
|
||||
// Remap any references Spigot maps to SRG
|
||||
Mercury().apply {
|
||||
classPath.addAll(listOf(
|
||||
Mercury().let { merc ->
|
||||
merc.classPath.addAll(listOf(
|
||||
vanillaJar.path,
|
||||
vanillaRemappedSpigotJar.path,
|
||||
spigotApiDir.path.resolve("src/main/java"),
|
||||
|
@ -93,19 +93,19 @@ abstract class RemapSources : ZippedTask() {
|
|||
*spigotServerDeps.get().asFileTree.files.map { it.toPath() }.toTypedArray()
|
||||
))
|
||||
|
||||
processors += AccessAnalyzerProcessor.create(processAt, mappingSet)
|
||||
merc.processors += AccessAnalyzerProcessor.create(processAt, mappingSet)
|
||||
|
||||
process(srcDir.toPath())
|
||||
merc.process(srcDir.toPath())
|
||||
|
||||
processors.clear()
|
||||
processors.addAll(listOf(
|
||||
merc.processors.clear()
|
||||
merc.processors.addAll(listOf(
|
||||
MercuryRemapper.create(mappingSet),
|
||||
BridgeMethodRewriter.create(),
|
||||
AccessTransformerRewriter.create(processAt),
|
||||
SrgParameterRemapper(mappingSet, constructorsData, paramNames)
|
||||
))
|
||||
|
||||
rewrite(srcDir.toPath(), rootDir.toPath())
|
||||
merc.rewrite(srcDir.toPath(), rootDir.toPath())
|
||||
}
|
||||
|
||||
AccessTransformFormats.FML.write(generatedAt.path, processAt)
|
||||
|
|
Loading…
Reference in a new issue