diff --git a/fml/applypatches.py b/fml/applypatches.py
new file mode 100644
index 0000000000..792171297c
--- /dev/null
+++ b/fml/applypatches.py
@@ -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()
diff --git a/fml/build.xml b/fml/build.xml
index 0c3c958a3b..49d5f94b87 100644
--- a/fml/build.xml
+++ b/fml/build.xml
@@ -147,6 +147,12 @@
+
+
+
+
+
+
diff --git a/fml/update_patches.py b/fml/update_patches.py
index 380898c823..14a95c7c25 100644
--- a/fml/update_patches.py
+++ b/fml/update_patches.py
@@ -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: