From 50a962db31626cd98a1856995ab855411bd57743 Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Wed, 26 Jan 2011 16:02:30 +0000 Subject: [PATCH] Some build and update system improvements, including the ability to set javac encoding --- README | 5 +++++ build.py | 7 +++++-- metadata.py | 13 +++++++------ update.py | 10 +++++++--- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/README b/README index b04f183c..334b8225 100644 --- a/README +++ b/README @@ -164,6 +164,11 @@ configuration to the build. These are: submodules=yes Use if the project (git only) has submodules - causes git submodule init and update to be executed after the source is cloned. + encoding=xxxx Adds a java.encoding property to local.properties with the given + value. Generally the value will be 'utf-8'. This is picked up by + the SDK's ant rules, and forces the Java compiler to interpret + source files with this encoding. If you receive warnings during + the compile about character encodings, you probably need this. Another example, using extra parameters: diff --git a/build.py b/build.py index 2710491b..3f4bb3dc 100644 --- a/build.py +++ b/build.py @@ -222,6 +222,9 @@ for app in apps: props += "\nsdk-location=" + sdkloc + "\n" # Add ndk location... props+= "\nndk.dir=" + ndk_path + "\n" + # Add java.encoding if necessary... + if thisbuild.has_key('encoding'): + props += "\njava.encoding=" + thisbuild['encoding'] + "\n" f = open(locprops, 'w') f.write(props) f.close() @@ -246,8 +249,8 @@ for app in apps: # Run a pre-build command if one is required... if thisbuild.has_key('prebuild'): - if subprocess.call(shlex.split(thisbuild['prebuild']), - cwd=root_dir) != 0: + if subprocess.call(thisbuild['prebuild'], + cwd=root_dir, shell=True) != 0: print "Error running pre-build command" sys.exit(1) diff --git a/metadata.py b/metadata.py index 2d3d3cf4..8bf114f8 100644 --- a/metadata.py +++ b/metadata.py @@ -16,7 +16,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -def read_metadata(): +def read_metadata(verbose=False): apps = [] @@ -26,7 +26,8 @@ def read_metadata(): # Get metadata... thisinfo['id'] = metafile[9:-4] - print "Reading metadata for " + thisinfo['id'] + if verbose: + print "Reading metadata for " + thisinfo['id'] thisinfo['description'] = '' thisinfo['name'] = None thisinfo['summary'] = '' @@ -82,7 +83,7 @@ def read_metadata(): part != "Tracking" and part != "NonFreeNet" and part != "NonFreeAdd"): - print "Unrecognised antifeature '" + part + "'" + print "Unrecognised antifeature '" + part + "' in "+ metafile sys.exit(1) thisinfo['antifeatures'] = value elif field == 'Market Version': @@ -96,7 +97,7 @@ def read_metadata(): elif field == 'Build Version': parts = value.split(",") if len(parts) < 3: - print "Invalid build format: " + value + print "Invalid build format: " + value + " in " + metafile sys.exit(1) thisbuild = {} thisbuild['version'] = parts[0] @@ -110,7 +111,7 @@ def read_metadata(): if value == "Yes": thisinfo['usebuilt'] = True else: - print "Unrecognised field " + field + print "Unrecognised field " + field + " in " + metafile sys.exit(1) elif mode == 1: if line == '.': @@ -125,7 +126,7 @@ def read_metadata(): thisinfo['description'] += line if mode == 1: - print "Description not terminated" + print "Description not terminated in " + metafile sys.exit(1) if len(thisinfo['description']) == 0: thisinfo['description'] = 'No description available' diff --git a/update.py b/update.py index a8404794..2285a68a 100644 --- a/update.py +++ b/update.py @@ -42,6 +42,8 @@ parser.add_option("-c", "--createmeta", action="store_true", default=False, help="Create skeleton metadata files that are missing") parser.add_option("-v", "--verbose", action="store_true", default=False, help="Spew out even more information than normal") +parser.add_option("-q", "--quiet", action = "store_true", default=False, + help="No output, except for warnings and errors") parser.add_option("-b", "--buildreport", action="store_true", default=False, help="Report on build data status") (options, args) = parser.parse_args() @@ -64,13 +66,14 @@ if (repo_url is None or repo_name is None or sys.exit(1) # Get all apps... -apps = read_metadata() +apps = read_metadata(verbose=options.verbose) # Copy apks and source tarballs for stuff we've built from source that # is flagged to be included in the repo... for app in apps: if app['usebuilt']: - print "Copying built files for " + app['id'] + if not options.quiet: + print "Copying built files for " + app['id'] src = os.path.join('built', app['id'] + "_*") for file in glob.glob(src): shutil.copy(file, 'repo/') @@ -81,7 +84,8 @@ for apkfile in glob.glob(os.path.join('repo','*.apk')): apkfilename = apkfile[5:] - print "Processing " + apkfilename + if not options.quiet: + print "Processing " + apkfilename thisinfo = {} thisinfo['apkname'] = apkfilename thisinfo['size'] = os.path.getsize(apkfile)