Base GenDiff off deobf data's class list instead of the merged jar. Add option to delete target files that generate patches.
This commit is contained in:
parent
028c77c3a0
commit
58ce9b33b3
3 changed files with 37 additions and 28 deletions
|
@ -151,7 +151,7 @@
|
|||
<antcall target="signjar" />
|
||||
<zip update="true" destfile="${basedir}/target/${universal.jarname}.zip">
|
||||
<zipfileset dir="${basedir}/binpatch" prefix="binpatch" includes="**/*.binpatch"/>
|
||||
<!-- <fileset dir="${client.mcp.obfoutput}" includes="*.class" />-->
|
||||
<fileset dir="${client.mcp.obfoutput}" includes="*.class" />
|
||||
<zipfileset dir="${basedir}" includes="fmlversion.properties" />
|
||||
<zipfileset dir="${basedir}" includes="LICENSE-fml.txt" />
|
||||
<zipfileset dir="${common.src.dir}" includes="mcpmod.info" />
|
||||
|
@ -382,22 +382,22 @@
|
|||
<pathelement path="${mcp.obfoutput}/minecraft"/>
|
||||
<fileset dir="${mcp.home}/lib" includes="guava-14.0-rc3.jar,asm-debug-all-4.1.jar"/>
|
||||
</classpath>
|
||||
<arg path="${mcp.home}/jars/bin/minecraft.jar.backup"/>
|
||||
<arg path="${mcp.home}/jars/bin/minecraft.jar.backup"/>
|
||||
<arg path="${mcp.home}/jars/versions/${version.minecraft}/${version.minecraft}.jar.backup"/>
|
||||
<arg path="${mcp.obfoutput}/minecraft"/>
|
||||
<arg path="${basedir}/deobfuscation_data_${version.minecraft}.zip"/>
|
||||
<arg path="${basedir}/binpatch/client"/>
|
||||
<arg value="false"/>
|
||||
</java>
|
||||
<java classname="cpw.mods.fml.common.patcher.GenDiffSet">
|
||||
<classpath>
|
||||
<pathelement path="${mcp.obfoutput}/minecraft"/>
|
||||
<fileset dir="${mcp.home}/lib" includes="guava-14.0-rc3.jar,asm-debug-all-4.1.jar"/>
|
||||
</classpath>
|
||||
<arg path="${mcp.home}/jars/bin/minecraft.jar.backup"/>
|
||||
<arg path="${mcp.home}/jars/minecraft_server.jar.backup"/>
|
||||
<arg path="${mcp.home}/jars/minecraft_server.${version.minecraft}.jar.backup"/>
|
||||
<arg path="${mcp.obfoutput}/minecraft"/>
|
||||
<arg path="${basedir}/deobfuscation_data_${version.minecraft}.zip"/>
|
||||
<arg path="${basedir}/binpatch/server"/>
|
||||
<arg value="true"/>
|
||||
</java>
|
||||
</target>
|
||||
</project>
|
||||
|
|
|
@ -41,6 +41,7 @@ import com.google.common.collect.HashBiMap;
|
|||
import com.google.common.collect.ImmutableBiMap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
|
@ -415,4 +416,9 @@ public class FMLDeobfuscatingRemapper extends Remapper {
|
|||
fieldNameMaps.put(name, ImmutableMap.copyOf(fieldMap));
|
||||
// System.out.printf("Maps: %s %s\n", name, methodMap);
|
||||
}
|
||||
|
||||
public Set<String> getObfedClasses()
|
||||
{
|
||||
return ImmutableSet.copyOf(classNameBiMap.keySet());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@ import java.util.jar.JarFile;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.omg.CORBA.REBIND;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
|
@ -23,35 +21,34 @@ public class GenDiffSet {
|
|||
|
||||
public static void main(String[] args) throws IOException
|
||||
{
|
||||
String vanillaMinecraftJar = args[0];
|
||||
String targetJar = args[1];
|
||||
String reobfuscationOutputPath = args[2];
|
||||
String deobfFileName = args[3];
|
||||
String binPatchOutputDir = args[4];
|
||||
String sourceJar = args[0]; //Clean Vanilla jar minecraft.jar or minecraft_server.jar
|
||||
String targetDir = args[1]; //Directory containing obfed output classes, typically mcp/reobf/minecraft
|
||||
String deobfData = args[2]; //Path to FML's deobfusication_data.zip
|
||||
String outputDir = args[3]; //Path to place generated .binpatch
|
||||
String killTarget = args[4]; //"true" if we should destroy the target file if it generated a successful .binpatch
|
||||
|
||||
Logger.getLogger("GENDIFF").log(Level.INFO, String.format("Creating patches at %s for %s from %s", binPatchOutputDir, targetJar, reobfuscationOutputPath));
|
||||
Logger.getLogger("GENDIFF").log(Level.INFO, String.format("Creating patches at %s for %s from %s", outputDir, sourceJar, targetDir));
|
||||
Delta delta = new Delta();
|
||||
FMLDeobfuscatingRemapper remapper = FMLDeobfuscatingRemapper.INSTANCE;
|
||||
remapper.setupLoadOnly(deobfFileName, false);
|
||||
JarFile originalJarFile = new JarFile(vanillaMinecraftJar);
|
||||
JarFile targetJarFile = new JarFile(targetJar);
|
||||
remapper.setupLoadOnly(deobfData, false);
|
||||
JarFile sourceZip = new JarFile(sourceJar);
|
||||
boolean kill = killTarget.equalsIgnoreCase("true");
|
||||
|
||||
File f = new File(binPatchOutputDir);
|
||||
File f = new File(outputDir);
|
||||
f.mkdirs();
|
||||
|
||||
for (JarEntry e : Collections.list(originalJarFile.entries()))
|
||||
for (String name : remapper.getObfedClasses())
|
||||
{
|
||||
String name = e.getName();
|
||||
// Logger.getLogger("GENDIFF").info(String.format("Evaluating path for data :%s",name));
|
||||
File reobfOutput = new File(reobfuscationOutputPath, name);
|
||||
if (reobfOutput.exists())
|
||||
File targetFile = new File(targetDir, name.replace('/', File.separatorChar) + ".class");
|
||||
if (targetFile.exists())
|
||||
{
|
||||
String sourceClassName = name.substring(0, name.lastIndexOf(".")).replace('/', '.');
|
||||
String targetClassName = remapper.map(name.substring(0,name.lastIndexOf("."))).replace('/', '.');
|
||||
JarEntry entry = targetJarFile.getJarEntry(name);
|
||||
String sourceClassName = name.replace('/', '.');
|
||||
String targetClassName = remapper.map(name).replace('/', '.');
|
||||
JarEntry entry = sourceZip.getJarEntry(name);
|
||||
|
||||
byte[] vanillaBytes = entry != null ? ByteStreams.toByteArray(targetJarFile.getInputStream(entry)) : new byte[0];
|
||||
byte[] patchedBytes = Files.toByteArray(reobfOutput);
|
||||
byte[] vanillaBytes = entry != null ? ByteStreams.toByteArray(sourceZip.getInputStream(entry)) : new byte[0];
|
||||
byte[] patchedBytes = Files.toByteArray(targetFile);
|
||||
|
||||
byte[] diff = delta.compute(vanillaBytes, patchedBytes);
|
||||
|
||||
|
@ -63,18 +60,24 @@ public class GenDiffSet {
|
|||
// Target name
|
||||
diffOut.writeUTF(targetClassName);
|
||||
// exists at original
|
||||
diffOut.writeBoolean(entry!=null);
|
||||
diffOut.writeBoolean(entry != null);
|
||||
// length of patch
|
||||
diffOut.writeInt(diff.length);
|
||||
// patch
|
||||
diffOut.write(diff);
|
||||
|
||||
File target = new File(binPatchOutputDir, targetClassName+".binpatch");
|
||||
File target = new File(outputDir, targetClassName+".binpatch");
|
||||
target.getParentFile().mkdirs();
|
||||
Files.write(diffOut.toByteArray(), target);
|
||||
Logger.getLogger("GENDIFF").info(String.format("Wrote patch for %s (%s) at %s",name, targetClassName, target.getAbsolutePath()));
|
||||
if (kill)
|
||||
{
|
||||
targetFile.delete();
|
||||
Logger.getLogger("GENDIFF").info(String.format(" Deleted target: %s", targetFile.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
sourceZip.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue