From 24af895915e3caacb6110ede034ec8fb7520aef1 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Tue, 27 Aug 2013 00:52:04 +0300 Subject: [PATCH] Print progress messages as a build goes thru various stages. Without this, we get bunch of messages at the start of build, which end with "Applying patch", and then all the things hangs for several minutes (or more, in case of network problems, etc). So, consistently keep user aware od what's happening. Note that --verbose switch affects deatiledness and amount of output (in particular, if it's given, "build" command output goes to console instead of log). --- fdroidserver/build.py | 18 ++++++++++++++++-- fdroidserver/common.py | 9 +++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/fdroidserver/build.py b/fdroidserver/build.py index 07e637dc..1cbb935a 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -345,6 +345,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d javacc_path, mvn3, verbose, onserver) # Scan before building... + print "Scanning source for common problems..." buildprobs = common.scan_source(build_dir, root_dir, thisbuild) if len(buildprobs) > 0: print 'Scanner found ' + str(len(buildprobs)) + ' problems:' @@ -355,6 +356,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d str(len(buildprobs)) + " scanned problems") # Build the source tarball right before we build the release... + print "Creating source tarball..." tarname = app['id'] + '_' + thisbuild['vercode'] + '_src' tarball = tarfile.open(os.path.join(tmp_dir, tarname + '.tar.gz'), "w:gz") @@ -369,6 +371,10 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d # Run a build command if one is required... if 'build' in thisbuild: cmd = thisbuild['build'] + if options.verbose: + print "Running custom build commands: " + cmd + else: + print "Running custom build commands..." # Substitute source library paths into commands... for name, libpath in srclibpaths: libpath = os.path.relpath(libpath, root_dir) @@ -376,14 +382,19 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d cmd = cmd.replace('$$SDK$$', sdk_path) cmd = cmd.replace('$$NDK$$', ndk_path) cmd = cmd.replace('$$MVN3$$', mvn3) - p = subprocess.Popen(['bash', '-c', cmd], cwd=root_dir, - stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if options.verbose: + # Note: output goes to console, not log + p = subprocess.Popen(['bash', '-x', '-c', cmd], cwd=root_dir) + else: + p = subprocess.Popen(['bash', '-c', cmd], cwd=root_dir, + 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'): + print "Building native libraries..." jni_components = thisbuild.get('buildjni') if jni_components == 'yes': jni_components = [''] @@ -413,6 +424,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d # Build the release... if 'maven' in thisbuild: + print "Building Maven project..." mvncmd = [mvn3, 'clean', 'package', '-Dandroid.sdk.path=' + sdk_path] if install: mvncmd += ['-Dandroid.sign.debug=true'] @@ -428,6 +440,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d mvncmd += thisbuild['mvnflags'] p = subprocess.Popen(mvncmd, cwd=root_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) elif 'gradle' in thisbuild: + print "Building Gradle project..." if '@' in thisbuild['gradle']: flavour = thisbuild['gradle'].split('@')[0] gradle_dir = thisbuild['gradle'].split('@')[1] @@ -471,6 +484,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d p = subprocess.Popen(commands, cwd=gradle_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) else: + print "Building Ant project..." if install: antcommands = ['debug','install'] elif 'antcommand' in thisbuild: diff --git a/fdroidserver/common.py b/fdroidserver/common.py index aea09bb3..d418f790 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -1315,6 +1315,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, sdk_path, # Add required external libraries... if 'extlibs' in build: + print "Collecting prebuilt libraries..." libsdir = os.path.join(root_dir, 'libs') if not os.path.exists(libsdir): os.mkdir(libsdir) @@ -1326,6 +1327,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, sdk_path, # Get required source libraries... srclibpaths = [] if 'srclibs' in build: + print "Collecting source libraries..." for lib in build['srclibs'].split(';'): name, _ = lib.split('@') srclibpaths.append((name, getsrclib(lib, srclib_dir, sdk_path, ndk_path, mvn3, preponly=onserver))) @@ -1353,6 +1355,11 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, sdk_path, # Run a pre-build command if one is required... if 'prebuild' in build: prebuild = build['prebuild'] + if verbose: + print "Running source init (prebuild) commands:" + prebuild + else: + print "Running source init (prebuild) commands..." + # Substitute source library paths into prebuild commands... for name, libpath in srclibpaths: libpath = os.path.relpath(libpath, root_dir) @@ -1366,6 +1373,8 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, sdk_path, if p.returncode != 0: raise BuildException("Error running pre-build command", out, err) + print "Applying generic clean-ups..." + if build.get('anal-tics', 'no') == 'yes': fp = os.path.join(root_dir, 'src', 'com', 'google', 'android', 'apps', 'analytics') os.makedirs(fp) -- 2.30.2