mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-03-28 04:07:01 -05:00
Remap mixins properly (and cursedly)
This commit is contained in:
@@ -74,4 +74,3 @@ loom {
|
|||||||
in some places.
|
in some places.
|
||||||
- The srg -> yarn remapper used for coremod class names is *really* simple,
|
- The srg -> yarn remapper used for coremod class names is *really* simple,
|
||||||
and might break with coremods that have multiple class names per line.
|
and might break with coremods that have multiple class names per line.
|
||||||
- Mixins aren't obfuscated properly.
|
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ group = 'net.fabricmc'
|
|||||||
archivesBaseName = project.name
|
archivesBaseName = project.name
|
||||||
def baseVersion = '0.5'
|
def baseVersion = '0.5'
|
||||||
|
|
||||||
def build = 'local'
|
def build = 'Forgified'
|
||||||
def ENV = System.getenv()
|
def ENV = System.getenv()
|
||||||
if (ENV.BUILD_NUMBER) {
|
if (ENV.BUILD_NUMBER) {
|
||||||
build = "release #${ENV.BUILD_NUMBER}"
|
build = "release #${ENV.BUILD_NUMBER}"
|
||||||
version = baseVersion + '.' + ENV.BUILD_NUMBER
|
version = baseVersion + '.' + ENV.BUILD_NUMBER
|
||||||
} else {
|
} else {
|
||||||
version = baseVersion + '-forge.49'
|
version = baseVersion + '-SNAPSHOT'
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
@@ -80,6 +82,7 @@ public class MappingsProvider extends DependencyProvider {
|
|||||||
public File tinyMappingsJar;
|
public File tinyMappingsJar;
|
||||||
public File mappingsMixinExport;
|
public File mappingsMixinExport;
|
||||||
public Path tinyMappingsWithSrg;
|
public Path tinyMappingsWithSrg;
|
||||||
|
public File mixinTinyMappingsWithSrg; // FORGE: The mixin mappings have srg names in intermediary.
|
||||||
|
|
||||||
public MappingsProvider(Project project) {
|
public MappingsProvider(Project project) {
|
||||||
super(project);
|
super(project);
|
||||||
@@ -148,6 +151,7 @@ public class MappingsProvider extends DependencyProvider {
|
|||||||
tinyMappings = mappingsDir.resolve(StringUtils.removeSuffix(mappingsJar.getName(), ".jar") + ".tiny").toFile();
|
tinyMappings = mappingsDir.resolve(StringUtils.removeSuffix(mappingsJar.getName(), ".jar") + ".tiny").toFile();
|
||||||
tinyMappingsJar = new File(getExtension().getUserCache(), mappingsJar.getName().replace(".jar", "-" + jarClassifier + ".jar"));
|
tinyMappingsJar = new File(getExtension().getUserCache(), mappingsJar.getName().replace(".jar", "-" + jarClassifier + ".jar"));
|
||||||
tinyMappingsWithSrg = mappingsDir.resolve(StringUtils.removeSuffix(mappingsJar.getName(), ".jar") + "-srg.tiny");
|
tinyMappingsWithSrg = mappingsDir.resolve(StringUtils.removeSuffix(mappingsJar.getName(), ".jar") + "-srg.tiny");
|
||||||
|
mixinTinyMappingsWithSrg = mappingsDir.resolve(StringUtils.removeSuffix(mappingsJar.getName(), ".jar") + "-mixin-srg.tiny").toFile();
|
||||||
|
|
||||||
if (!tinyMappings.exists() || isRefreshDeps()) {
|
if (!tinyMappings.exists() || isRefreshDeps()) {
|
||||||
storeMappings(getProject(), minecraftProvider, mappingsJar.toPath());
|
storeMappings(getProject(), minecraftProvider, mappingsJar.toPath());
|
||||||
@@ -157,8 +161,17 @@ public class MappingsProvider extends DependencyProvider {
|
|||||||
ZipUtil.pack(new ZipEntrySource[] {new FileSource("mappings/mappings.tiny", tinyMappings)}, tinyMappingsJar);
|
ZipUtil.pack(new ZipEntrySource[] {new FileSource("mappings/mappings.tiny", tinyMappings)}, tinyMappingsJar);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getExtension().isForge() && (Files.notExists(tinyMappingsWithSrg) || isRefreshDeps())) {
|
if (getExtension().isForge()) {
|
||||||
SrgMerger.mergeSrg(getExtension().getMcpConfigProvider().getSrg().toPath(), tinyMappings.toPath(), tinyMappingsWithSrg, true);
|
if (Files.notExists(tinyMappingsWithSrg) || isRefreshDeps()) {
|
||||||
|
SrgMerger.mergeSrg(getExtension().getMcpConfigProvider().getSrg().toPath(), tinyMappings.toPath(), tinyMappingsWithSrg, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mixinTinyMappingsWithSrg.exists() || isRefreshDeps()) {
|
||||||
|
List<String> lines = new ArrayList<>(Files.readAllLines(tinyMappingsWithSrg));
|
||||||
|
lines.set(0, lines.get(0).replace("intermediary", "yraidemretni").replace("srg", "intermediary"));
|
||||||
|
Files.deleteIfExists(mixinTinyMappingsWithSrg.toPath());
|
||||||
|
Files.write(mixinTinyMappingsWithSrg.toPath(), lines);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addDependency(tinyMappingsJar, Constants.Configurations.MAPPINGS_FINAL);
|
addDependency(tinyMappingsJar, Constants.Configurations.MAPPINGS_FINAL);
|
||||||
|
|||||||
@@ -109,14 +109,9 @@ public class RemapJarTask extends Jar {
|
|||||||
|
|
||||||
remapperBuilder = remapperBuilder.withMappings(TinyRemapperMappingsHelper.create(extension.isForge() ? mappingsProvider.getMappingsWithSrg() : mappingsProvider.getMappings(), fromM, toM, false));
|
remapperBuilder = remapperBuilder.withMappings(TinyRemapperMappingsHelper.create(extension.isForge() ? mappingsProvider.getMappingsWithSrg() : mappingsProvider.getMappings(), fromM, toM, false));
|
||||||
|
|
||||||
// FIXME: The mixin map is named->intermediary, but I think we need named->srg?
|
|
||||||
for (File mixinMapFile : extension.getAllMixinMappings()) {
|
for (File mixinMapFile : extension.getAllMixinMappings()) {
|
||||||
if ("intermediary".equals(toM)) {
|
if (mixinMapFile.exists()) {
|
||||||
if (mixinMapFile.exists()) {
|
remapperBuilder = remapperBuilder.withMappings(TinyUtils.createTinyMappingProvider(mixinMapFile.toPath(), fromM, "intermediary"));
|
||||||
remapperBuilder = remapperBuilder.withMappings(TinyUtils.createTinyMappingProvider(mixinMapFile.toPath(), fromM, toM));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
project.getLogger().error("Mixins in Forge projects are currently not supported.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,12 +200,8 @@ public class RemapJarTask extends Jar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (File mixinMapFile : extension.getAllMixinMappings()) {
|
for (File mixinMapFile : extension.getAllMixinMappings()) {
|
||||||
if ("intermediary".equals(toM)) {
|
if (mixinMapFile.exists()) {
|
||||||
if (mixinMapFile.exists()) {
|
jarRemapper.addMappings(TinyUtils.createTinyMappingProvider(mixinMapFile.toPath(), fromM, "intermediary"));
|
||||||
jarRemapper.addMappings(TinyUtils.createTinyMappingProvider(mixinMapFile.toPath(), fromM, toM));
|
|
||||||
} else {
|
|
||||||
project.getLogger().error("Mixins in Forge projects are currently not supported.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,8 +71,9 @@ public abstract class AnnotationProcessorInvoker<T extends Task> {
|
|||||||
private void passMixinArguments(T task) {
|
private void passMixinArguments(T task) {
|
||||||
try {
|
try {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
||||||
|
File inMapFile = extension.isForge() ? extension.getMappingsProvider().mixinTinyMappingsWithSrg : extension.getMappingsProvider().tinyMappings;
|
||||||
Map<String, String> args = new HashMap<String, String>() {{
|
Map<String, String> args = new HashMap<String, String>() {{
|
||||||
put(Constants.MixinArguments.IN_MAP_FILE_NAMED_INTERMEDIARY, extension.getMappingsProvider().tinyMappings.getCanonicalPath());
|
put(Constants.MixinArguments.IN_MAP_FILE_NAMED_INTERMEDIARY, inMapFile.getCanonicalPath());
|
||||||
put(Constants.MixinArguments.OUT_MAP_FILE_NAMED_INTERMEDIARY, extension.getNextMixinMappings().getCanonicalPath());
|
put(Constants.MixinArguments.OUT_MAP_FILE_NAMED_INTERMEDIARY, extension.getNextMixinMappings().getCanonicalPath());
|
||||||
put(Constants.MixinArguments.OUT_REFMAP_FILE, getRefmapDestination(task, extension));
|
put(Constants.MixinArguments.OUT_REFMAP_FILE, getRefmapDestination(task, extension));
|
||||||
put(Constants.MixinArguments.DEFAULT_OBFUSCATION_ENV, "named:intermediary");
|
put(Constants.MixinArguments.DEFAULT_OBFUSCATION_ENV, "named:intermediary");
|
||||||
|
|||||||
Reference in New Issue
Block a user