mirror of https://github.com/FabricMC/yarn.git
Manually adding signature back for records to aid decompilers and javadoc gen (#2683)
* Manually adding signature back for records to aid decompilers and javadoc gen Signed-off-by: liach <liach@users.noreply.github.com> * Fix more bad notations Now fake source errors are only packages + cannot extend record Signed-off-by: liach <liach@users.noreply.github.com> * Export signatures to extras/record_signatures.json Signed-off-by: liach <liach@users.noreply.github.com> * Add newline * Load the map immediately into memory than lazily Co-authored-by: liach <liach@users.noreply.github.com>
This commit is contained in:
parent
61372ae755
commit
544daf01e8
34
build.gradle
34
build.gradle
|
@ -98,7 +98,7 @@ def clientJar = new File(cacheFilesMinecraft, "${minecraft_version}-client.jar")
|
|||
def serverJar = new File(cacheFilesMinecraft, "${minecraft_version}-server.jar")
|
||||
def libraries = new File(cacheFilesMinecraft, "libraries")
|
||||
def libs = new File("build/libs/")
|
||||
|
||||
def recordSignaturesJson = file("record_signatures.json")
|
||||
|
||||
import com.google.common.hash.Hashing
|
||||
import cuchaz.enigma.command.CheckMappingsCommand
|
||||
|
@ -119,6 +119,8 @@ import net.fabricmc.tinyremapper.OutputConsumerPath
|
|||
import net.fabricmc.tinyremapper.TinyRemapper
|
||||
import net.fabricmc.tinyremapper.TinyUtils
|
||||
import org.apache.commons.io.FileUtils
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.util.zip.GZIPOutputStream
|
||||
|
@ -373,10 +375,28 @@ task mapIntermediaryJar(dependsOn: [downloadMcLibs, downloadIntermediary, mergeJ
|
|||
//Force the task to always run
|
||||
outputs.upToDateWhen { false }
|
||||
|
||||
def brokenSignatures = new HashMap((Map) new JsonSlurper().parse(recordSignaturesJson))
|
||||
|
||||
doLast {
|
||||
logger.lifecycle(":mapping minecraft to intermediary")
|
||||
def tinyInput = downloadIntermediary.dest
|
||||
mapJar(intermediaryJar, mergedFile, tinyInput, libraries, "official", "intermediary")
|
||||
mapJar(intermediaryJar, mergedFile, tinyInput, libraries, "official", "intermediary") { remapperBuilder ->
|
||||
// Fix the broken record signatures
|
||||
remapperBuilder.extraPostApplyVisitor { cls, next ->
|
||||
return new ClassVisitor(Opcodes.ASM9, next) {
|
||||
@Override
|
||||
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
|
||||
if (signature == null) {
|
||||
signature = brokenSignatures.getOrDefault(name, null);
|
||||
if (signature != null) {
|
||||
logger.lifecycle("replacing signature for " + name);
|
||||
}
|
||||
}
|
||||
super.visit(version, access, name, signature, superName, interfaces);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -758,6 +778,9 @@ task v2UnmergedYarnJar(dependsOn: [insertAutoGeneratedEnumMappings, combineUnpic
|
|||
expand version: project.unpick_version
|
||||
rename unpickMetaFile.name, "extras/unpick.json"
|
||||
}
|
||||
from(recordSignaturesJson) {
|
||||
into "extras/"
|
||||
}
|
||||
destinationDirectory.set(file("build/libs"))
|
||||
}
|
||||
|
||||
|
@ -777,6 +800,9 @@ task v2MergedYarnJar(dependsOn: ["mergeV2"], type: Jar) {
|
|||
expand version: project.unpick_version
|
||||
rename unpickMetaFile.name, "extras/unpick.json"
|
||||
}
|
||||
from(recordSignaturesJson) {
|
||||
into "extras/"
|
||||
}
|
||||
destinationDirectory.set(file("build/libs"))
|
||||
}
|
||||
|
||||
|
@ -971,7 +997,9 @@ void mapJar(File output, File input, File mappings, File libraries, String from,
|
|||
.build()
|
||||
|
||||
try {
|
||||
def outputConsumer = new OutputConsumerPath(output.toPath())
|
||||
def outputConsumerBuilder = new OutputConsumerPath.Builder(output.toPath())
|
||||
// expose output consumer builder to function if there is need in the future
|
||||
def outputConsumer = outputConsumerBuilder.build()
|
||||
outputConsumer.addNonClassFiles(input.toPath())
|
||||
remapper.readInputs(input.toPath())
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"net/minecraft/class_2841$class_6561": "<T:Ljava/lang/Object;>Ljava/lang/Record;",
|
||||
"net/minecraft/class_2841$class_6562": "<T:Ljava/lang/Object;>Ljava/lang/Record;",
|
||||
"net/minecraft/class_6497": "<T::Ljava/lang/Comparable<TT;>;>Ljava/lang/Record;",
|
||||
"net/minecraft/class_6535": "<T::Lnet/minecraft/class_6534;>Ljava/lang/Record;",
|
||||
"net/minecraft/class_2769$class_4933": "<T::Ljava/lang/Comparable<TT;>;>Ljava/lang/Record;"
|
||||
}
|
Loading…
Reference in New Issue