Fix mod obof, and add property to specify refmapName

dev/0.11
modmuss50 2016-10-20 16:55:46 +01:00
parent 14fb337330
commit 9f959ef04d
No known key found for this signature in database
GPG Key ID: 773D17BE8BF49C82
10 changed files with 172 additions and 175 deletions

View File

@ -57,7 +57,7 @@ dependencies {
shade 'commons-io:commons-io:1.4'
shade 'com.google.guava:guava:19.0'
shade 'net.fabricmc:weave:0.1.0.6'
shade 'cuchaz:enigma:0.11.0.5:lib'
shade 'cuchaz:enigma:0.11.0.19:lib'
shade 'net.fabricmc:tiny-remapper:+'
compile 'net.fabricmc:fabric-base:16w38a-0.0.4-SNAPSHOT'

View File

@ -30,14 +30,13 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.fabricmc.loom.task.DownloadTask;
import net.fabricmc.loom.task.GenIdeaProjectTask;
import net.fabricmc.loom.util.ModRemapper;
import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.ModRemapper;
import net.fabricmc.loom.util.Version;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.artifacts.repositories.MavenArtifactRepository;
import org.gradle.api.internal.file.collections.FileCollectionAdapter;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.tasks.SourceSet;
@ -97,7 +96,7 @@ public class AbstractPlugin implements Plugin<Project> {
Set<Task> taskSet = entry.getValue();
for (Task task : taskSet) {
if (task instanceof JavaCompile
&& !(task.getName().contains("Test")) && !(task.getName().contains("test"))) {
&& !(task.getName().contains("Test")) && !(task.getName().contains("test"))) {
JavaCompile javaCompileTask = (JavaCompile) task;
javaCompileTask.doFirst(task1 -> {
project.getLogger().lifecycle(":setting java compiler args");
@ -105,8 +104,8 @@ public class AbstractPlugin implements Plugin<Project> {
javaCompileTask.getClasspath().add(target.files(this.getClass().getProtectionDomain().getCodeSource().getLocation()));
javaCompileTask.getOptions().getCompilerArgs().add("-AinMapFilePomfMojang=" + Constants.MAPPINGS_TINY.get(extension).getCanonicalPath());
javaCompileTask.getOptions().getCompilerArgs().add("-AoutMapFilePomfMojang=" + Constants.MAPPINGS_MIXIN_EXPORT.get(extension).getCanonicalPath());
javaCompileTask.getOptions().getCompilerArgs().add("-AoutRefMapFile=" + new File(javaCompileTask.getDestinationDir(), ".mixin-refmap.json").getCanonicalPath());
javaCompileTask.getOptions().getCompilerArgs().add("-AoutMapFilePomfMojang=" + Constants.MAPPINGS_MIXIN_EXPORT.get(extension).getCanonicalPath());
javaCompileTask.getOptions().getCompilerArgs().add("-AoutRefMapFile=" + new File(javaCompileTask.getDestinationDir(), extension.refmapName).getCanonicalPath());
} catch (IOException e) {
e.printStackTrace();
}
@ -267,7 +266,6 @@ public class AbstractPlugin implements Plugin<Project> {
});
});
}
protected void readModJson(LoomGradleExtension extension) {

View File

@ -33,6 +33,7 @@ public class LoomGradleExtension {
public String runDir = "run";
public String fabricVersion;
public String pomfVersion;
public String refmapName;
//Not to be set in the build.gradle
public Project project;

View File

@ -37,103 +37,108 @@ import java.io.IOException;
import java.nio.file.Files;
public class MixinMappingProviderTiny extends MappingProvider {
private final String from, to;
private final String from, to;
public MixinMappingProviderTiny(Messager messager, Filer filer, String from, String to) {
super(messager, filer);
this.from = from;
this.to = to;
}
public MixinMappingProviderTiny(Messager messager, Filer filer, String from, String to) {
super(messager, filer);
this.from = from;
this.to = to;
}
private static final String[] removeFirst(String[] src, int count) {
if (count >= src.length) {
return new String[0];
} else {
String[] out = new String[src.length - count];
System.arraycopy(src, count, out, 0, out.length);
return out;
}
}
private static final String[] removeFirst(String[] src, int count) {
if (count >= src.length) {
return new String[0];
} else {
String[] out = new String[src.length - count];
System.arraycopy(src, count, out, 0, out.length);
return out;
}
}
@Override
public MappingMethod getMethodMapping(MappingMethod method) {
System.out.println("processing " + method.getName() + method.getDesc());
@Override
public MappingMethod getMethodMapping(MappingMethod method) {
System.out.println("processing " + method.getName() + method.getDesc());
MappingMethod mapped = this.methodMap.get(method);
if (mapped != null)
return mapped;
MappingMethod mapped = this.methodMap.get(method);
if (mapped != null) return mapped;
try {
Class c = this.getClass().getClassLoader().loadClass(method.getOwner().replace('/', '.'));
if (c == null || c == Object.class) {
return null;
}
try {
Class c = this.getClass().getClassLoader().loadClass(method.getOwner().replace('/', '.'));
if (c == null || c == Object.class) {
return null;
}
for (Class cc : c.getInterfaces()) {
mapped = getMethodMapping(method.move(cc.getName().replace('.', '/')));
if (mapped != null)
return mapped;
}
for (Class cc : c.getInterfaces()) {
mapped = getMethodMapping(method.move(cc.getName().replace('.', '/')));
if (mapped != null) return mapped;
}
if (c.getSuperclass() != null) {
mapped = getMethodMapping(method.move(c.getSuperclass().getName().replace('.', '/')));
if (mapped != null)
return mapped;
}
if (c.getSuperclass() != null) {
mapped = getMethodMapping(method.move(c.getSuperclass().getName().replace('.', '/')));
if (mapped != null) return mapped;
}
return null;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
return null;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
@Override
public MappingField getFieldMapping(MappingField field) {
System.out.println("processing " + field.getOwner() + "/" + field.getName() + field.getDesc());
@Override
public MappingField getFieldMapping(MappingField field) {
System.out.println("processing " + field.getOwner() + "/" + field.getName() + field.getDesc());
MappingField mapped = this.fieldMap.get(field);
if (mapped != null)
return mapped;
MappingField mapped = this.fieldMap.get(field);
if (mapped != null) return mapped;
try {
Class c = this.getClass().getClassLoader().loadClass(field.getOwner().replace('/', '.'));
if (c == null || c == Object.class) {
return null;
}
try {
Class c = this.getClass().getClassLoader().loadClass(field.getOwner().replace('/', '.'));
if (c == null || c == Object.class) {
return null;
}
for (Class cc : c.getInterfaces()) {
mapped = getFieldMapping(field.move(cc.getName().replace('.', '/')));
if (mapped != null)
return mapped;
}
for (Class cc : c.getInterfaces()) {
mapped = getFieldMapping(field.move(cc.getName().replace('.', '/')));
if (mapped != null) return mapped;
}
if (c.getSuperclass() != null) {
mapped = getFieldMapping(field.move(c.getSuperclass().getName().replace('.', '/')));
if (mapped != null)
return mapped;
}
if (c.getSuperclass() != null) {
mapped = getFieldMapping(field.move(c.getSuperclass().getName().replace('.', '/')));
if (mapped != null) return mapped;
}
return null;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
return null;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
// TODO: Unify with tiny-remapper
// TODO: Unify with tiny-remapper
@Override
public void read(File input) throws IOException {
BufferedReader reader = Files.newBufferedReader(input.toPath());
@Override
public void read(File input) throws IOException {
BufferedReader reader = Files.newBufferedReader(input.toPath());
TinyUtils.read(reader, from, to, (classFrom, classTo) -> {
classMap.put(classFrom, classTo);
}, (fieldFrom, fieldTo) -> {
fieldMap.put(
new MappingField(fieldFrom.owner, fieldFrom.name, fieldFrom.desc),
new MappingField(fieldTo.owner, fieldTo.name, fieldTo.desc)
);
}, (methodFrom, methodTo) -> {
methodMap.put(
new MappingMethod(methodFrom.owner, methodFrom.name, methodFrom.desc),
new MappingMethod(methodTo.owner, methodTo.name, methodTo.desc)
);
});
}
TinyUtils.read(reader, from, to, (classFrom, classTo) -> {
classMap.put(classFrom, classTo);
}, (fieldFrom, fieldTo) -> {
fieldMap.put(
new MappingField(fieldFrom.owner, fieldFrom.name, fieldFrom.desc),
new MappingField(fieldTo.owner, fieldTo.name, fieldTo.desc)
);
}, (methodFrom, methodTo) -> {
methodMap.put(
new MappingMethod(methodFrom.owner, methodFrom.name, methodFrom.desc),
new MappingMethod(methodTo.owner, methodTo.name, methodTo.desc)
);
});
}
}

View File

@ -39,37 +39,37 @@ import java.io.PrintWriter;
* Created by asie on 10/9/16.
*/
public class MixinMappingWriterTiny extends MappingWriter {
public MixinMappingWriterTiny(Messager messager, Filer filer) {
super(messager, filer);
}
public MixinMappingWriterTiny(Messager messager, Filer filer) {
super(messager, filer);
}
@Override
public void write(String output, ObfuscationType type, IMappingConsumer.MappingSet<MappingField> fields, IMappingConsumer.MappingSet<MappingMethod> methods) {
if (output != null) {
PrintWriter writer = null;
@Override
public void write(String output, ObfuscationType type, IMappingConsumer.MappingSet<MappingField> fields, IMappingConsumer.MappingSet<MappingMethod> methods) {
if (output != null) {
PrintWriter writer = null;
try {
String from = type.getKey().split(":")[0];
String to = type.getKey().split(":")[1];
try {
String from = type.getKey().split(":")[0];
String to = type.getKey().split(":")[1];
writer = this.openFileWriter(output, type + " output TinyMappings");
writer.println(String.format("v1\t%s\t%s", from, to));
for (IMappingConsumer.MappingSet.Pair<MappingField> pair : fields) {
writer.println(String.format("FIELD\t%s\t%s\t%s\t%s", pair.from.getOwner(), pair.from.getDesc(), pair.from.getSimpleName(), pair.to.getSimpleName()));
}
for (IMappingConsumer.MappingSet.Pair<MappingMethod> pair : methods) {
writer.println(String.format("METHOD\t%s\t%s\t%s\t%s", pair.from.getOwner(), pair.from.getDesc(), pair.from.getSimpleName(), pair.to.getSimpleName()));
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (writer != null) {
try {
writer.close();
} catch (Exception e) {
}
}
}
}
}
writer = this.openFileWriter(output, type + " output TinyMappings");
writer.println(String.format("v1\t%s\t%s", from, to));
for (IMappingConsumer.MappingSet.Pair<MappingField> pair : fields) {
writer.println(String.format("FIELD\t%s\t%s\t%s\t%s", pair.from.getOwner(), pair.from.getDesc(), pair.from.getSimpleName(), pair.to.getSimpleName()));
}
for (IMappingConsumer.MappingSet.Pair<MappingMethod> pair : methods) {
writer.println(String.format("METHOD\t%s\t%s\t%s\t%s", pair.from.getOwner(), pair.from.getDesc(), pair.from.getSimpleName(), pair.to.getSimpleName()));
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (writer != null) {
try {
writer.close();
} catch (Exception e) {
}
}
}
}
}
}

View File

@ -33,19 +33,19 @@ import javax.annotation.processing.Filer;
import javax.annotation.processing.Messager;
public class ObfuscationEnvironmentFabric extends ObfuscationEnvironment {
protected ObfuscationEnvironmentFabric(ObfuscationType type) {
super(type);
}
protected ObfuscationEnvironmentFabric(ObfuscationType type) {
super(type);
}
@Override
protected IMappingProvider getMappingProvider(Messager messager, Filer filer) {
String from = type.getKey().split(":")[0];
String to = type.getKey().split(":")[1];
return new MixinMappingProviderTiny(messager, filer, from, to);
}
@Override
protected IMappingProvider getMappingProvider(Messager messager, Filer filer) {
String from = type.getKey().split(":")[0];
String to = type.getKey().split(":")[1];
return new MixinMappingProviderTiny(messager, filer, from, to);
}
@Override
protected IMappingWriter getMappingWriter(Messager messager, Filer filer) {
return new MixinMappingWriterTiny(messager, filer);
}
@Override
protected IMappingWriter getMappingWriter(Messager messager, Filer filer) {
return new MixinMappingWriterTiny(messager, filer);
}
}

View File

@ -33,43 +33,43 @@ import java.util.Collection;
import java.util.Set;
public class ObfuscationServiceFabric implements IObfuscationService {
public static final String IN_MAP_FILE = "inMapFile";
public static final String IN_MAP_EXTRA_FILES = "inMapExtraFiles";
public static final String OUT_MAP_FILE = "outMapFile";
public static final String IN_MAP_FILE = "inMapFile";
public static final String IN_MAP_EXTRA_FILES = "inMapExtraFiles";
public static final String OUT_MAP_FILE = "outMapFile";
private String asSuffixed(String arg, String from, String to) {
return arg + StringUtils.capitalize(from) + StringUtils.capitalize(to);
}
private String asSuffixed(String arg, String from, String to) {
return arg + StringUtils.capitalize(from) + StringUtils.capitalize(to);
}
private ObfuscationTypeDescriptor createObfuscationType(String from, String to) {
return new ObfuscationTypeDescriptor(
from + ":" + to,
asSuffixed(ObfuscationServiceFabric.IN_MAP_FILE, from, to),
asSuffixed(ObfuscationServiceFabric.IN_MAP_EXTRA_FILES, from, to),
asSuffixed(ObfuscationServiceFabric.OUT_MAP_FILE, from, to),
ObfuscationEnvironmentFabric.class
);
}
private ObfuscationTypeDescriptor createObfuscationType(String from, String to) {
return new ObfuscationTypeDescriptor(
from + ":" + to,
asSuffixed(ObfuscationServiceFabric.IN_MAP_FILE, from, to),
asSuffixed(ObfuscationServiceFabric.IN_MAP_EXTRA_FILES, from, to),
asSuffixed(ObfuscationServiceFabric.OUT_MAP_FILE, from, to),
ObfuscationEnvironmentFabric.class
);
}
private void addSupportedOptions(ImmutableSet.Builder builder, String from, String to) {
builder.add(asSuffixed(ObfuscationServiceFabric.IN_MAP_FILE, from, to));
builder.add(asSuffixed(ObfuscationServiceFabric.IN_MAP_EXTRA_FILES, from, to));
builder.add(asSuffixed(ObfuscationServiceFabric.OUT_MAP_FILE, from, to));
}
private void addSupportedOptions(ImmutableSet.Builder builder, String from, String to) {
builder.add(asSuffixed(ObfuscationServiceFabric.IN_MAP_FILE, from, to));
builder.add(asSuffixed(ObfuscationServiceFabric.IN_MAP_EXTRA_FILES, from, to));
builder.add(asSuffixed(ObfuscationServiceFabric.OUT_MAP_FILE, from, to));
}
@Override
public Set<String> getSupportedOptions() {
ImmutableSet.Builder builder = new ImmutableSet.Builder();
addSupportedOptions(builder, "mojang", "pomf");
addSupportedOptions(builder, "pomf", "mojang");
return builder.build();
}
@Override
public Set<String> getSupportedOptions() {
ImmutableSet.Builder builder = new ImmutableSet.Builder();
addSupportedOptions(builder, "mojang", "pomf");
addSupportedOptions(builder, "pomf", "mojang");
return builder.build();
}
@Override
public Collection<ObfuscationTypeDescriptor> getObfuscationTypes() {
return ImmutableSet.of(
createObfuscationType("mojang", "pomf"),
createObfuscationType("pomf", "mojang")
);
}
@Override
public Collection<ObfuscationTypeDescriptor> getObfuscationTypes() {
return ImmutableSet.of(
createObfuscationType("mojang", "pomf"),
createObfuscationType("pomf", "mojang")
);
}
}

View File

@ -29,9 +29,7 @@ import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.IdeaRunConfig;
import net.fabricmc.loom.util.Version;
import org.gradle.api.DefaultTask;
import org.gradle.api.Project;
import org.gradle.api.tasks.TaskAction;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

View File

@ -29,11 +29,7 @@ import cuchaz.enigma.TranslatingTypeLoader;
import cuchaz.enigma.mapping.MappingsEnigmaReader;
import cuchaz.enigma.mapping.TranslationDirection;
import cuchaz.enigma.throwables.MappingParseException;
import javassist.CtBehavior;
import javassist.CtClass;
import javassist.CtField;
import javassist.bytecode.AccessFlag;
import javassist.bytecode.InnerClassesAttribute;
import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.util.Constants;
import org.gradle.api.DefaultTask;
@ -64,7 +60,7 @@ public class MapJarsTask extends DefaultTask {
writeJar(Constants.MINECRAFT_MAPPED_JAR.get(extension), new ProgressListener(), deobfuscator);
File tempAssests = new File(Constants.CACHE_FILES, "tempAssets");
if(tempAssests.exists()){
if (tempAssests.exists()) {
FileUtils.deleteDirectory(tempAssests);
}
tempAssests.mkdir();

View File

@ -32,7 +32,6 @@ import org.gradle.api.Project;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
@ -64,7 +63,7 @@ public class ModRemapper {
classpathFiles.addAll(project.getConfigurations().getByName("compile").getFiles());
classpathFiles.addAll(project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES_CLIENT).getFiles());
classpathFiles.addAll(project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES).getFiles());
classpathFiles.add(new File(Constants.MINECRAFT_MERGED_JAR.get(extension).getAbsolutePath()));//Seems to fix it not finding it
classpathFiles.add(new File(Constants.MINECRAFT_FINAL_JAR.get(extension).getAbsolutePath()));//Seems to fix it not finding it
Path[] classpath = new Path[classpathFiles.size()];
for (int i = 0; i < classpathFiles.size(); i++) {