From 3b3600d44fb3f70bf68aab115b1009bc7f2c77d8 Mon Sep 17 00:00:00 2001 From: LexManos Date: Mon, 19 Nov 2012 17:45:53 -0800 Subject: [PATCH] Modified merger to just consider all server classes as common. And moved the defnition of CodecMus to the config. --- .../common/asm/transformers/MCPMerger.java | 30 +++++++------- install/fml.py | 41 ++++++++----------- mcp_merge.cfg | 21 +--------- .../minecraft/src/IBossDisplayData.java.patch | 4 +- 4 files changed, 35 insertions(+), 61 deletions(-) rename patches/{common => minecraft}/net/minecraft/src/IBossDisplayData.java.patch (61%) diff --git a/common/cpw/mods/fml/common/asm/transformers/MCPMerger.java b/common/cpw/mods/fml/common/asm/transformers/MCPMerger.java index 4d2625713f..e1cc0e4442 100644 --- a/common/cpw/mods/fml/common/asm/transformers/MCPMerger.java +++ b/common/cpw/mods/fml/common/asm/transformers/MCPMerger.java @@ -45,6 +45,7 @@ public class MCPMerger private static Hashtable servers = new Hashtable(); private static HashSet copyToServer = new HashSet(); private static HashSet copyToClient = new HashSet(); + private static HashSet dontAnnotate = new HashSet(); private static final boolean DEBUG = false; public static void main(String[] args) @@ -134,11 +135,16 @@ public class MCPMerger String line; while ((line = br.readLine()) != null) { - line = line.split("#")[0]; - boolean toClient = line.charAt(0) == '<'; + line = line.split("#")[0]; + char cmd = line.charAt(0); line = line.substring(1).trim(); - if (toClient) copyToClient.add(line); - else copyToServer.add(line); + + switch (cmd) + { + case '!': dontAnnotate.add(line); break; + case '<': copyToClient.add(line); break; + case '>': copyToServer.add(line); break; + } } in.close(); @@ -225,20 +231,14 @@ public class MCPMerger cAdded.add(name); sAdded.add(name); } + for (Entry entry : sClasses.entrySet()) { - if (!copyToClient.contains(entry.getKey())) + if (DEBUG) { - copyClass(sInJar, entry.getValue(), null, sOutJar, false); - } - else - { - if (DEBUG) - { - System.out.println("Copy class s->c : " + entry.getKey()); - } - copyClass(sInJar, entry.getValue(), cOutJar, sOutJar, false); + System.out.println("Copy class s->c : " + entry.getKey()); } + copyClass(sInJar, entry.getValue(), cOutJar, sOutJar, false); } for (String name : new String[]{SideOnly.class.getName(), Side.class.getName()}) @@ -289,7 +289,7 @@ public class MCPMerger reader.accept(classNode, 0); - if (!classNode.name.equals("beg")) //Special case CodecMus so I dont have to make a new patch, anyone who uses this in production code is.. bad. + if (!dontAnnotate.contains(classNode.name)) { if (classNode.visibleAnnotations == null) classNode.visibleAnnotations = new ArrayList(); classNode.visibleAnnotations.add(getSideAnn(isClientOnly)); diff --git a/install/fml.py b/install/fml.py index e4295688d5..e302467dea 100644 --- a/install/fml.py +++ b/install/fml.py @@ -401,38 +401,31 @@ def merge_client_server(mcp_dir): if not os.path.isdir(shared): os.makedirs(shared) - client_classes = [] server_classes = [] - - zip = ZipFile(client_jar) - for i in zip.filelist: - if i.filename.endswith('.class'): - client_classes.append(i.filename[:-6]) zip = ZipFile(server_jar) for i in zip.filelist: if i.filename.endswith('.class'): server_classes.append(i.filename[:-6]) - for cls in client_classes: - if cls in server_classes: - if cls in joined_srg.keys(): - cls = joined_srg[cls] - cls += '.java' + for cls in server_classes: + if cls in joined_srg.keys(): + cls = joined_srg[cls] + cls += '.java' + + f_client = os.path.normpath(os.path.join(client, cls.replace('/', os.path.sep))).replace(os.path.sep, '/') + f_shared = os.path.normpath(os.path.join(shared, cls.replace('/', os.path.sep))).replace(os.path.sep, '/') + + if not os.path.isfile(f_client): + print 'Issue Merging File Not Found: ' + cls + continue - f_client = os.path.normpath(os.path.join(client, cls.replace('/', os.path.sep))).replace(os.path.sep, '/') - f_shared = os.path.normpath(os.path.join(shared, cls.replace('/', os.path.sep))).replace(os.path.sep, '/') + if not cls.rfind('/') == -1: + new_dir = os.path.join(shared, cls.rsplit('/', 1)[0]) + if not os.path.isdir(new_dir): + os.makedirs(new_dir) - if not os.path.isfile(f_client): - print 'Issue Merging File Not Found: ' + cls - continue - - if not cls.rfind('/') == -1: - new_dir = os.path.join(shared, cls.rsplit('/', 1)[0]) - if not os.path.isdir(new_dir): - os.makedirs(new_dir) - - shutil.move(f_client, f_shared) + shutil.move(f_client, f_shared) cleanDirs(client) @@ -728,7 +721,7 @@ def get_conf_copy(mcp_dir, fml_dir): common_srg = gen_merged_srg(mcp_dir, fml_dir) common_exc = gen_merged_exc(mcp_dir, fml_dir) common_map = gen_shared_searge_names(common_srg, common_exc) - #ToDo use common_map to merge the remaining csvs, client taking precidense, setting the common items to side '2' and editing commands.py in FML to have 'if csv_side == side || csv_side == '2'' + gen_merged_csv(common_map, os.path.join(mcp_dir, 'conf', 'fields.csv'), os.path.join(fml_dir, 'conf', 'fields.csv')) gen_merged_csv(common_map, os.path.join(mcp_dir, 'conf', 'methods.csv'), os.path.join(fml_dir, 'conf', 'methods.csv')) gen_merged_csv(common_map, os.path.join(mcp_dir, 'conf', 'params.csv'), os.path.join(fml_dir, 'conf', 'params.csv'), main_key='param') diff --git a/mcp_merge.cfg b/mcp_merge.cfg index acc8dc80dc..4aac7762b6 100644 --- a/mcp_merge.cfg +++ b/mcp_merge.cfg @@ -1,20 +1 @@ ->pl #net/minecraft/src/IBossDisplayData ->ji #net/minecraft/src/IStatStringFormat ->xu #net/minecraft/src/ColorizerGrass ->xr #net/minecraft/src/ColorizerFoliage ->aom #org/bouncycastle/crypto/CipherKeyGenerator ->aor #org/bouncycastle/crypto/KeyGenerationParameters ->jw #net/minecraft/src/HttpUtilRunnable ->uw #net/minecraft/src/EnumRarity ->aid #net/minecraft/src/SaveFormatComparator ->jx #net/minecraft/src/IDownloadSuccess -