Added new source clean step to fix linux vs windows astyle issues.

This commit is contained in:
LexManos 2012-05-27 01:52:02 -07:00
parent 2898457766
commit d952a7be49
3 changed files with 38 additions and 3 deletions

View file

@ -185,3 +185,34 @@ def zip_create(path, key, zip_name):
else: else:
zip.write(path, key) zip.write(path, key)
zip.close() zip.close()
count = 0
def cleanup_source(path):
path = os.path.normpath(path)
regex_cases_before = re.compile(r'((case|default).+\r?\n)\r?\n', re.MULTILINE) #Fixes newline after case before case body
regex_cases_after = re.compile(r'\r?\n(\r?\n[ \t]+(case|default))', re.MULTILINE) #Fixes newline after case body before new case
def updatefile(src_file):
global count
tmp_file = src_file + '.tmp'
count = 0
with open(src_file, 'r') as fh:
buf = fh.read()
def fix_cases(match):
global count
count += 1
return match.group(1)
buf = regex_cases_before.sub(fix_cases, buf)
buf = regex_cases_after.sub(fix_cases, buf)
if count > 0:
with open(tmp_file, 'w') as fh:
fh.write(buf)
shutil.move(tmp_file, src_file)
for path, _, filelist in os.walk(path, followlinks=True):
sub_dir = os.path.relpath(path, path)
for cur_file in fnmatch.filter(filelist, '*.java'):
src_file = os.path.normpath(os.path.join(path, cur_file))
updatefile(src_file)

View file

@ -14,7 +14,7 @@ from runtime.updatemd5 import updatemd5
from runtime.cleanup import cleanup from runtime.cleanup import cleanup
from runtime.updatemcp import updatemcp from runtime.updatemcp import updatemcp
from forge import apply_patches, copytree, reset_logger, download_ff from forge import apply_patches, copytree, reset_logger, download_ff, cleanup_source
def main(): def main():
print '=================================== Minecraft Forge Setup Start =================================' print '=================================== Minecraft Forge Setup Start ================================='
@ -50,6 +50,8 @@ def main():
print 'Something went wrong, src folder not found at: %s' % src_dir print 'Something went wrong, src folder not found at: %s' % src_dir
sys.exit(1) sys.exit(1)
cleanup_source(src_dir)
has_client = os.path.isdir(os.path.join(mcp_dir, 'src', 'minecraft')) has_client = os.path.isdir(os.path.join(mcp_dir, 'src', 'minecraft'))
has_server = os.path.isdir(os.path.join(mcp_dir, 'src', 'minecraft_server')) has_server = os.path.isdir(os.path.join(mcp_dir, 'src', 'minecraft_server'))

View file

@ -12,7 +12,7 @@ from runtime.decompile import decompile
from runtime.updatenames import updatenames from runtime.updatenames import updatenames
from runtime.updatemd5 import updatemd5 from runtime.updatemd5 import updatemd5
from forge import apply_patches, copytree, reset_logger, download_ff from forge import apply_patches, copytree, reset_logger, download_ff, cleanup_source
def main(): def main():
@ -39,6 +39,8 @@ def main():
print 'Something went wrong, src folder not found at: %s' % src_dir print 'Something went wrong, src folder not found at: %s' % src_dir
sys.exit(1) sys.exit(1)
cleanup_source(src_dir)
setup_fml() setup_fml()
os.chdir(mcp_dir) os.chdir(mcp_dir)