mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-16 10:34:49 +00:00
Cleaned up the AT config updater, should work for any setup of the MCP workspace now.
This commit is contained in:
1 parent
fa567014a5
commit
2dc3f0ddef
2 files changed
+93
-72
No files matched your search
+1
-1
@@ -757,7 +757,7 @@ def gen_merged_srg(mcp_dir, fml_dir):
|
|||||||
|
|
||||||
#Print joined retroguard files
|
#Print joined retroguard files
|
||||||
if fml_dir is None:
|
if fml_dir is None:
|
||||||
return common
|
return common
|
||||||
|
|
||||||
with open(os.path.join(fml_dir, 'conf', 'joined.srg'), 'wb') as f:
|
with open(os.path.join(fml_dir, 'conf', 'joined.srg'), 'wb') as f:
|
||||||
for type in ['PK:', 'CL:', 'FD:', 'MD:']:
|
for type in ['PK:', 'CL:', 'FD:', 'MD:']:
|
||||||
|
|||||||
+92
-71
@@ -1,80 +1,101 @@
|
|||||||
import os, os.path, sys
|
import os, os.path, sys
|
||||||
import urllib, zipfile
|
|
||||||
import shutil, glob, fnmatch
|
import shutil, glob, fnmatch
|
||||||
import subprocess, logging, re, shlex
|
import csv, re
|
||||||
import csv
|
|
||||||
|
|
||||||
print(os.getcwd())
|
|
||||||
sys.path.append('install')
|
|
||||||
from fml import gen_merged_srg
|
|
||||||
ctorsigre = re.compile('<init>\((.*)\)')
|
ctorsigre = re.compile('<init>\((.*)\)')
|
||||||
ctorparamre = re.compile('(([ZBCSIJFD]|L([\w\/]+);))')
|
ctorparamre = re.compile('(([ZBCSIJFD]|L([\w\/]+);))')
|
||||||
common = gen_merged_srg('..',None)
|
|
||||||
rev_common = {t:{v.split(' ')[0]:k for k, v in m.items()} for t,m in common.items()}
|
|
||||||
|
|
||||||
if len(sys.argv) < 2:
|
def get_merged_info():
|
||||||
print('Give me a file to process please')
|
mcp_dir = os.path.join(os.getcwd(), '..')
|
||||||
sys.exit(1)
|
joined = os.path.join(mcp_dir, 'conf', 'joined.srg')
|
||||||
print(sys.argv, len(sys.argv))
|
values = {'PK:': {}, 'CL:': {}, 'FD:': {}, 'MD:': {}}
|
||||||
|
|
||||||
if sys.argv[1]=='mcp_merge.cfg':
|
if not os.path.isfile(joined):
|
||||||
print('Fixing mcp_merge.cfg')
|
sys.path.append('install')
|
||||||
with open('mcp_merge.cfg-new','w') as nf:
|
from fml import gen_merged_srg
|
||||||
with open(sys.argv[1]) as f:
|
values = gen_merged_srg(mcp_dir, None)
|
||||||
for line in f:
|
else:
|
||||||
parts = line.split('#')
|
with open(joined, 'r') as fh:
|
||||||
target = parts[1].strip()
|
for line in fh:
|
||||||
newpart = parts[0][0]+rev_common['CL:'][target]+" #"+target+'\n'
|
pts = line.rstrip('\r\n').split(' ')
|
||||||
nf.write(newpart)
|
if pts[0] == 'MD:':
|
||||||
sys.exit(0)
|
values[pts[0]][pts[1] + ' ' + pts[2]] = pts[3] + ' ' + pts[4]
|
||||||
elif len(sys.argv)==2:
|
else:
|
||||||
with open(sys.argv[1]+'-new','w') as nf:
|
values[pts[0]][pts[1]] = pts[2]
|
||||||
with open(sys.argv[1]) as f:
|
|
||||||
for line in f:
|
|
||||||
parts = line.split('#')
|
|
||||||
if len(parts[1])<4:
|
|
||||||
nf.write(line)
|
|
||||||
continue
|
|
||||||
typ = parts[1][0:3]
|
|
||||||
if not rev_common.has_key(typ):
|
|
||||||
nf.write(line)
|
|
||||||
continue
|
|
||||||
name = parts[1][3:].strip()
|
|
||||||
action = parts[0].split(' ')
|
|
||||||
if name.endswith('/*'):
|
|
||||||
targ = rev_common['CL:']['net/minecraft/src/'+name[:-2]]
|
|
||||||
if typ == 'MD:':
|
|
||||||
wildcard = '.*()'
|
|
||||||
else:
|
|
||||||
wildcard = '.*'
|
|
||||||
newline = action[0]+' '+targ+wildcard+' #'+'#'.join(parts[1:])
|
|
||||||
nf.write(newline)
|
|
||||||
elif name.find('/<init>')>=0:
|
|
||||||
targ = rev_common['CL:']['net/minecraft/src/'+name[:name.find('/<init>')]]
|
|
||||||
args = '<init>('
|
|
||||||
armatch = ctorsigre.search(name).group(1)
|
|
||||||
for bit in ctorparamre.findall(armatch):
|
|
||||||
if len(bit[2])>0 and rev_common['CL:'].has_key(bit[2]):
|
|
||||||
cl = 'L'+rev_common['CL:'][bit[2]]+';'
|
|
||||||
else:
|
|
||||||
cl = bit[1]
|
|
||||||
args+=cl
|
|
||||||
args+=')V'
|
|
||||||
print(line.strip())
|
|
||||||
newline = action[0]+' '+targ+'.'+args+' #'+'#'.join(parts[1:])
|
|
||||||
print(newline.strip())
|
|
||||||
nf.write(newline)
|
|
||||||
else:
|
|
||||||
targ = rev_common[typ]['net/minecraft/src/'+name]
|
|
||||||
newline = action[0]+' '+targ.replace('/','.',1).replace(' ','',1)+' #'+'#'.join(parts[1:])
|
|
||||||
nf.write(newline)
|
|
||||||
else:
|
|
||||||
typ = sys.argv[1]
|
|
||||||
name = sys.argv[2]
|
|
||||||
name = name.replace('.','/')
|
|
||||||
if typ.startswith('-'):
|
|
||||||
print(rev_common[typ[1:]][name])
|
|
||||||
else:
|
|
||||||
print(common[typ][name])
|
|
||||||
|
|
||||||
|
return {t:{v.split(' ')[0]:k for k, v in m.items()} for t,m in values.items()}
|
||||||
|
|
||||||
|
def process_file(file, srg):
|
||||||
|
name = os.path.basename(file)
|
||||||
|
print 'Processing: ' + name
|
||||||
|
|
||||||
|
if name == 'mcp_merge.cfg':
|
||||||
|
with open(file + '-new','w') as nf:
|
||||||
|
with open(file) as f:
|
||||||
|
for line in f:
|
||||||
|
parts = line.split('#')
|
||||||
|
target = parts[1].strip()
|
||||||
|
newpart = '%s%s #%s\n' % (parts[0][0], srg['CL:'][target], target)
|
||||||
|
nf.write(newpart)
|
||||||
|
else:
|
||||||
|
with open(file + '-new', 'w') as nf:
|
||||||
|
with open(file) as f:
|
||||||
|
for line in f:
|
||||||
|
parts = line.split('#')
|
||||||
|
|
||||||
|
if len(parts[1]) < 4:
|
||||||
|
nf.write(line)
|
||||||
|
continue
|
||||||
|
|
||||||
|
typ = parts[1][0:3]
|
||||||
|
|
||||||
|
if not srg.has_key(typ):
|
||||||
|
nf.write(line)
|
||||||
|
continue
|
||||||
|
|
||||||
|
name = parts[1][3:].strip()
|
||||||
|
name = (name if name.startswith('net/minecraft/') else 'net/minecraft/src/' + name)
|
||||||
|
action = parts[0].split(' ')
|
||||||
|
|
||||||
|
if name.endswith('/*'):
|
||||||
|
targ = srg['CL:'][name[:-2]]
|
||||||
|
wildcard = ('.*()' if typ == 'MD:' else '.*')
|
||||||
|
|
||||||
|
newline = '%s %s%s #%s' % (action[0], targ, wildcard, '#'.join(parts[1:]))
|
||||||
|
nf.write(newline)
|
||||||
|
|
||||||
|
elif name.find('/<init>') >= 0:
|
||||||
|
targ = srg['CL:'][name[:name.find('/<init>')]]
|
||||||
|
args = '<init>('
|
||||||
|
armatch = ctorsigre.search(name).group(1)
|
||||||
|
for bit in ctorparamre.findall(armatch):
|
||||||
|
if len(bit[2]) > 0 and srg['CL:'].has_key(bit[2]):
|
||||||
|
cl = 'L' + srg['CL:'][bit[2]] + ';'
|
||||||
|
else:
|
||||||
|
cl = bit[1]
|
||||||
|
args += cl
|
||||||
|
args += ')V'
|
||||||
|
newline = ('%s %s.%s #%s' % (action[0], targ, args, '#'.join(parts[1:])))
|
||||||
|
nf.write(newline)
|
||||||
|
|
||||||
|
else:
|
||||||
|
targ = srg[typ][name]
|
||||||
|
args = targ.replace('/', '.', 1).replace(' ', '', 1)
|
||||||
|
newline = ('%s %s #%s' % (action[0], args, '#'.join(parts[1:])))
|
||||||
|
nf.write(newline)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
srg = get_merged_info()
|
||||||
|
for arg in sys.argv:
|
||||||
|
path = os.path.join(os.getcwd(), arg)
|
||||||
|
|
||||||
|
if arg.endswith('_at.cfg') or arg == 'mcp_merge.cfg':
|
||||||
|
process_file(path, srg)
|
||||||
|
elif os.path.isdir(path):
|
||||||
|
for file in os.listdir(path):
|
||||||
|
if file.endswith('_at.cfg'):
|
||||||
|
process_file(os.path.join(path, file), srg)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
||||||
Reference in new issue
Block a user