Update build, dependencies and DepLoader

This commit is contained in:
Chicken-Bomes committed 2014-04-29 15:31:53 +10:00
1 parent 0460815720
commit ce95f90b0d
11 files changed
+107 -82

No files matched your search

+9 -9
View File
@@ -29,6 +29,7 @@ configFile.withReader {
prop.load(it)
project.ext.config = new ConfigSlurper().parse prop
}
dependencies {
compile "codechicken:CodeChickenLib:${config.mc_version}-${config.ccl_version}:dev"
}
@@ -57,11 +58,12 @@ processResources {
//redo task if any of these properties change
inputs.property "version", project.version
inputs.property "mc_version", config.mc_version
inputs.property "ccl_version", config.ccl_version
// Replace properties in info files
from(sourceSets.main.resources.srcDirs) {
include '*.info'
expand 'version':project.version,'mc_version':config.mc_version
expand 'version':project.version,'mc_version':config.mc_version,'ccl_version':config.ccl_version
}
// Copy everything else
from(sourceSets.main.resources.srcDirs) {
@@ -69,26 +71,24 @@ processResources {
}
}
task sourceJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'src'
version = "${project.minecraft.version}-${project.version}"
}
version = "${project.minecraft.version}-${project.version}"
def commonManifest = {
attributes 'FMLCorePlugin': 'codechicken.core.launch.CodeChickenCorePlugin'
}
jar {
classifier = 'universal'
version = "${project.minecraft.version}-${project.version}"
manifest commonManifest
}
task sourceJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'src'
}
task devJar(type: Jar) {
from sourceSets.main.output
classifier = 'dev'
version = "${project.minecraft.version}-${project.version}"
manifest commonManifest
}
+1 -1
View File
@@ -1,4 +1,4 @@
mc_version=1.7.2
forge_version=10.12.0.1054
ccl_version=1.1.0.74
ccl_version=1.1.0.76
mod_version=1.0
-9
View File
@@ -1,9 +0,0 @@
{
"repo": "http://files.minecraftforge.net/CodeChickenLib/",
"file": "CodeChickenLib-universal-@MCVERSION@-@VERSION@.jar",
"dev": "CodeChickenLib-dev-@MCVERSION@-@VERSION@.jar",
"class": "codechicken.lib.asm.ASMHelper",
"version": "1.0.0.62",
"mcversion": "1.6.4",
"coreLib": true
}
+7
View File
@@ -0,0 +1,7 @@
{
"repo": "http://files.minecraftforge.net/maven/codechicken/CodeChickenLib/${mc_version}-${ccl_version}/",
"file": "CodeChickenLib-${mc_version}-${ccl_version}-universal.jar",
"dev": "CodeChickenLib-${mc_version}-${ccl_version}-dev.jar",
"class": "codechicken.lib.asm.ASMHelper",
"coreLib": true
}
@@ -119,7 +119,7 @@ public class DelegatedTransformer implements IClassTransformer
{
ZipEntry entry = jar.getEntry(dependancy+".class");
if(entry == null)
throw new Exception("Dependancy "+dependancy+" not found in jar file "+jarFile.getName());
throw new Exception("Dependency "+dependancy+" not found in jar file "+jarFile.getName());
byte[] depbytes = readFully(jar.getInputStream(entry));
defineDependancies(depbytes, jar, jarFile, depStack);
@@ -2,12 +2,12 @@ package codechicken.core.asm;
import java.util.Iterator;
import codechicken.lib.asm.ASMInit;
import net.minecraft.launchwrapper.Launch;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.ClassNode;
import codechicken.core.launch.CodeChickenCorePlugin;
import codechicken.lib.asm.ASMHelper;
import codechicken.lib.asm.ObfMapping;
@@ -15,6 +15,10 @@ import net.minecraft.launchwrapper.IClassTransformer;
public class InterfaceDependancyTransformer implements IClassTransformer
{
static {
ASMInit.init();
}
@Override
public byte[] transform(String name, String tname, byte[] bytes) {
if (bytes == null) return null;
@@ -6,10 +6,8 @@ import java.lang.reflect.Field;
import java.util.*;
import java.util.Map.Entry;
import javax.swing.JFileChooser;
import codechicken.lib.asm.ASMInit;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
import net.minecraft.launchwrapper.ITweaker;
import net.minecraft.launchwrapper.Launch;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
@@ -26,7 +24,6 @@ import codechicken.lib.asm.ASMHelper;
import codechicken.lib.asm.CC_ClassWriter;
import codechicken.lib.asm.ObfMapping;
import codechicken.lib.config.ConfigFile;
import codechicken.lib.config.ConfigTag;
import codechicken.obfuscator.IHeirachyEvaluator;
import codechicken.obfuscator.ObfuscationRun;
import codechicken.obfuscator.ObfuscationMap.ObfuscationEntry;
@@ -38,6 +35,10 @@ import net.minecraft.launchwrapper.LaunchClassLoader;
public class MCPDeobfuscationTransformer implements IClassTransformer, Opcodes, IHeirachyEvaluator
{
static {
ASMInit.init();
}
public static class LoadPlugin implements IFMLLoadingPlugin
{
@Override
@@ -19,6 +19,10 @@ import static codechicken.lib.asm.InsnComparator.*;
public class TweakTransformer implements IClassTransformer, Opcodes
{
static {
ASMInit.init();
}
private static ModularASMTransformer transformer = new ModularASMTransformer();
private static Map<String, ASMBlock> blocks = ASMReader.loadResource("/assets/codechickencore/asm/tweaks.asm");
public static ConfigTag tweaks;
@@ -18,10 +18,10 @@ public class GameDataManipulator
{
try {
f_registryObjects = RegistrySimple.class.getDeclaredField(
new ObfMapping("net/minecraft/util/RegistrySimple", "registryObjects", "Ljava/util/Map;").toRuntime().s_name);
new ObfMapping("net/minecraft/util/RegistrySimple", "field_82596_a", "Ljava/util/Map;").toRuntime().s_name);
f_registryObjects.setAccessible(true);
f_underlyingIntegerMap = RegistryNamespaced.class.getDeclaredField(
new ObfMapping("net/minecraft/util/RegistryNamespaced", "underlyingIntegerMap", "Lnet/minecraft/util/ObjectIntIdentityMap;").toRuntime().s_name);
new ObfMapping("net/minecraft/util/RegistryNamespaced", "field_148759_a", "Lnet/minecraft/util/ObjectIntIdentityMap;").toRuntime().s_name);
f_underlyingIntegerMap.setAccessible(true);
} catch (Exception e) {
throw new RuntimeException(e);
@@ -17,6 +17,7 @@ import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import codechicken.core.asm.*;
import codechicken.lib.asm.ASMInit;
import cpw.mods.fml.relauncher.CoreModManager;
import net.minecraft.launchwrapper.Launch;
+72 -55
View File
@@ -32,6 +32,7 @@ import java.util.*;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -219,10 +220,36 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
}
}
public static class Dependancy {
public static class VersionedFile
{
public final Pattern pattern;
public final String filename;
public final ComparableVersion version;
public final String name;
public VersionedFile(String filename, Pattern pattern) {
this.pattern = pattern;
this.filename = filename;
Matcher m = pattern.matcher(filename);
if(m.matches()) {
name = m.group(1);
version = new ComparableVersion(m.group(2));
}
else {
name = null;
version = null;
}
}
public boolean matches() {
return name != null;
}
}
public static class Dependency
{
public String url;
public String[] filesplit;
public ComparableVersion version;
public VersionedFile file;
public String existing;
/**
@@ -230,19 +257,10 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
*/
public boolean coreLib;
public Dependancy(String url, String[] filesplit, boolean coreLib) {
public Dependency(String url, VersionedFile file, boolean coreLib) {
this.url = url;
this.filesplit = filesplit;
this.file = file;
this.coreLib = coreLib;
version = new ComparableVersion(filesplit[1]);
}
public String getName() {
return filesplit[0];
}
public String fileName() {
return filesplit[0] + filesplit[1] + filesplit[2];
}
}
@@ -252,7 +270,7 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
private IDownloadDisplay downloadMonitor;
private JDialog popupWindow;
private Map<String, Dependancy> depMap = new HashMap<String, Dependancy>();
private Map<String, Dependency> depMap = new HashMap<String, Dependency>();
private HashSet<String> depSet = new HashSet<String>();
public DepLoadInst() {
@@ -308,11 +326,11 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
}
}
private void download(Dependancy dep) {
private void download(Dependency dep) {
popupWindow = (JDialog) downloadMonitor.makeDialog();
File libFile = new File(v_modsDir, dep.fileName());
File libFile = new File(v_modsDir, dep.file.filename);
try {
URL libDownload = new URL(dep.url + '/' + dep.fileName());
URL libDownload = new URL(dep.url + '/' + dep.file.filename);
downloadMonitor.updateProgressString("Downloading file %s", libDownload.toString());
System.out.format("Downloading file %s\n", libDownload.toString());
URLConnection connection = libDownload.openConnection();
@@ -332,7 +350,7 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
System.exit(1);
return;
}
downloadMonitor.showErrorDialog(dep.fileName(), dep.url + '/' + dep.fileName());
downloadMonitor.showErrorDialog(dep.file.filename, dep.url + '/' + dep.file.filename);
throw new RuntimeException("A download error occured", e);
}
}
@@ -391,10 +409,10 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
}
}
private String checkExisting(String[] dependency) {
private String checkExisting(Dependency dep) {
for (File f : modsDir.listFiles()) {
String[] split = splitFileName(f.getName());
if (split == null || !split[0].equals(dependency[0]))
VersionedFile vfile = new VersionedFile(f.getName(), dep.file.pattern);
if (!vfile.matches() || !vfile.name.equals(dep.file.name))
continue;
if (f.renameTo(new File(v_modsDir, f.getName())))
@@ -404,21 +422,18 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
}
for (File f : v_modsDir.listFiles()) {
String[] split = splitFileName(f.getName());
if (split == null || !split[0].equals(dependency[0]))
VersionedFile vfile = new VersionedFile(f.getName(), dep.file.pattern);
if (!vfile.matches() || !vfile.name.equals(dep.file.name))
continue;
ComparableVersion found = new ComparableVersion(split[1]);
ComparableVersion requested = new ComparableVersion(dependency[1]);
int cmp = found.compareTo(requested);
int cmp = vfile.version.compareTo(dep.file.version);
if (cmp < 0) {
System.out.println("Deleted old version " + f.getName());
deleteMod(f);
return null;
}
if (cmp > 0) {
System.err.println("Warning: version of " + dependency[0] + ", " + split[1] + " is newer than request " + dependency[1]);
System.err.println("Warning: version of " + dep.file.name + ", " + vfile.version + " is newer than request " + dep.file.version);
return f.getName();
}
return f.getName();//found dependency
@@ -436,7 +451,7 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
}
private void activateDeps() {
for (Dependancy dep : depMap.values())
for (Dependency dep : depMap.values())
if (dep.coreLib)
addClasspath(dep.existing);
}
@@ -446,7 +461,7 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
try {
while (!depSet.isEmpty()) {
Iterator<String> it = depSet.iterator();
Dependancy dep = depMap.get(it.next());
Dependency dep = depMap.get(it.next());
it.remove();
load(dep);
}
@@ -458,12 +473,12 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
}
}
private void load(Dependancy dep) {
dep.existing = checkExisting(dep.filesplit);
private void load(Dependency dep) {
dep.existing = checkExisting(dep);
if (dep.existing == null)//download dep
{
download(dep);
dep.existing = dep.fileName();
dep.existing = dep.file.filename;
}
}
@@ -521,31 +536,42 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
return;
String repo = node.get("repo").getAsString();
String file = node.get("file").getAsString();
String filename = node.get("file").getAsString();
if (!obfuscated && node.has("dev"))
file = node.get("dev").getAsString();
filename = node.get("dev").getAsString();
boolean coreLib = node.has("coreLib") && node.get("coreLib").getAsBoolean();
String[] split = splitFileName(file);
if (split == null)
throw new RuntimeException("Invalid filename format for dependency: " + file);
Pattern pattern = null;
try {
if(node.has("pattern"))
pattern = Pattern.compile(node.get("pattern").getAsString());
} catch (PatternSyntaxException e) {
System.err.println("Invalid filename pattern: "+node.get("pattern"));
e.printStackTrace();
}
if(pattern == null)
pattern = Pattern.compile("(\\w+).*?([\\d\\.]+)[-\\w]*\\.[^\\d]+");
addDep(new Dependancy(repo, split, coreLib));
VersionedFile file = new VersionedFile(filename, pattern);
if (!file.matches())
throw new RuntimeException("Invalid filename format for dependency: " + filename);
addDep(new Dependency(repo, file, coreLib));
}
private void addDep(Dependancy newDep) {
if (mergeNew(depMap.get(newDep.getName()), newDep)) {
depMap.put(newDep.getName(), newDep);
depSet.add(newDep.getName());
private void addDep(Dependency newDep) {
if (mergeNew(depMap.get(newDep.file.name), newDep)) {
depMap.put(newDep.file.name, newDep);
depSet.add(newDep.file.name);
}
}
private boolean mergeNew(Dependancy oldDep, Dependancy newDep) {
private boolean mergeNew(Dependency oldDep, Dependency newDep) {
if (oldDep == null)
return true;
Dependancy newest = newDep.version.compareTo(oldDep.version) > 0 ? newDep : oldDep;
Dependency newest = newDep.file.version.compareTo(oldDep.file.version) > 0 ? newDep : oldDep;
newest.coreLib = newDep.coreLib || oldDep.coreLib;
return newest == newDep;
@@ -559,15 +585,6 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
}
}
private static String[] splitFileName(String filename) {
Pattern p = Pattern.compile("(.+?)([\\d\\.\\w]+)(\\.[^\\d]+)");
Matcher m = p.matcher(filename);
if (!m.matches())
return null;
return new String[]{m.group(1), m.group(2), m.group(3)};
}
@Override
public String[] getASMTransformerClass() {
return null;