Skip to content

Commit

Permalink
update to enigma 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ix0rai committed Dec 22, 2023
1 parent 300c5e4 commit 415ff5a
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
import java.util.Objects;

import com.google.common.collect.Streams;
import cuchaz.enigma.Enigma;
import cuchaz.enigma.EnigmaProfile;
import cuchaz.enigma.EnigmaProject;
import cuchaz.enigma.api.service.NameProposalService;
import cuchaz.enigma.command.Command;
import cuchaz.enigma.command.FillClassMappingsCommand;
import cuchaz.enigma.command.InsertProposedMappingsCommand;
import cuchaz.enigma.command.MappingCommandsUtil;
import cuchaz.enigma.translation.mapping.EntryMapping;
import cuchaz.enigma.translation.mapping.MappingDelta;
import cuchaz.enigma.translation.mapping.serde.MappingSaveParameters;
import cuchaz.enigma.translation.mapping.tree.DeltaTrackingTree;
import cuchaz.enigma.translation.mapping.tree.EntryTree;
import cuchaz.enigma.utils.Utils;
import org.quiltmc.enigma.api.Enigma;
import org.quiltmc.enigma.api.EnigmaProfile;
import org.quiltmc.enigma.api.EnigmaProject;
import org.quiltmc.enigma.api.service.NameProposalService;
import org.quiltmc.enigma.command.Command;
import org.quiltmc.enigma.command.FillClassMappingsCommand;
import org.quiltmc.enigma.command.InsertProposedMappingsCommand;
import org.quiltmc.enigma.command.MappingCommandsUtil;
import org.quiltmc.enigma.api.translation.mapping.EntryMapping;
import org.quiltmc.enigma.api.translation.mapping.MappingDelta;
import org.quiltmc.enigma.api.translation.mapping.serde.MappingSaveParameters;
import org.quiltmc.enigma.api.translation.mapping.tree.DeltaTrackingTree;
import org.quiltmc.enigma.api.translation.mapping.tree.EntryTree;
import org.quiltmc.enigma.util.Utils;
import net.fabricmc.mappingio.MappingWriter;
import net.fabricmc.mappingio.adapter.MappingDstNsReorder;
import net.fabricmc.mappingio.format.MappingFormat;
Expand Down Expand Up @@ -111,20 +111,20 @@ public static void addProposedMappings(Path input, Path output, Path tempDir, Pa

private static void runCommands(Path jar, Path input, Path output, String resultFormat, Path profilePath) throws Exception {
EnigmaProfile profile = EnigmaProfile.read(profilePath);
Enigma enigma = Command.createEnigma(profile);
Enigma enigma = Command.createEnigma(profile, null);

EnigmaProject project = Command.openProject(jar, input, enigma);
NameProposalService[] nameProposalServices = enigma.getServices().get(NameProposalService.TYPE).toArray(new NameProposalService[0]);

boolean debug = System.getProperty("qm.addProposedMappings.debug", "false").toLowerCase(Locale.ROOT).equals("true");
EntryTree<EntryMapping> withProposals = InsertProposedMappingsCommand.exec(nameProposalServices, project, debug);
EntryTree<EntryMapping> withProposals = InsertProposedMappingsCommand.exec(nameProposalServices, project);

// TODO: Disable fillAll after fixing the tiny v2 writer to avoid adding unnecessary class names
EntryTree<EntryMapping> result = FillClassMappingsCommand.exec(project.getJarIndex(), withProposals, true, debug);

Utils.delete(output);
MappingSaveParameters saveParameters = enigma.getProfile().getMappingSaveParameters();
MappingCommandsUtil.write(result, resultFormat, output, saveParameters);
MappingCommandsUtil.getWriter(resultFormat).write(result, output, saveParameters);

if (debug) {
Path debugFile = output.getParent().resolve(output.getFileName().toString() + "-delta.txt");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import java.io.IOException;
import java.nio.file.Path;

import cuchaz.enigma.command.MapSpecializedMethodsCommand;
import cuchaz.enigma.translation.mapping.serde.MappingParseException;
import org.quiltmc.enigma.command.MapSpecializedMethodsCommand;
import org.quiltmc.enigma.api.translation.mapping.serde.MappingParseException;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.tasks.InputDirectory;
import org.gradle.api.tasks.OutputFile;
Expand Down Expand Up @@ -45,7 +45,6 @@ public void execute() throws IOException, MappingParseException {
public static void buildMappingsTiny(Path perVersionMappingsJar, Path mappings, Path outputMappings) throws IOException, MappingParseException {
MapSpecializedMethodsCommand.run(
perVersionMappingsJar,
"enigma",
mappings,
String.format("tinyv2:%s:named", Constants.PER_VERSION_MAPPINGS_NAME),
outputMappings
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package quilt.internal.tasks.build;

import cuchaz.enigma.command.DropInvalidMappingsCommand;
import org.quiltmc.enigma.command.DropInvalidMappingsCommand;
import org.gradle.api.tasks.TaskAction;
import quilt.internal.Constants;
import quilt.internal.tasks.DefaultMappingsTask;
Expand Down
8 changes: 4 additions & 4 deletions buildSrc/src/main/java/quilt/internal/tasks/lint/Checker.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import java.util.Set;
import java.util.function.Function;

import cuchaz.enigma.translation.mapping.EntryMapping;
import cuchaz.enigma.translation.representation.AccessFlags;
import cuchaz.enigma.translation.representation.entry.Entry;
import cuchaz.enigma.translation.representation.entry.FieldEntry;
import org.quiltmc.enigma.api.translation.mapping.EntryMapping;
import org.quiltmc.enigma.api.translation.representation.AccessFlags;
import org.quiltmc.enigma.api.translation.representation.entry.Entry;
import org.quiltmc.enigma.api.translation.representation.entry.FieldEntry;

/**
* A checker checks mapping entries for formatting/convention errors and warnings.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package quilt.internal.tasks.lint;

import cuchaz.enigma.translation.mapping.EntryMapping;
import cuchaz.enigma.translation.representation.AccessFlags;
import cuchaz.enigma.translation.representation.entry.ClassEntry;
import cuchaz.enigma.translation.representation.entry.Entry;
import cuchaz.enigma.translation.representation.entry.FieldEntry;
import cuchaz.enigma.translation.representation.entry.MethodEntry;
import org.quiltmc.enigma.api.translation.mapping.EntryMapping;
import org.quiltmc.enigma.api.translation.representation.AccessFlags;
import org.quiltmc.enigma.api.translation.representation.entry.ClassEntry;
import org.quiltmc.enigma.api.translation.representation.entry.Entry;
import org.quiltmc.enigma.api.translation.representation.entry.FieldEntry;
import org.quiltmc.enigma.api.translation.representation.entry.MethodEntry;

import java.util.function.Function;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import java.util.Locale;
import java.util.function.Function;

import cuchaz.enigma.translation.mapping.EntryMapping;
import cuchaz.enigma.translation.representation.AccessFlags;
import cuchaz.enigma.translation.representation.TypeDescriptor;
import cuchaz.enigma.translation.representation.entry.Entry;
import cuchaz.enigma.translation.representation.entry.FieldEntry;
import org.quiltmc.enigma.api.translation.mapping.EntryMapping;
import org.quiltmc.enigma.api.translation.representation.AccessFlags;
import org.quiltmc.enigma.api.translation.representation.TypeDescriptor;
import org.quiltmc.enigma.api.translation.representation.entry.Entry;
import org.quiltmc.enigma.api.translation.representation.entry.FieldEntry;

public final class FieldNamingChecker implements Checker<FieldEntry> {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package quilt.internal.tasks.lint;

import cuchaz.enigma.translation.mapping.EntryMapping;
import cuchaz.enigma.translation.representation.AccessFlags;
import cuchaz.enigma.translation.representation.entry.Entry;
import cuchaz.enigma.translation.representation.entry.LocalVariableEntry;
import cuchaz.enigma.translation.representation.entry.MethodEntry;
import org.quiltmc.enigma.api.translation.mapping.EntryMapping;
import org.quiltmc.enigma.api.translation.representation.AccessFlags;
import org.quiltmc.enigma.api.translation.representation.entry.Entry;
import org.quiltmc.enigma.api.translation.representation.entry.LocalVariableEntry;
import org.quiltmc.enigma.api.translation.representation.entry.MethodEntry;

import java.util.function.Function;
import java.util.regex.Pattern;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
import java.util.Set;
import java.util.function.Function;

import cuchaz.enigma.Enigma;
import cuchaz.enigma.EnigmaProject;
import cuchaz.enigma.ProgressListener;
import cuchaz.enigma.analysis.index.EntryIndex;
import cuchaz.enigma.classprovider.ClasspathClassProvider;
import cuchaz.enigma.translation.mapping.EntryMapping;
import cuchaz.enigma.translation.mapping.serde.MappingParseException;
import cuchaz.enigma.translation.mapping.serde.enigma.EnigmaMappingsReader;
import cuchaz.enigma.translation.mapping.tree.EntryTree;
import cuchaz.enigma.translation.representation.AccessFlags;
import cuchaz.enigma.translation.representation.entry.ClassEntry;
import cuchaz.enigma.translation.representation.entry.Entry;
import cuchaz.enigma.translation.representation.entry.MethodEntry;
import org.quiltmc.enigma.api.Enigma;
import org.quiltmc.enigma.api.EnigmaProject;
import org.quiltmc.enigma.api.ProgressListener;
import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex;
import org.quiltmc.enigma.api.class_provider.ClasspathClassProvider;
import org.quiltmc.enigma.api.translation.mapping.EntryMapping;
import org.quiltmc.enigma.api.translation.mapping.serde.MappingParseException;
import org.quiltmc.enigma.api.translation.mapping.serde.enigma.EnigmaMappingsReader;
import org.quiltmc.enigma.api.translation.mapping.tree.EntryTree;
import org.quiltmc.enigma.api.translation.representation.AccessFlags;
import org.quiltmc.enigma.api.translation.representation.entry.ClassEntry;
import org.quiltmc.enigma.api.translation.representation.entry.Entry;
import org.quiltmc.enigma.api.translation.representation.entry.MethodEntry;
import javax.inject.Inject;
import org.gradle.api.GradleException;
import org.gradle.api.file.ConfigurableFileCollection;
Expand Down Expand Up @@ -154,9 +154,9 @@ public void execute() {
Enigma enigma = Enigma.create();
EnigmaProject project = enigma.openJar(params.getJarFile().get().getAsFile().toPath(), new ClasspathClassProvider(), ProgressListener.none());
EntryTree<EntryMapping> mappings = readMappings(getParameters().getMappingFiles());
project.setMappings(mappings);
project.setMappings(mappings, ProgressListener.none());
Function<Entry<?>, AccessFlags> accessProvider = entry -> {
EntryIndex index = project.getJarIndex().getEntryIndex();
EntryIndex index = project.getJarIndex().getIndex(EntryIndex.class);

if (entry instanceof ClassEntry c) {
return index.getClassAccess(c);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;

import cuchaz.enigma.translation.mapping.EntryMapping;
import cuchaz.enigma.translation.representation.AccessFlags;
import cuchaz.enigma.translation.representation.entry.ClassEntry;
import cuchaz.enigma.translation.representation.entry.Entry;
import cuchaz.enigma.translation.representation.entry.MethodEntry;
import org.quiltmc.enigma.api.translation.mapping.EntryMapping;
import org.quiltmc.enigma.api.translation.representation.AccessFlags;
import org.quiltmc.enigma.api.translation.representation.entry.ClassEntry;
import org.quiltmc.enigma.api.translation.representation.entry.Entry;
import org.quiltmc.enigma.api.translation.representation.entry.MethodEntry;

public class SpellingChecker implements Checker<Entry<?>> {
private static final String PACKAGE_INFO_CLASS_PACKAGE = "net/minecraft/unused/packageinfo/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class EnigmaMappingsTask extends JavaExec implements MappingsTask {
public EnigmaMappingsTask() {
this.setGroup(Constants.Groups.MAPPINGS_GROUP);
this.getMainClass().set("cuchaz.enigma.gui.Main");
this.getMainClass().set("org.quiltmc.enigma.gui.Main");
this.classpath(getProject().getConfigurations().getByName("enigmaRuntime"));
jarToMap = getObjectFactory().fileProperty();
jvmArgs("-Xmx2048m");
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ download_task = "4.1.1"
guava = "31.1-jre"
jackson_xml = "2.14.1"
launchermeta_parser = "1.0.0"
enigma = "1.9.0"
enigma_plugin = "1.4.0"
enigma = "2.0.0+local"
enigma_plugin = "1.5.0+local"
tiny_remapper = "0.7.2"
stitch = "0.6.1"
unpick = "3.0.6"
Expand Down

0 comments on commit 415ff5a

Please sign in to comment.