More build stuff

This commit is contained in:
Christian Weeks 2012-03-30 20:38:31 -04:00
parent 18069778d9
commit e5b4d1e953
3 changed files with 41 additions and 7 deletions

27
fml/applypatches.py Normal file
View File

@ -0,0 +1,27 @@
import sys
import os
import commands
import fnmatch
import re
import subprocess, shlex
def cmdsplit(args):
if os.sep == '\\':
args = args.replace('\\', '\\\\')
return shlex.split(args)
def main():
print("Applying patches")
patches = os.path.abspath(sys.argv[1])
work = os.path.normpath(sys.argv[2])
for path, _, filelist in os.walk(patches, followlinks=True):
for cur_file in fnmatch.filter(filelist, '*.patch'):
patch_file = os.path.normpath(os.path.join(patches, path[len(patches)+1:], cur_file))
print(patch_file)
cmd = 'patch -p1 -i "%s" ' % (patch_file)
process = subprocess.Popen(cmdsplit(cmd), cwd=work, bufsize=-1)
process.communicate()
if __name__ == '__main__':
main()

View File

@ -147,6 +147,12 @@
<target name="build" depends="init,clean,merge-server,patch,build-server,build-source-pack" />
<target name="patch" depends="init">
<exec executable="${python.exe}" dir="${basedir}">
<arg value="${basedir}/applypatches.py"/>
<arg value="${patch.src.dir}"/>
<arg value="${mcp.srcdir}"/>
</exec>
</target>
</project>

View File

@ -27,19 +27,20 @@ def cleanDirs(path):
def main():
print("Creating patches")
base = os.path.normpath(os.path.join(sys.argv[1], 'src-reference'))
work = os.path.normpath(os.path.join(sys.argv[1], 'src-work'))
base = 'src-reference'
work = 'src-work'
patched_dir=os.path.join(sys.argv[1],work)
timestamp = re.compile(r'[0-9-]* [0-9:\.]* [+-][0-9]*\r?\n')
for path, _, filelist in os.walk(work, followlinks=True):
for path, _, filelist in os.walk(patched_dir, followlinks=True):
for cur_file in fnmatch.filter(filelist, '*.java'):
file_base = os.path.normpath(os.path.join(base, path[len(work)+1:], cur_file))
file_work = os.path.normpath(os.path.join(work, path[len(work)+1:], cur_file))
file_base = os.path.normpath(os.path.join(base, path[len(patched_dir)+1:], cur_file))
file_work = os.path.normpath(os.path.join(work, path[len(patched_dir)+1:], cur_file))
patch = ''
cmd = 'diff -u %s %s -r --strip-trailing-cr --new-file' % (file_base, file_work)
process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1)
process = subprocess.Popen(cmdsplit(cmd), cwd=os.path.normpath(sys.argv[1]), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1)
patch, _ = process.communicate()
patch_dir = os.path.join(sys.argv[2]+'patches', path[len(work)+1:])
patch_dir = os.path.join(sys.argv[2],'patches', path[len(work)+1:])
patch_file = os.path.join(patch_dir, cur_file + '.patch')
if len(patch) > 0: