# We need to clean via the build tool in case the binary dirs are
# different from the default ones
p = None
- if 'maven' in thisbuild:
+ if thisbuild.get('maven', 'no') != 'no':
print "Cleaning Maven project..."
cmd = [config['mvn3'], 'clean', '-Dandroid.sdk.path=' + config['sdk_path']]
if '@' in thisbuild['maven']:
- maven_dir = os.path.join(root_dir, thisbuild['maven'].split('@')[1])
+ maven_dir = os.path.join(root_dir, thisbuild['maven'].split('@',1)[1])
else:
maven_dir = root_dir
p = FDroidPopen(cmd, cwd=maven_dir)
- elif 'gradle' in thisbuild:
+ elif thisbuild.get('gradle', 'no') != 'no':
print "Cleaning Gradle project..."
cmd = [config['gradle'], 'clean']
if '@' in thisbuild['gradle']:
- gradle_dir = os.path.join(root_dir, thisbuild['gradle'].split('@')[1])
+ gradle_dir = os.path.join(root_dir, thisbuild['gradle'].split('@',1)[1])
else:
gradle_dir = root_dir
p = None
# Build the release...
- if 'maven' in thisbuild:
+ if thisbuild.get('maven', 'no') != 'no':
print "Building Maven project..."
if '@' in thisbuild['maven']:
- maven_dir = os.path.join(root_dir, thisbuild['maven'].split('@')[1])
+ maven_dir = os.path.join(root_dir, thisbuild['maven'].split('@',1)[1])
else:
maven_dir = root_dir
p = FDroidPopen(mvncmd, cwd=maven_dir)
- elif 'gradle' in thisbuild:
+ bindir = os.path.join(root_dir, 'target')
+
+ elif thisbuild.get('gradle', 'no') != 'no':
print "Building Gradle project..."
if '@' in thisbuild['gradle']:
flavour = thisbuild['gradle'].split('@')[0]
cmd += ['release']
p = FDroidPopen(cmd, cwd=root_dir)
+ bindir = os.path.join(root_dir, 'bin')
+
if p.returncode != 0:
raise BuildException("Build failed for %s:%s" % (app['id'], thisbuild['version']), p.stdout, p.stderr)
print "Successfully built version " + thisbuild['version'] + ' of ' + app['id']
# Find the apk name in the output...
if 'bindir' in thisbuild:
bindir = os.path.join(build_dir, thisbuild['bindir'])
- elif 'maven' in thisbuild:
- bindir = os.path.join(root_dir, 'target')
- else:
- bindir = os.path.join(root_dir, 'bin')
- if 'maven' in thisbuild:
+
+ if thisbuild.get('maven', 'no') != 'no':
stdout_apk = '\n'.join([
line for line in p.stdout.splitlines() if any(a in line for a in ('.apk','.ap_'))])
m = re.match(r".*^\[INFO\] .*apkbuilder.*/([^/]*)\.apk",
raise BuildException('Failed to find output')
src = m.group(1)
src = os.path.join(bindir, src) + '.apk'
- elif 'gradle' in thisbuild:
+ elif thisbuild.get('gradle', 'no') != 'no':
dd = build_dir
if 'subdir' in thisbuild:
dd = os.path.join(dd, thisbuild['subdir'])
vercode = re.match(pat, line).group(1)
pat = re.compile(".*versionName='([^']*)'.*")
version = re.match(pat, line).group(1)
- if thisbuild.get('novcheck', 'no') == "yes":
+ if thisbuild['novcheck']:
vercode = thisbuild['vercode']
version = thisbuild['version']
if not version or not vercode:
for p in parts[3:]:
pk, pv = p.split('=', 1)
thisbuild[pk.strip()] = pv
+
return thisbuild
def add_comments(key):
thisinfo['comments'].append((key, comment))
del curcomments[:]
+
thisinfo = {}
if metafile:
if not isinstance(metafile, file):
mode = 0
add_comments(None)
+ # These can only contain 'yes' or 'no'
+ for key in ('submodules', 'oldsdkloc', 'forceversion', 'forcevercode', 'fixtrans', 'fixapos', 'novcheck'):
+ for build in thisinfo['builds']:
+ if key not in build:
+ build[key] = False
+ continue
+ if build[key] == 'yes':
+ build[key] = True
+ elif build[key] == 'no':
+ build[key] = False
+ else:
+ raise MetaDataException("Invalid value %s assigned to boolean build flag %s"
+ % (build[key], key))
+
# Mode at end of file should always be 0...
if mode == 1:
raise MetaDataException(field + " not terminated in " + metafile.name)
raise BuildException('Missing subdir ' + root_dir)
# Initialise submodules if requred...
- if build.get('submodules', 'no') == 'yes':
+ if build['submodules']:
if options.verbose:
print "Initialising submodules..."
vcs.initsubmodules()
props += '\n'
# Fix old-fashioned 'sdk-location' by copying
# from sdk.dir, if necessary...
- if build.get('oldsdkloc', 'no') == "yes":
+ if build['oldsdkloc']:
sdkloc = re.match(r".*^sdk.dir=(\S+)$.*", props,
re.S|re.M).group(1)
props += "sdk-location=%s\n" % sdkloc
f.close()
flavour = None
- if 'gradle' in build:
+ if build.get('gradle', 'no') != 'no':
flavour = build['gradle'].split('@')[0]
if flavour in ['main', 'yes', '']:
flavour = None
raise BuildException("Failed to remove debuggable flags")
# Insert version code and number into the manifest if necessary...
- if 'forceversion' in build:
+ if build['forceversion']:
print "Changing the version name..."
for path in manifest_paths(root_dir, flavour):
if not os.path.isfile(path):
's/versionName[ ]*=[ ]*"[^"]*"/versionName = "' + build['version'] + '"/g',
path]) != 0:
raise BuildException("Failed to amend build.gradle")
- if 'forcevercode' in build:
+ if build['forcevercode']:
print "Changing the version code..."
for path in manifest_paths(root_dir, flavour):
if not os.path.isfile(path):
subprocess.call('rm -rf ' + dest, shell=True)
# Fix apostrophes translation files if necessary...
- if build.get('fixapos', 'no') == 'yes':
+ if build['fixapos']:
for root, dirs, files in os.walk(os.path.join(root_dir, 'res')):
for filename in files:
if filename.endswith('.xml'):
raise BuildException("Failed to amend " + filename)
# Fix translation files if necessary...
- if build.get('fixtrans', 'no') == 'yes':
+ if build['fixtrans']:
for root, dirs, files in os.walk(os.path.join(root_dir, 'res')):
for filename in files:
if filename.endswith('.xml'):
if p.returncode != 0:
raise BuildException("Error running prebuild command for %s:%s" %
(app['id'], build['version']), p.stdout, p.stderr)
- 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)
- with open(os.path.join(fp, 'GoogleAnalyticsTracker.java'), 'w') as f:
- f.write("""
- package com.google.android.apps.analytics;
- public class GoogleAnalyticsTracker {
- private static GoogleAnalyticsTracker instance;
- private GoogleAnalyticsTracker() {
- }
- public static GoogleAnalyticsTracker getInstance() {
- if(instance == null)
- instance = new GoogleAnalyticsTracker();
- return instance;
- }
- public void start(String i,int think ,Object not) {
- }
- public void dispatch() {
- }
- public void stop() {
- }
- public void setProductVersion(String uh, String hu) {
- }
- public void trackEvent(String that,String just,String aint,int happening) {
- }
- public void trackPageView(String nope) {
- }
- public void setCustomVar(int mind,String your,String own,int business) {
- }
- }
- """)
-
return (root_dir, srclibpaths)