mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 13:37:45 -05:00
Switch back to Atlas
This commit is contained in:
@@ -37,7 +37,6 @@ import java.nio.file.StandardCopyOption;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.google.common.net.UrlEscapers;
|
||||
import cuchaz.enigma.command.ComposeMappingsCommand;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.tools.ant.util.StringUtils;
|
||||
import org.gradle.api.Project;
|
||||
@@ -122,13 +121,13 @@ public class MappingsProvider extends DependencyProvider {
|
||||
Files.createDirectories(mappingsStepsDir);
|
||||
|
||||
String[] depStringSplit = dependency.getDepString().split(":");
|
||||
String jarClassifier = "final-srg";
|
||||
String jarClassifier = "final";
|
||||
|
||||
if (depStringSplit.length >= 4) {
|
||||
jarClassifier = jarClassifier + depStringSplit[3];
|
||||
}
|
||||
|
||||
tinyMappings = mappingsDir.resolve(StringUtils.removeSuffix(mappingsJar.getName(), ".jar") + "-srg.tiny").toFile();
|
||||
tinyMappings = mappingsDir.resolve(StringUtils.removeSuffix(mappingsJar.getName(), ".jar") + ".tiny").toFile();
|
||||
tinyMappingsJar = new File(getExtension().getUserCache(), mappingsJar.getName().replace(".jar", "-" + jarClassifier + ".jar"));
|
||||
|
||||
if (!tinyMappings.exists() || isRefreshDeps()) {
|
||||
@@ -173,8 +172,6 @@ public class MappingsProvider extends DependencyProvider {
|
||||
|
||||
mergeAndSaveMappings(project, intermediaryJar, yarnJar);
|
||||
} else {
|
||||
project.getLogger().warn(":forge not supported with v1 mappings");
|
||||
|
||||
// These are merged v1 mappings
|
||||
if (tinyMappings.exists()) {
|
||||
tinyMappings.delete();
|
||||
@@ -225,24 +222,12 @@ public class MappingsProvider extends DependencyProvider {
|
||||
extractMappings(unmergedYarnJarFs, unmergedYarn);
|
||||
}
|
||||
|
||||
//Path invertedIntermediary = Paths.get(mappingsStepsDir.toString(), "inverted-intermediary.tiny");
|
||||
//reorderMappings(unmergedIntermediary, invertedIntermediary, "intermediary", "official");
|
||||
Path invertedIntermediary = Paths.get(mappingsStepsDir.toString(), "inverted-intermediary.tiny");
|
||||
reorderMappings(unmergedIntermediary, invertedIntermediary, "intermediary", "official");
|
||||
Path unorderedMergedMappings = Paths.get(mappingsStepsDir.toString(), "unordered-merged.tiny");
|
||||
Path srgToIntermediary = Paths.get(mappingsStepsDir.toString(), "srg-to-intermediary.tiny");
|
||||
Path srgToYarn = Paths.get(mappingsStepsDir.toString(), "srg-to-yarn.tiny");
|
||||
composeMappings(getExtension().getMcpConfigProvider().getSrgTiny().toPath(), unmergedIntermediary, "tinyv2:srg:intermediary", srgToIntermediary);
|
||||
composeMappings(srgToIntermediary, unmergedYarn, "tinyv2:srg:named", srgToYarn);
|
||||
project.getLogger().info(":merging");
|
||||
mergeMappings(srgToIntermediary, srgToYarn, unorderedMergedMappings);
|
||||
reorderMappings(unorderedMergedMappings, tinyMappings.toPath(), "srg", "intermediary", "named");
|
||||
}
|
||||
|
||||
private void composeMappings(Path a, Path b, String outputFormat, Path output) {
|
||||
try {
|
||||
new ComposeMappingsCommand().run("tinyv2", a.toString(), "tinyv2", b.toString(), outputFormat, output.toString(), "right");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
mergeMappings(invertedIntermediary, unmergedYarn, unorderedMergedMappings);
|
||||
reorderMappings(unorderedMergedMappings, tinyMappings.toPath(), "official", "intermediary", "named");
|
||||
}
|
||||
|
||||
private void reorderMappings(Path oldMappings, Path newMappings, String... newOrder) {
|
||||
@@ -258,20 +243,20 @@ public class MappingsProvider extends DependencyProvider {
|
||||
try {
|
||||
Command command = new CommandMergeTinyV2();
|
||||
runCommand(command, intermediaryMappings.toAbsolutePath().toString(),
|
||||
yarnMappings.toAbsolutePath().toString(),
|
||||
newMergedMappings.toAbsolutePath().toString(),
|
||||
"intermediary", "official");
|
||||
yarnMappings.toAbsolutePath().toString(),
|
||||
newMergedMappings.toAbsolutePath().toString(),
|
||||
"intermediary", "official");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Could not merge mappings from " + intermediaryMappings.toString()
|
||||
+ " with mappings from " + yarnMappings, e);
|
||||
+ " with mappings from " + yarnMappings, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void suggestFieldNames(MinecraftProvider minecraftProvider, Path oldMappings, Path newMappings) {
|
||||
Command command = new CommandProposeFieldNames();
|
||||
runCommand(command, minecraftProvider.getMergedJar().getAbsolutePath(),
|
||||
oldMappings.toAbsolutePath().toString(),
|
||||
newMappings.toAbsolutePath().toString());
|
||||
oldMappings.toAbsolutePath().toString(),
|
||||
newMappings.toAbsolutePath().toString());
|
||||
}
|
||||
|
||||
private void runCommand(Command command, String... args) {
|
||||
|
||||
@@ -25,46 +25,22 @@
|
||||
package net.fabricmc.loom.providers;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.net.URI;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import cuchaz.enigma.command.ConvertMappingsCommand;
|
||||
import cuchaz.enigma.command.InvertMappingsCommand;
|
||||
import org.cadixdev.lorenz.MappingSet;
|
||||
import org.cadixdev.lorenz.io.enigma.EnigmaWriter;
|
||||
import org.cadixdev.lorenz.io.srg.tsrg.TSrgReader;
|
||||
import org.cadixdev.lorenz.model.ClassMapping;
|
||||
import org.cadixdev.lorenz.model.FieldMapping;
|
||||
import org.cadixdev.lorenz.model.MethodMapping;
|
||||
import org.cadixdev.lorenz.model.TopLevelClassMapping;
|
||||
import org.gradle.api.Project;
|
||||
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.DependencyProvider;
|
||||
import net.fabricmc.mapping.tree.ClassDef;
|
||||
import net.fabricmc.stitch.commands.CommandReorderTiny;
|
||||
import net.fabricmc.stitch.commands.tinyv2.CommandReorderTinyV2;
|
||||
import net.fabricmc.stitch.commands.tinyv2.TinyClass;
|
||||
import net.fabricmc.stitch.commands.tinyv2.TinyField;
|
||||
import net.fabricmc.stitch.commands.tinyv2.TinyMethod;
|
||||
|
||||
public class McpConfigProvider extends DependencyProvider {
|
||||
private File mcp;
|
||||
private File srg;
|
||||
private File srgTiny;
|
||||
private File invertedSrgTiny;
|
||||
|
||||
public McpConfigProvider(Project project) {
|
||||
super(project);
|
||||
@@ -74,7 +50,7 @@ public class McpConfigProvider extends DependencyProvider {
|
||||
public void provide(DependencyInfo dependency, Consumer<Runnable> postPopulationScheduler) throws Exception {
|
||||
init(dependency.getDependency().getVersion());
|
||||
|
||||
if (mcp.exists() && srg.exists() && srgTiny.exists() && invertedSrgTiny.exists()) {
|
||||
if (mcp.exists() && srg.exists()) {
|
||||
return; // No work for us to do here
|
||||
}
|
||||
|
||||
@@ -89,43 +65,11 @@ public class McpConfigProvider extends DependencyProvider {
|
||||
Files.copy(fs.getPath("config", "joined.tsrg"), srg.toPath());
|
||||
}
|
||||
}
|
||||
|
||||
if (!srgTiny.exists()) {
|
||||
List<TinyClass> classes = new ArrayList<>();
|
||||
|
||||
try (TSrgReader reader = new TSrgReader(new FileReader(srg))) {
|
||||
MappingSet mappings = reader.read();
|
||||
|
||||
}
|
||||
|
||||
new ConvertMappingsCommand().run("enigma_file", enigma.toString(), "tinyv2:official:srg", srgTiny.getAbsolutePath());
|
||||
new CommandReorderTinyV2().run(new String[]{srgTiny.getAbsolutePath(), invertedSrgTiny.getAbsolutePath(), "srg", "official"});
|
||||
}
|
||||
}
|
||||
|
||||
private <M extends ClassMapping<M, ?>> TinyClass toTinyClass(M mapping) {
|
||||
List<String> names = ImmutableList.of(mapping.getFullObfuscatedName(), mapping.getFullDeobfuscatedName());
|
||||
List<TinyMethod> methods = new ArrayList<>();
|
||||
List<TinyField> fields = new ArrayList<>();
|
||||
|
||||
for (MethodMapping method : mapping.getMethodMappings()) {
|
||||
List<String> methodNames = ImmutableList.of(method.getObfuscatedName(), method.getDeobfuscatedName());
|
||||
methods.add(new TinyMethod(method.getObfuscatedDescriptor(), methodNames, Collections.emptySet(), Collections.emptySet(), Collections.emptySet()));
|
||||
}
|
||||
|
||||
for (FieldMapping field : mapping.getFieldMappings()) {
|
||||
List<String> fieldNames = ImmutableList.of(field.getObfuscatedName(), field.getDeobfuscatedName());
|
||||
fields.add(new TinyField(field.get))
|
||||
}
|
||||
|
||||
return new TinyClass(names, methods, fields, Collections.emptySet());
|
||||
}
|
||||
|
||||
private void init(String version) {
|
||||
mcp = new File(getExtension().getUserCache(), "mcp-" + version + ".zip");
|
||||
srg = new File(getExtension().getUserCache(), "srg-" + version + ".tsrg");
|
||||
srgTiny = new File(getExtension().getUserCache(), "srg-" + version + ".tiny");
|
||||
invertedSrgTiny = new File(getExtension().getUserCache(), "srg-" + version + "-inverted.tiny");
|
||||
}
|
||||
|
||||
public File getMcp() {
|
||||
@@ -136,14 +80,6 @@ public class McpConfigProvider extends DependencyProvider {
|
||||
return srg;
|
||||
}
|
||||
|
||||
public File getSrgTiny() {
|
||||
return srgTiny;
|
||||
}
|
||||
|
||||
public File getInvertedSrgTiny() {
|
||||
return invertedSrgTiny;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetConfig() {
|
||||
return Constants.MCP_CONFIG;
|
||||
|
||||
@@ -63,7 +63,7 @@ public class MinecraftMappedProvider extends DependencyProvider {
|
||||
throw new RuntimeException("mappings file not found");
|
||||
}
|
||||
|
||||
if (!getExtension().getMinecraftProvider().getMergedSrgJar().exists()) {
|
||||
if (!getExtension().getMinecraftProvider().getMergedJar().exists()) {
|
||||
throw new RuntimeException("input merged jar not found");
|
||||
}
|
||||
|
||||
@@ -97,11 +97,11 @@ public class MinecraftMappedProvider extends DependencyProvider {
|
||||
}
|
||||
|
||||
private void mapMinecraftJar() throws IOException {
|
||||
String fromM = "srg";
|
||||
String fromM = "official";
|
||||
|
||||
MappingsProvider mappingsProvider = getExtension().getMappingsProvider();
|
||||
|
||||
Path input = minecraftProvider.getMergedSrgJar().toPath();
|
||||
Path input = minecraftProvider.getMergedJar().toPath();
|
||||
Path outputMapped = minecraftMappedJar.toPath();
|
||||
Path outputIntermediary = minecraftIntermediaryJar.toPath();
|
||||
|
||||
|
||||
@@ -34,11 +34,9 @@ import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.FileSystemNotFoundException;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.UnaryOperator;
|
||||
@@ -84,7 +82,6 @@ public class MinecraftProvider extends DependencyProvider {
|
||||
private File minecraftClientPatchedJar;
|
||||
private File minecraftServerPatchedJar;
|
||||
private File minecraftMergedJar;
|
||||
private File minecraftMergedSrgJar;
|
||||
|
||||
Gson gson = new Gson();
|
||||
|
||||
@@ -137,7 +134,7 @@ public class MinecraftProvider extends DependencyProvider {
|
||||
createPatchedJars(getProject().getLogger());
|
||||
}
|
||||
|
||||
if (!minecraftMergedJar.exists() || !minecraftMergedSrgJar.exists() || isRefreshDeps()) {
|
||||
if (!minecraftMergedJar.exists() || isRefreshDeps()) {
|
||||
try {
|
||||
mergeJars(getProject().getLogger());
|
||||
} catch (ZipError e) {
|
||||
@@ -168,7 +165,6 @@ public class MinecraftProvider extends DependencyProvider {
|
||||
minecraftClientPatchedSrgJar = new File(getExtension().getProjectPersistentCache(), "minecraft-" + minecraftVersion + "-client-patched-srg-" + patchProvider.forgeVersion + ".jar");
|
||||
minecraftServerPatchedSrgJar = new File(getExtension().getProjectPersistentCache(), "minecraft-" + minecraftVersion + "-server-patched-srg-" + patchProvider.forgeVersion + ".jar");
|
||||
minecraftMergedJar = new File(getExtension().getProjectPersistentCache(), "minecraft-" + minecraftVersion + "-merged-patched-" + patchProvider.forgeVersion + ".jar");
|
||||
minecraftMergedSrgJar = new File(getExtension().getProjectPersistentCache(), "minecraft-" + minecraftVersion + "-merged-patched-" + patchProvider.forgeVersion + "-srg.jar");
|
||||
}
|
||||
|
||||
private void downloadMcJson(boolean offline) throws IOException {
|
||||
@@ -308,13 +304,12 @@ public class MinecraftProvider extends DependencyProvider {
|
||||
|
||||
// FIXME: Hack here: There are no server-only classes so we can just copy the client JAR.
|
||||
Files.copy(minecraftClientPatchedJar, minecraftMergedJar);
|
||||
Files.copy(minecraftClientPatchedSrgJar, minecraftMergedSrgJar);
|
||||
|
||||
logger.lifecycle(":copying resources");
|
||||
|
||||
// Copy resources
|
||||
copyNonClassFiles(minecraftClientJar, minecraftMergedJar);
|
||||
copyNonClassFiles(minecraftClientJar, minecraftMergedSrgJar);
|
||||
copyNonClassFiles(minecraftServerJar, minecraftMergedJar);
|
||||
copyNonClassFiles(minecraftServerJar, minecraftMergedSrgJar);
|
||||
|
||||
/*try (JarMerger jarMerger = new JarMerger(minecraftClientPatchedJar, minecraftServerPatchedJar, minecraftMergedJar)) {
|
||||
jarMerger.enableSyntheticParamsOffset();
|
||||
@@ -353,10 +348,6 @@ public class MinecraftProvider extends DependencyProvider {
|
||||
return minecraftMergedJar;
|
||||
}
|
||||
|
||||
public File getMergedSrgJar() {
|
||||
return minecraftMergedSrgJar;
|
||||
}
|
||||
|
||||
public String getMinecraftVersion() {
|
||||
return minecraftVersion;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user