Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method hierarchy propagation via MIO and Hypo #4123

Open
wants to merge 1 commit into
base: 25w07a
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ import net.fabricmc.filament.task.mappingio.FormatMappingsTask
import net.fabricmc.filament.task.mappingio.MergeMappingsTask
import net.fabricmc.filament.task.mappingio.CheckMappingsTask
import net.fabricmc.filament.task.mappingio.CheckMergedMappingsTask
import net.fabricmc.filament.task.mappingio.PropagateHierarchyTask
import net.fabricmc.filament.nameproposal.MappingNameCompleter
import net.fabricmc.mappingio.format.MappingFormat
import org.gradle.work.DisableCachingByDefault
Expand Down Expand Up @@ -185,14 +186,24 @@ tasks.register('mapSpecializedMethods', MapSpecializedMethodsTask) {
outputMappingsFormat = "tinyv2:intermediary:named"
}

tasks.register('propagateNames', PropagateHierarchyTask) {
intermediaryJarFile = mapIntermediaryJar.output
mappingsDirectory = mappingsDir
srcNamespace = "intermediary"
dstNamespace = "named"
classpath.from minecraftLibraries
output = new File(tempDir, "yarn-propagated-v2.tiny")
outputFormat = MappingFormat.TINY_2_FILE
}

tasks.register('completeMappings', CompleteMappingsTask) {
input = mapSpecializedMethods.output
input = propagateNames.output
output = new File(tempDir, "yarn-mappings-v2.tiny")
outputFormat = MappingFormat.TINY_2_FILE
}

tasks.register('convertToV1', ConvertMappingsTask) {
input = mapSpecializedMethods.output
input = propagateNames.output
output = new File(tempDir, "yarn-mappings.tiny")
outputFormat = MappingFormat.TINY_FILE
}
Expand Down
17 changes: 12 additions & 5 deletions filament/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,26 @@ repositories {
}

dependencies {
implementation "org.ow2.asm:asm:${properties.asm_version}"
implementation "org.ow2.asm:asm-tree:${properties.asm_version}"
implementation "org.ow2.asm:asm:$properties.asm_version"
implementation "org.ow2.asm:asm-tree:$properties.asm_version"
implementation "cuchaz:enigma:$properties.enigma_version"
implementation "cuchaz:enigma-cli:$properties.enigma_version"
implementation "net.fabricmc.unpick:unpick:$properties.unpick_version"
implementation "net.fabricmc.unpick:unpick-format-utils:$properties.unpick_version"
implementation "net.fabricmc.unpick:unpick-cli:$properties.unpick_version"
implementation "net.fabricmc:tiny-remapper:$properties.tiny_remapper_version"
implementation 'net.fabricmc:mapping-io:0.6.1'
implementation 'net.fabricmc:javapoet:0.1.1'
implementation "net.fabricmc:mapping-io:$properties.mappingio_version"
implementation "net.fabricmc:javapoet:$properties.javapoet_version"

implementation platform("dev.denwav.hypo:hypo-platform:$properties.hypo_version")
implementation 'dev.denwav.hypo:hypo-model'
implementation 'dev.denwav.hypo:hypo-core'
implementation 'dev.denwav.hypo:hypo-hydrate'
implementation 'dev.denwav.hypo:hypo-asm'
implementation 'dev.denwav.hypo:hypo-asm-hydrate'

// Contains a number of useful utilities we can re-use.
implementation ("net.fabricmc:fabric-loom:1.7.3") {
implementation ("net.fabricmc:fabric-loom:$properties.loom_version") {
transitive = false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import net.fabricmc.filament.task.base.WithFileOutput;

@Deprecated(forRemoval = true)
public abstract class MapSpecializedMethodsTask extends EnigmaCommandTask implements WithFileOutput {
@InputFile
public abstract RegularFileProperty getIntermediaryJarFile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.gradle.api.tasks.TaskAction;
import org.jetbrains.annotations.Nullable;
Expand All @@ -27,10 +25,7 @@ public final void run() throws IOException {
List<String> errors = new ArrayList<>();

MappingReader.read(path, new MappingVisitor() {
private final Set<String> mthDstNames = new HashSet<>();
private String clsSrcName;
private String mthSrcName;
private String mthSrcDesc;

@Override
public void visitNamespaces(String srcNamespace, List<String> dstNamespaces) throws IOException {
Expand All @@ -57,9 +52,10 @@ public boolean visitField(String srcName, @Nullable String srcDesc) throws IOExc

@Override
public boolean visitMethod(String srcName, @Nullable String srcDesc) throws IOException {
mthSrcName = srcName;
mthSrcDesc = srcDesc;
mthDstNames.clear();
if (srcName.startsWith("method_")) {
errors.add("Encountered mapping for non-existent method " + clsSrcName + "#" + srcName + srcDesc);
}

return true;
}

Expand All @@ -75,25 +71,6 @@ public boolean visitMethodVar(int lvtRowIndex, int lvIndex, int startOpIdx, int

@Override
public void visitDstName(MappedElementKind targetKind, int namespace, String name) throws IOException {
if (targetKind == MappedElementKind.METHOD) {
mthDstNames.add(name);
}
}

@Override
public boolean visitElementContent(MappedElementKind targetKind) throws IOException {
if (targetKind == MappedElementKind.METHOD) {
// Checking if the srcName is an intermediary name (like for classes and fields) would be the more correct option,
// but Enigma's bridge method mapper behaves weirdly and injects copies of the mapping into the whole hierarchy.
// We haven't been able to fix this yet, so in the meantime, we're using the following workaround,
// which ignores any Enigma-bridge-mapper generated mappings, but should still catch all other
// mappings without official names.
if (mthDstNames.size() == 1 && mthDstNames.contains(mthSrcName) && mthSrcName.startsWith("method_")) {
errors.add("Encountered mapping for non-existent method " + clsSrcName + "#" + mthSrcName + mthSrcDesc);
}
}

return true;
}

@Override
Expand Down
Loading
Loading