update tiny-remapper, Mixin

dev/0.11
Adrian Siekierka 2019-04-21 11:37:16 +02:00
parent bcae78333d
commit bed0bba2da
5 changed files with 45 additions and 44 deletions

View File

@ -37,12 +37,12 @@ dependencies {
implementation ('net.fabricmc:stitch:0.1.2.49') { implementation ('net.fabricmc:stitch:0.1.2.49') {
exclude module: 'enigma' exclude module: 'enigma'
} }
implementation ('net.fabricmc:tiny-remapper:0.1.0.29') { implementation ('net.fabricmc:tiny-remapper:0.1.0.33') {
transitive = false transitive = false
} }
implementation ('org.jetbrains:intellij-fernflower:1.0.0.8') implementation ('org.jetbrains:intellij-fernflower:1.0.0.8')
implementation ('net.fabricmc:sponge-mixin:0.7.11.21') { implementation ('net.fabricmc:sponge-mixin:0.7.11.22') {
exclude module: 'launchwrapper' exclude module: 'launchwrapper'
exclude module: 'guava' exclude module: 'guava'
} }

View File

@ -24,17 +24,16 @@
package net.fabricmc.loom.mixin; package net.fabricmc.loom.mixin;
import net.fabricmc.tinyremapper.TinyUtils; import net.fabricmc.mappings.*;
import org.spongepowered.asm.obfuscation.mapping.common.MappingField; import org.spongepowered.asm.obfuscation.mapping.common.MappingField;
import org.spongepowered.asm.obfuscation.mapping.common.MappingMethod; import org.spongepowered.asm.obfuscation.mapping.common.MappingMethod;
import org.spongepowered.tools.obfuscation.mapping.common.MappingProvider; import org.spongepowered.tools.obfuscation.mapping.common.MappingProvider;
import javax.annotation.processing.Filer; import javax.annotation.processing.Filer;
import javax.annotation.processing.Messager; import javax.annotation.processing.Messager;
import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files;
public class MixinMappingProviderTiny extends MappingProvider { public class MixinMappingProviderTiny extends MappingProvider {
private final String from, to; private final String from, to;
@ -119,22 +118,36 @@ public class MixinMappingProviderTiny extends MappingProvider {
} */ } */
} }
// TODO: Unify with tiny-remapper
@Override @Override
public void read(File input) throws IOException { public void read(File input) throws IOException {
BufferedReader reader = Files.newBufferedReader(input.toPath()); Mappings mappings;
try (FileInputStream stream = new FileInputStream(input)) {
mappings = MappingsProvider.readTinyMappings(stream, false);
}
for (ClassEntry entry : mappings.getClassEntries()) {
classMap.put(entry.get(from), entry.get(to));
}
for (FieldEntry entry : mappings.getFieldEntries()) {
EntryTriple fromEntry = entry.get(from);
EntryTriple toEntry = entry.get(to);
TinyUtils.read(reader, from, to, classMap::put, (fieldFrom, fieldTo) -> {
fieldMap.put( fieldMap.put(
new MappingField(fieldFrom.owner, fieldFrom.name, fieldFrom.desc), new MappingField(fromEntry.getOwner(), fromEntry.getName(), fromEntry.getDesc()),
new MappingField(fieldTo.owner, fieldTo.name, fieldTo.desc) new MappingField(toEntry.getOwner(), toEntry.getName(), toEntry.getDesc())
); );
}, (methodFrom, methodTo) -> { }
for (MethodEntry entry : mappings.getMethodEntries()) {
EntryTriple fromEntry = entry.get(from);
EntryTriple toEntry = entry.get(to);
methodMap.put( methodMap.put(
new MappingMethod(methodFrom.owner, methodFrom.name, methodFrom.desc), new MappingMethod(fromEntry.getOwner(), fromEntry.getName(), fromEntry.getDesc()),
new MappingMethod(methodTo.owner, methodTo.name, methodTo.desc) new MappingMethod(toEntry.getOwner(), toEntry.getName(), toEntry.getDesc())
); );
}); }
} }
} }

View File

