chiark / gitweb /
Patch before running prebuild commands.
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>
Fri, 24 Feb 2012 01:21:00 +0000 (03:21 +0200)
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>
Fri, 24 Feb 2012 01:21:00 +0000 (03:21 +0200)
Sometimes an application provides a script to initialize its build
environment, and it may be required to patch such a script before running
it (typical case is hardcoding developer's local paths). More generally,
"declaritive" ways of changing code (e.g., forceversion, patch, etc.)
should be preferred to prebuild, which should be used as the last resort
(as it is too generic and thus verbose). So, it's right ordering in that
respect either.

common.py

index 48be88eba64201c7dd5404075e7049a0d132246b..b071470ad61f533f1b8371edcce2056a96cbde78 100644 (file)
--- a/common.py
+++ b/common.py
@@ -829,6 +829,15 @@ def prepare_source(vcs, app, build, build_dir, extlib_dir, sdk_path, ndk_path, j
         if os.path.exists(badpath):
             shutil.rmtree(badpath)
 
+    # Apply patches if any
+    if 'patch' in build:
+        for patch in build['patch'].split(';'):
+            print "Applying " + patch
+            patch_path = os.path.join('metadata', app['id'], patch)
+            if subprocess.call(['patch', '-p1',
+                            '-i', os.path.abspath(patch_path)], cwd=build_dir) != 0:
+                raise BuildException("Failed to apply patch %s" % patch_path)
+
     # Run a pre-build command if one is required...
     if build.has_key('prebuild'):
         prebuild = build['prebuild']
@@ -839,15 +848,6 @@ def prepare_source(vcs, app, build, build_dir, extlib_dir, sdk_path, ndk_path, j
         if subprocess.call(prebuild, cwd=root_dir, shell=True) != 0:
             raise BuildException("Error running pre-build command")
 
-    # Apply patches if any
-    if 'patch' in build:
-        for patch in build['patch'].split(';'):
-            print "Applying " + patch
-            patch_path = os.path.join('metadata', app['id'], patch)
-            if subprocess.call(['patch', '-p1',
-                            '-i', os.path.abspath(patch_path)], cwd=build_dir) != 0:
-                raise BuildException("Failed to apply patch %s" % patch_path)
-
     # Special case init functions for funambol...
     if build.get('initfun', 'no')  == "yes":