2012-08-02 07:51:51 +00:00
|
|
|
--- commands.py
|
|
|
|
+++ commands.py
|
2012-08-09 01:53:41 +00:00
|
|
|
@@ -58,6 +58,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
def reallyrmtree(path):
|
|
|
|
+ if os.path.isfile(os.path.join(path, 'asm-all-4.0.jar')): #Check if asm exists, indicating the libs folder, if so, don't delete it
|
|
|
|
+ return
|
|
|
|
if not sys.platform.startswith('win'):
|
|
|
|
if os.path.exists(path):
|
|
|
|
shutil.rmtree(path)
|
2012-08-16 16:22:56 +00:00
|
|
|
@@ -584,6 +586,9 @@
|
2012-08-03 04:14:06 +00:00
|
|
|
self.has_astyle_cfg = False
|
|
|
|
if os.path.isfile(self.astyleconf):
|
|
|
|
self.has_astyle_cfg = True
|
|
|
|
+
|
|
|
|
+ #FML Entries
|
2012-08-02 07:51:51 +00:00
|
|
|
+ self.srcshared = os.path.normpath(os.path.join(self.dirsrc, 'common'))
|
2012-08-03 04:14:06 +00:00
|
|
|
|
|
|
|
def creatergcfg(self, reobf=False, keep_lvt=False, keep_generics=False, rg_update=False):
|
|
|
|
"""Create the files necessary for RetroGuard"""
|
2012-10-31 14:40:40 +00:00
|
|
|
@@ -781,13 +786,16 @@
|
2012-08-08 12:48:06 +00:00
|
|
|
testlk = {CLIENT: self.testclient, SERVER: self.testserver}
|
|
|
|
|
|
|
|
if not os.path.exists(os.path.join(srclk[side], os.path.normpath(testlk[side] + '.java'))):
|
|
|
|
- return False
|
|
|
|
+ if not os.path.exists(os.path.join(self.srcshared, os.path.normpath(testlk[side] + '.java'))):
|
|
|
|
+ return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
def checkbins(self, side):
|
2012-10-31 14:40:40 +00:00
|
|
|
binlk = {CLIENT: self.binclient, SERVER: self.binserver}
|
|
|
|
testlk = {CLIENT: self.testclient, SERVER: self.testserver}
|
|
|
|
|
|
|
|
+ if side == SERVER:
|
|
|
|
+ return self.checkbins(CLIENT)
|
|
|
|
if not os.path.exists(os.path.join(binlk[side], os.path.normpath(testlk[side] + '.class'))):
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
@@ -1029,6 +1037,10 @@
|
2012-08-14 04:02:55 +00:00
|
|
|
pathsrclk = {CLIENT: self.srcclient, SERVER: self.srcserver}
|
|
|
|
pathlog = {CLIENT: self.clientrecomplog, SERVER: self.serverrecomplog}
|
|
|
|
|
|
|
|
+ if side == SERVER: #Disable server because FML recombines it into client
|
2012-08-15 02:24:49 +00:00
|
|
|
+ self.logger.info('Server side recompiling skipped, this is normal')
|
2012-08-14 04:02:55 +00:00
|
|
|
+ return
|
|
|
|
+
|
|
|
|
if not os.path.exists(pathbinlk[side]):
|
|
|
|
os.makedirs(pathbinlk[side])
|
|
|
|
|
2012-10-31 14:40:40 +00:00
|
|
|
@@ -1041,6 +1053,7 @@
|
2012-08-08 03:11:37 +00:00
|
|
|
all_files = True
|
|
|
|
append_pattern = False
|
|
|
|
pkglist = filterdirs(pathsrclk[side], '*.java', append_pattern=append_pattern, all_files=all_files)
|
|
|
|
+ pkglist = pkglist + filterdirs(self.srcshared, '*.java', append_pattern=append_pattern, all_files=all_files) #FML, Add Common folder
|
|
|
|
dirs = ' '.join(pkglist)
|
|
|
|
classpath = os.pathsep.join(cplk[side])
|
|
|
|
forkcmd = self.cmdrecomp.format(classpath=classpath, sourcepath=pathsrclk[side], outpath=pathbinlk[side],
|
2012-10-31 14:40:40 +00:00
|
|
|
@@ -1062,7 +1075,7 @@
|
2012-08-10 19:38:59 +00:00
|
|
|
raise
|
|
|
|
|
|
|
|
def startserver(self):
|
|
|
|
- classpath = [self.binserver] + self.cpathserver
|
2012-10-31 14:40:40 +00:00
|
|
|
+ classpath = [self.binclient, self.srcshared] + self.cpathserver
|
2012-08-10 19:38:59 +00:00
|
|
|
classpath = [os.path.join('..', p) for p in classpath]
|
|
|
|
classpath = os.pathsep.join(classpath)
|
|
|
|
os.chdir(self.dirjars)
|
2012-10-31 14:40:40 +00:00
|
|
|
@@ -1070,7 +1083,7 @@
|
2012-08-10 19:38:59 +00:00
|
|
|
self.runmc(forkcmd)
|
|
|
|
|
|
|
|
def startclient(self):
|
|
|
|
- classpath = [self.binclient] + self.cpathclient
|
|
|
|
+ classpath = [self.binclient, self.srcshared] + self.cpathclient
|
|
|
|
classpath = [os.path.join('..', p) for p in classpath]
|
|
|
|
classpath = os.pathsep.join(classpath)
|
|
|
|
natives = os.path.join('..', self.dirnatives)
|
2012-10-31 14:40:40 +00:00
|
|
|
@@ -1197,20 +1210,20 @@
|
2012-08-04 10:34:34 +00:00
|
|
|
with open(self.csvmethods, 'rb') as fh:
|
|
|
|
methodsreader = csv.DictReader(fh)
|
|
|
|
for row in methodsreader:
|
|
|
|
- if int(row['side']) == side:
|
|
|
|
+ if int(row['side']) == side or int(row['side']) == 2:
|
|
|
|
if row['name'] != row['searge']:
|
|
|
|
names['methods'][row['searge']] = row['name']
|
|
|
|
with open(self.csvfields, 'rb') as fh:
|
|
|
|
fieldsreader = csv.DictReader(fh)
|
|
|
|
for row in fieldsreader:
|
|
|
|
- if int(row['side']) == side:
|
|
|
|
+ if int(row['side']) == side or int(row['side']) == 2:
|
|
|
|
if row['name'] != row['searge']:
|
|
|
|
names['fields'][row['searge']] = row['name']
|
|
|
|
if self.has_param_csv:
|
|
|
|
with open(self.csvparams, 'rb') as fh:
|
|
|
|
paramsreader = csv.DictReader(fh)
|
|
|
|
for row in paramsreader:
|
|
|
|
- if int(row['side']) == side:
|
|
|
|
+ if int(row['side']) == side or int(row['side']) == 2:
|
|
|
|
names['params'][row['param']] = row['name']
|
|
|
|
|
|
|
|
regexps = {
|
2012-10-31 14:40:40 +00:00
|
|
|
@@ -1240,6 +1253,11 @@
|
2012-08-02 07:51:51 +00:00
|
|
|
|
|
|
|
# HINT: We pathwalk the sources
|
|
|
|
for path, _, filelist in os.walk(pathsrclk[side], followlinks=True):
|
|
|
|
+ for cur_file in fnmatch.filter(filelist, '*.java'):
|
|
|
|
+ updatefile(os.path.normpath(os.path.join(path, cur_file)))
|
|
|
|
+
|
|
|
|
+ # FML, copy of the above, for the common folder
|
|
|
|
+ for path, _, filelist in os.walk(self.srcshared, followlinks=True):
|
|
|
|
for cur_file in fnmatch.filter(filelist, '*.java'):
|
|
|
|
updatefile(os.path.normpath(os.path.join(path, cur_file)))
|
|
|
|
return True
|
2012-10-31 14:40:40 +00:00
|
|
|
@@ -1322,12 +1340,14 @@
|
2012-08-08 03:11:37 +00:00
|
|
|
pathsrclk = {CLIENT: self.srcclient, SERVER: self.srcserver}
|
|
|
|
|
|
|
|
strip_comments(pathsrclk[side])
|
|
|
|
+ strip_comments(self.srcshared)
|
|
|
|
|
|
|
|
def process_cleanup(self, side):
|
|
|
|
"""Do lots of random cleanups including stripping comments, trailing whitespace and extra blank lines"""
|
|
|
|
pathsrclk = {CLIENT: self.srcclient, SERVER: self.srcserver}
|
|
|
|
|
|
|
|
src_cleanup(pathsrclk[side], fix_imports=True, fix_unicode=True, fix_charval=True, fix_pi=True, fix_round=False)
|
|
|
|
+ src_cleanup(self.srcshared, fix_imports=True, fix_unicode=True, fix_charval=True, fix_pi=True, fix_round=False)
|
|
|
|
|
|
|
|
def process_javadoc(self, side):
|
|
|
|
"""Add CSV descriptions to methods and fields as javadoc"""
|
2012-10-31 14:40:40 +00:00
|
|
|
@@ -1336,6 +1356,21 @@
|
2012-08-08 03:11:37 +00:00
|
|
|
if not self.has_doc_csv:
|
|
|
|
self.logger.warning('!! javadoc disabled due to no csvs !!')
|
2012-08-02 07:51:51 +00:00
|
|
|
return False
|
|
|
|
+
|
|
|
|
+ #FML Recall this function on the common folder
|
|
|
|
+ #Potential bug: If this is called without a subsiquent rename call, will cause double comments
|
|
|
|
+ if pathsrclk[side] != self.srcshared:
|
|
|
|
+ if side == CLIENT:
|
|
|
|
+ tmp = self.srcclient
|
|
|
|
+ self.srcclient = self.srcshared
|
2012-08-04 10:34:34 +00:00
|
|
|
+ self.process_javadoc(side)
|
2012-08-02 07:51:51 +00:00
|
|
|
+ self.srcclient = tmp
|
|
|
|
+ else:
|
|
|
|
+ tmp = self.srcserver
|
|
|
|
+ self.srcserver = self.srcshared
|
2012-08-04 10:34:34 +00:00
|
|
|
+ self.process_javadoc(side)
|
2012-08-02 07:51:51 +00:00
|
|
|
+ self.srcserver = tmp
|
|
|
|
+
|
|
|
|
|
2012-08-08 03:11:37 +00:00
|
|
|
#HINT: We read the relevant CSVs
|
|
|
|
methodsreader = csv.DictReader(open(self.csvmethods, 'r'))
|
2012-10-31 14:40:40 +00:00
|
|
|
@@ -1344,13 +1379,13 @@
|
2012-08-08 03:11:37 +00:00
|
|
|
methods = {}
|
|
|
|
for row in methodsreader:
|
|
|
|
#HINT: Only include methods that have a non-empty description
|
|
|
|
- if int(row['side']) == side and row['desc']:
|
|
|
|
+ if (int(row['side']) == side or int(row['side']) == 2) and row['desc']:
|
|
|
|
methods[row['searge']] = row['desc'].replace('*/', '* /')
|
|
|
|
|
|
|
|
fields = {}
|
|
|
|
for row in fieldsreader:
|
|
|
|
#HINT: Only include fields that have a non-empty description
|
|
|
|
- if int(row['side']) == side and row['desc']:
|
|
|
|
+ if (int(row['side']) == side or int(row['side']) == 2) and row['desc']:
|
|
|
|
fields[row['searge']] = row['desc'].replace('*/', '* /')
|
|
|
|
|
|
|
|
regexps = {
|
2012-10-31 14:40:40 +00:00
|
|
|
@@ -1422,12 +1457,13 @@
|
2012-08-08 03:11:37 +00:00
|
|
|
|
2012-08-02 07:51:51 +00:00
|
|
|
# HINT: We create the list of source directories based on the list of packages
|
|
|
|
pkglist = filterdirs(pathsrclk[side], '*.java', append_pattern=True)
|
2012-08-08 03:11:37 +00:00
|
|
|
+ pkglist = pkglist + filterdirs(self.srcshared, '*.java', append_pattern=True) #FML, Add Common folder
|
|
|
|
dirs = ' '.join(pkglist)
|
|
|
|
forkcmd = self.cmdastyle.format(classes=dirs, conffile=self.astyleconf)
|
|
|
|
self.runcmd(forkcmd)
|
2012-08-14 04:53:52 +00:00
|
|
|
return True
|
|
|
|
|
|
|
|
- def gathermd5s(self, side, reobf=False):
|
|
|
|
+ def gathermd5s(self, side, reobf=False, skip_fml=False):
|
|
|
|
if not reobf:
|
|
|
|
md5lk = {CLIENT: self.md5client, SERVER: self.md5server}
|
|
|
|
else:
|
2012-10-31 14:40:40 +00:00
|
|
|
@@ -1442,6 +1478,9 @@
|
2012-08-14 04:53:52 +00:00
|
|
|
class_path = ''
|
|
|
|
else:
|
|
|
|
class_path += '/'
|
|
|
|
+ if skip_fml:
|
|
|
|
+ if class_path.startswith('cpw/'):
|
|
|
|
+ continue
|
|
|
|
for class_file in fnmatch.filter(filelist, '*.class'):
|
|
|
|
class_name = class_path + os.path.splitext(class_file)[0]
|
|
|
|
bin_file = os.path.normpath(os.path.join(path, class_file))
|
2012-10-31 14:40:40 +00:00
|
|
|
@@ -1594,6 +1633,9 @@
|
2012-08-08 03:11:37 +00:00
|
|
|
sys.exit(1)
|
2012-08-02 07:51:51 +00:00
|
|
|
|
|
|
|
for entry in newfiles:
|
|
|
|
+ if 'commands.py' in entry[0]: #FML, Disable updating of Commands.py
|
|
|
|
+ print 'Update to runtime/commands.py found, but disbled due to using fml'
|
|
|
|
+ continue
|
|
|
|
if entry[3] == 'U':
|
2012-08-08 03:11:37 +00:00
|
|
|
self.logger.info('Retrieving file from server : %s', entry[0])
|
|
|
|
cur_file = os.path.normpath(entry[0])
|
2012-10-31 14:40:40 +00:00
|
|
|
@@ -1614,6 +1656,9 @@
|
2012-08-15 07:50:40 +00:00
|
|
|
md5reoblk = {CLIENT: self.md5reobfclient, SERVER: self.md5reobfserver}
|
|
|
|
outpathlk = {CLIENT: self.srcmodclient, SERVER: self.srcmodserver}
|
|
|
|
src = {CLIENT: self.srcclient, SERVER: self.srcserver}
|
|
|
|
+
|
|
|
|
+ if side == SERVER: #Noop out server side stuff
|
|
|
|
+ return
|
|
|
|
|
|
|
|
# HINT: We need a table for the old md5 and the new ones
|
|
|
|
md5table = {}
|
2012-10-31 14:40:40 +00:00
|
|
|
@@ -1646,6 +1691,7 @@
|
2012-09-16 00:09:34 +00:00
|
|
|
# HINT: We extract the source files for the modified class files
|
|
|
|
for in_class in trgclasses:
|
|
|
|
src_file = os.path.normpath(os.path.join(src[side], in_class + '.java'))
|
|
|
|
+ cmn_file = os.path.normpath(os.path.join(self.srcshared, in_class + '.java'))
|
|
|
|
dest_file = os.path.normpath(os.path.join(outpathlk[side], in_class + '.java'))
|
|
|
|
if os.path.isfile(src_file):
|
|
|
|
if not os.path.exists(os.path.dirname(dest_file)):
|
2012-10-31 14:40:40 +00:00
|
|
|
@@ -1655,4 +1701,15 @@
|
2012-09-16 00:09:34 +00:00
|
|
|
self.logger.info('> Outputted %s to %s', in_class.ljust(35), outpathlk[side])
|
2012-08-12 09:49:39 +00:00
|
|
|
except IOError:
|
|
|
|
self.logger.error('* File %s copy failed', in_class)
|
2012-09-16 00:09:34 +00:00
|
|
|
-
|
|
|
|
+ elif os.path.isfile(cmn_file):
|
|
|
|
+ if not os.path.exists(os.path.dirname(dest_file)):
|
|
|
|
+ os.makedirs(os.path.dirname(dest_file))
|
|
|
|
+ try:
|
|
|
|
+ shutil.copyfile(cmn_file, dest_file)
|
|
|
|
+ self.logger.info('> Outputted %s to %s', in_class.ljust(35), outpathlk[side])
|
|
|
|
+ except IOError:
|
|
|
|
+ self.logger.error('* File %s copy failed', in_class)
|
|
|
|
+
|
2012-08-12 09:49:39 +00:00
|
|
|
+def commands_sanity_check():
|
|
|
|
+ print 'Commands patch applied successfully'
|
2012-08-13 04:17:34 +00:00
|
|
|
+
|