@ -69,9 +69,9 @@ public class MapJarsTiny {
try (OutputConsumerPath outputConsumer = new OutputConsumerPath(output)) { try (OutputConsumerPath outputConsumer = new OutputConsumerPath(output)) {
outputConsumer.addNonClassFiles(input); outputConsumer.addNonClassFiles(input);
remapper.read(input); remapper.readClassPath(classpath);
remapper.read(classpath); remapper.readInputs(input);
remapper.apply(input, outputConsumer); remapper.apply(outputConsumer);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("Failed to remap JAR", e); throw new RuntimeException("Failed to remap JAR", e);
} finally { } finally {

View File

@ -148,8 +148,8 @@ public class ModProcessor {
Path[] mcDeps = mappedProvider.getMapperPaths().stream() Path[] mcDeps = mappedProvider.getMapperPaths().stream()
.map(File::toPath) .map(File::toPath)
.toArray(Path[]::new); .toArray(Path[]::new);
Collection<File> modCompileFiles = project.getConfigurations().getByName(Constants.COMPILE_MODS).getFiles(); Path[] modCompiles = project.getConfigurations().getByName(Constants.COMPILE_MODS).getFiles().stream()
Path[] modCompiles = modCompileFiles.stream() .filter((f) -> !f.equals(input))
.map(p -> { .map(p -> {
if (p.equals(input)) { if (p.equals(input)) {
return inputPath; return inputPath;
@ -167,13 +167,11 @@ public class ModProcessor {
try (OutputConsumerPath outputConsumer = new OutputConsumerPath(Paths.get(output.getAbsolutePath()))) { try (OutputConsumerPath outputConsumer = new OutputConsumerPath(Paths.get(output.getAbsolutePath()))) {
outputConsumer.addNonClassFiles(inputPath); outputConsumer.addNonClassFiles(inputPath);
if (!modCompileFiles.contains(input)) { remapper.readClassPath(modCompiles);
remapper.read(inputPath); remapper.readClassPath(mc);
} remapper.readClassPath(mcDeps);
remapper.read(modCompiles); remapper.readInputs(inputPath);
remapper.read(mc); remapper.apply(outputConsumer);
remapper.read(mcDeps);
remapper.apply(inputPath, outputConsumer);
} catch (Exception e){ } catch (Exception e){
throw new RuntimeException("Failed to remap JAR to " + toM, e); throw new RuntimeException("Failed to remap JAR to " + toM, e);
} finally { } finally {

View File

@ -37,6 +37,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
public class ModRemapper { public class ModRemapper {
@ -62,19 +63,10 @@ public class ModRemapper {
List<File> classpathFiles = new ArrayList<>(); List<File> classpathFiles = new ArrayList<>();
classpathFiles.addAll(project.getConfigurations().getByName(Constants.COMPILE_MODS_MAPPED).getFiles()); classpathFiles.addAll(project.getConfigurations().getByName(Constants.COMPILE_MODS_MAPPED).getFiles());
classpathFiles.addAll(project.getConfigurations().getByName(Constants.MINECRAFT_NAMED).getFiles()); classpathFiles.addAll(project.getConfigurations().getByName(Constants.MINECRAFT_NAMED).getFiles());
Path[] classpath = classpathFiles.stream().map(File::toPath).toArray(Path[]::new); final Path modJarPath = modJar.toPath();
Path modJarPath = modJar.toPath(); Path[] classpath = classpathFiles.stream().map(File::toPath).filter((p) -> !modJarPath.equals(p)).toArray(Path[]::new);
boolean classpathContainsModJarPath = false;
for (Path p : classpath) { String s = modJar.getAbsolutePath();
if (modJarPath.equals(p)) {
modJarPath = p;
classpathContainsModJarPath = true;
break;
}
}
String s =modJar.getAbsolutePath();
File modJarOutput = new File(s.substring(0, s.length() - 4) + ".remapped.jar"); File modJarOutput = new File(s.substring(0, s.length() - 4) + ".remapped.jar");
Path modJarOutputPath = modJarOutput.toPath(); Path modJarOutputPath = modJarOutput.toPath();
@ -98,11 +90,9 @@ public class ModRemapper {
try (OutputConsumerPath outputConsumer = new OutputConsumerPath(modJarOutputPath)) { try (OutputConsumerPath outputConsumer = new OutputConsumerPath(modJarOutputPath)) {
outputConsumer.addNonClassFiles(modJarPath); outputConsumer.addNonClassFiles(modJarPath);
remapper.read(classpath); remapper.readClassPath(classpath);
if (!classpathContainsModJarPath) { remapper.readInputs(modJarPath);
remapper.read(modJarPath); remapper.apply(outputConsumer);
}
remapper.apply(modJarPath, outputConsumer);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("Failed to remap JAR", e); throw new RuntimeException("Failed to remap JAR", e);
} finally { } finally {