chiark / gitweb /
Add extra build commands that can run after scan/tarball
authorCiaran Gultnieks <ciaran@ciarang.com>
Wed, 20 Mar 2013 09:30:56 +0000 (09:30 +0000)
committerCiaran Gultnieks <ciaran@ciarang.com>
Wed, 20 Mar 2013 09:30:56 +0000 (09:30 +0000)
Commands used in the 'build' section are for actual building that
produces binary output. Some existing stuff will need to move from
'prebuild' to this. See manual for more information.

docs/fdroid.texi
fdroidserver/build.py
fdroidserver/common.py
fdroidserver/scanner.py

index 3cc1f5f73d5126ddea0e1059525f68d6cc478d59..09c573809451a0e77fb02fe657f402c760d4e420 100644 (file)
@@ -772,6 +772,11 @@ insert literal commas, or as the last character on a line to join that
 line with the next. It has no special meaning in other contexts; in
 particular, literal backslashes should not be escaped.
 
+Note that nothing should be build during this prebuild phase - scanning
+of the code and building of the source tarball, for example, take place
+after this. For custom actions that actually build things, use 'build'
+instead.
+
 You can use $$name$$ to substitute the path to a referenced srclib - see
 the @code{srclib} directory for details of this.
 
@@ -785,6 +790,15 @@ takes place.
 You can use $$SDK$$, $$NDK$$ and $$MVN3$$ to substitute the paths to the
 android SDK and NDK directories, and maven 3 executable respectively.
 
+@item build=xxxx
+As for 'prebuild', but runs during the actual build phase (but before the
+main ant/maven build). Use this only for actions that do actual building.
+Any prepartion of the source code should be done using 'init' or 'prebuild'.
+
+You can use $$SDK$$, $$NDK$$ and $$MVN3$$ to substitute the paths to the
+android SDK and NDK directories, and maven 3 executable respectively.
+
+
 @item novcheck=yes 
 Don't check that the version name and code in the resulting apk are
 correct by looking at the build output - assume the metadata is
index c2e2fb84d8426e524c5f3463c98ccece03457db3..40d1e987d6a4f7e4c6dcfc23f31d1bd3b572155e 100644 (file)
@@ -265,7 +265,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, extlib_dir, tmp_dir,
     """Do a build locally."""
 
     # Prepare the source code...
-    root_dir = common.prepare_source(vcs, app, thisbuild,
+    root_dir, srclibpaths = common.prepare_source(vcs, app, thisbuild,
             build_dir, extlib_dir, sdk_path, ndk_path,
             javacc_path, mvn3, verbose)
 
@@ -291,6 +291,22 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, extlib_dir, tmp_dir,
     tarball.add(build_dir, tarname, exclude=tarexc)
     tarball.close()
 
+    # Run a build command if one is required...
+    if 'build' in thisbuild:
+        prebuild = build['build']
+        # Substitute source library paths into prebuild commands...
+        for name, libpath in srclibpaths:
+            libpath = os.path.relpath(libpath, root_dir)
+            prebuild = prebuild.replace('$$' + name + '$$', libpath)
+        prebuild = prebuild.replace('$$SDK$$', sdk_path)
+        prebuild = prebuild.replace('$$NDK$$', ndk_path)
+        prebuild = prebuild.replace('$$MVN3$$', mvn3)
+        p = subprocess.Popen(prebuild, cwd=root_dir, shell=True,
+                stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        out, err = p.communicate()
+        if p.returncode != 0:
+            raise BuildException("Error running build command", out, err)
+
     # Build native stuff if required...
     if thisbuild.get('buildjni') not in (None, 'no'):
         jni_components = thisbuild.get('buildjni')
index a948f821db56b0508238691e4dd681383c3119fa..050a0fa84187be0491001cdab17ca033c703ffa2 100644 (file)
@@ -1642,8 +1642,10 @@ def getsrclib(spec, extlib_dir, sdk_path, basepath=False):
 #  'javacc_path' - the path to javacc
 #  'mvn3'        - the path to the maven 3 executable
 #  'verbose'     - optional: verbose or not (default=False)
-# Returns the root directory, which may be the same as 'build_dir' or may
-# be a subdirectory of it.
+# Returns the (root, srclibpaths) where:
+#   'root' is the root directory, which may be the same as 'build_dir' or may
+#          be a subdirectory of it.
+#   'srclibpaths' is information on the srclibs being used
 def prepare_source(vcs, app, build, build_dir, extlib_dir, sdk_path, ndk_path, javacc_path, mvn3, verbose=False):
 
     # Optionally, the actual app source can be in a subdirectory...
@@ -1970,7 +1972,7 @@ def prepare_source(vcs, app, build, build_dir, extlib_dir, sdk_path, ndk_path, j
             'build.properties'], cwd=root_dir) !=0:
             raise BuildException("Failed to amend build.properties")
 
-    return root_dir
+    return (root_dir, srclibpaths)
 
 
 # Scan the source code in the given directory (and all subdirectories)
index 2d307a328242efaca5234fec6195687a66f42fd2..9af74da9fa2853fdd04f7634afaf93bb4a2651e4 100644 (file)
@@ -98,7 +98,7 @@ def main():
                         print "..scanning version " + thisbuild['version']
 
                         # Prepare the source code...
-                        root_dir = common.prepare_source(vcs, app, thisbuild,
+                        root_dir, _ = common.prepare_source(vcs, app, thisbuild,
                                 build_dir, extlib_dir, sdk_path, ndk_path, javacc_path, mvn3, options.verbose)
 
                         # Do the scan...