Add extra build commands that can run after scan/tarball

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.
This commit is contained in:
Ciaran Gultnieks 2013-03-20 09:30:56 +00:00
parent 4b472aed5a
commit 64729ba9fe
4 changed files with 37 additions and 5 deletions

View 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')

View 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)

View 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...