chiark / gitweb /
Allow 'update' and 'buildjni' to accept list of subdir paths to run tools within.
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>
Wed, 7 Mar 2012 06:46:56 +0000 (08:46 +0200)
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>
Fri, 9 Mar 2012 20:41:19 +0000 (22:41 +0200)
This is useful for multi-component projects (main app + libraries in separate
dirs). Older adhoc values (update=no, buildjni=yes) for both options are
retained, except that to ignore jni/ directory, buildjni=no instead of
buildjni=manual should be used now.

Also, if --verbose is given, print message about runnibg ndk-build - native
libraries can be quite big and process long, so this is useful to keep user
in loop. To achieve this, had to global'ize options.

build.py
common.py

index 81c68c643bcf7cd8147cad0c22250a75ab97ffc1..c341dda549c36d50e935da4605ed5c0eec59ffc9 100755 (executable)
--- a/build.py
+++ b/build.py
@@ -149,10 +149,18 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, extlib_dir, tmp_dir,
     tarball.close()
 
     # Build native stuff if required...
-    if thisbuild.get('buildjni', 'no') == 'yes':
+    if thisbuild.get('buildjni') not in (None, 'no'):
+        jni_components = thisbuild.get('buildjni')
+        if jni_components == 'yes':
+            jni_components = ['']
+        else:
+            jni_components = jni_components.split(';')
         ndkbuild = os.path.join(ndk_path, "ndk-build")
-        p = subprocess.Popen([ndkbuild], cwd=root_dir,
-                stdout=subprocess.PIPE)
+        for d in jni_components:
+            if options.verbose:
+                print "Running ndk-build in " + root_dir + '/' + d
+            p = subprocess.Popen([ndkbuild], cwd=root_dir + '/' + d,
+                    stdout=subprocess.PIPE)
         output = p.communicate()[0]
         if p.returncode != 0:
             print output
@@ -327,9 +335,11 @@ def parse_commandline():
 
     return options, args
 
+options = None
 
 def main():
 
+    global options
     # Read configuration...
     execfile('config.py', globals())
     options, args = parse_commandline()
index 1916c9ccf4841d6301538def168fe195b79706a4..3b0decf4bb3ee0c04c0702d9756bb5d680af946c 100644 (file)
--- a/common.py
+++ b/common.py
@@ -687,7 +687,7 @@ def prepare_source(vcs, app, build, build_dir, extlib_dir, sdk_path, ndk_path, j
             raise BuildException("Error running init command")
 
     # Generate (or update) the ant build file, build.xml...
-    if (build.get('update', 'yes') != 'no' and
+    if (build.get('update', '.') != 'no' and
         not build.has_key('maven')):
         parms = [os.path.join(sdk_path, 'tools', 'android'),
                 'update', 'project', '-p', '.']
@@ -695,14 +695,17 @@ def prepare_source(vcs, app, build, build_dir, extlib_dir, sdk_path, ndk_path, j
         if build.has_key('target'):
             parms.append('-t')
             parms.append(build['target'])
+        update_dirs = build.get('update', '.').split(';')
         # Force build.xml update if necessary...
-        if build.get('update', 'yes') == 'force' or build.has_key('target'):
+        if build.get('update', '.') == 'force' or build.has_key('target'):
+            update_dirs = ['.']
             buildxml = os.path.join(root_dir, 'build.xml')
             if os.path.exists(buildxml):
                 print 'Force-removing old build.xml'
                 os.remove(buildxml)
-        if subprocess.call(parms, cwd=root_dir) != 0:
-            raise BuildException("Failed to update project")
+        for d in update_dirs:
+            if subprocess.call(parms, cwd=root_dir + '/' + d) != 0:
+                raise BuildException("Failed to update project")
 
     # If the app has ant set up to sign the release, we need to switch
     # that off, because we want the unsigned apk...
@@ -974,7 +977,7 @@ def scan_source(build_dir, root_dir, thisbuild):
     # Presence of a jni directory without buildjni=yes might
     # indicate a problem...
     if (os.path.exists(os.path.join(root_dir, 'jni')) and 
-            thisbuild.get('buildjni', 'no') == 'no'):
+            thisbuild.get('buildjni') is None):
         msg = 'Found jni directory, but buildjni is not enabled'
         problems.append(msg)