chiark / gitweb /
output= is now a glob path and can do gradle
authorDaniel Martí <mvdan@mvdan.cc>
Mon, 15 Feb 2016 12:01:38 +0000 (12:01 +0000)
committerDaniel Martí <mvdan@mvdan.cc>
Mon, 15 Feb 2016 12:02:45 +0000 (12:02 +0000)
docs/fdroid.texi
fdroidserver/build.py
fdroidserver/common.py
fdroidserver/lint.py
fdroidserver/metadata.py

index 96545d73785774d5a6c3b50b8331d56bcf033b15..7d3470706ab8e84d34fa9664771f08007612420f 100644 (file)
@@ -1120,10 +1120,12 @@ For example: @code{gradleprops=enableFoo,someSetting=bar} will result in
 Specify an alternate set of Ant commands (target) instead of the default
 'release'. It can't be given any flags, such as the path to a build.xml.
 
-@item output=path/to/output.apk
-To be used when app is built with a tool other than the ones natively
-supported, like GNU Make. The given path will be where the build= set of
-commands should produce the final unsigned release apk.
+@item output=glob/to/output.apk
+Specify a glob path where the resulting unsigned release apk from the
+build should be. This can be used in combination with build methods like
+@code{gradle=yes} or @code{maven=yes}, but if no build method is
+specified, the build is manual. You should run your build commands, such
+as @code{make}, in @code{build=}.
 
 @item novcheck=yes
 Don't check that the version name and code in the resulting apk are
index 12cc61c144d57894fda53d8be57ad9e2f62d5ea1..2d9e61bfb3fb5e201dd22dfbffacc8a100cd4b8b 100644 (file)
@@ -489,8 +489,8 @@ def build_local(app, build, vcs, build_dir, output_dir, srclib_dir, extlib_dir,
     # different from the default ones
     p = None
     gradletasks = []
-    method = build.method()
-    if method == 'maven':
+    bmethod = build.build_method()
+    if bmethod == 'maven':
         logging.info("Cleaning Maven project...")
         cmd = [config['mvn3'], 'clean', '-Dandroid.sdk.path=' + config['sdk_path']]
 
@@ -502,7 +502,7 @@ def build_local(app, build, vcs, build_dir, output_dir, srclib_dir, extlib_dir,
 
         p = FDroidPopen(cmd, cwd=maven_dir)
 
-    elif method == 'gradle':
+    elif bmethod == 'gradle':
 
         logging.info("Cleaning Gradle project...")
 
@@ -529,10 +529,10 @@ def build_local(app, build, vcs, build_dir, output_dir, srclib_dir, extlib_dir,
 
         p = FDroidPopen(cmd, cwd=root_dir)
 
-    elif method == 'kivy':
+    elif bmethod == 'kivy':
         pass
 
-    elif method == 'ant':
+    elif bmethod == 'ant':
         logging.info("Cleaning Ant project...")
         p = FDroidPopen(['ant', 'clean'], cwd=root_dir)
 
@@ -639,7 +639,7 @@ def build_local(app, build, vcs, build_dir, output_dir, srclib_dir, extlib_dir,
 
     p = None
     # Build the release...
-    if method == 'maven':
+    if bmethod == 'maven':
         logging.info("Building Maven project...")
 
         if '@' in build.maven:
@@ -665,7 +665,7 @@ def build_local(app, build, vcs, build_dir, output_dir, srclib_dir, extlib_dir,
 
         bindir = os.path.join(root_dir, 'target')
 
-    elif method == 'kivy':
+    elif bmethod == 'kivy':
         logging.info("Building Kivy project...")
 
         spec = os.path.join(root_dir, 'buildozer.spec')
@@ -726,7 +726,7 @@ def build_local(app, build, vcs, build_dir, output_dir, srclib_dir, extlib_dir,
         cmd.append('release')
         p = FDroidPopen(cmd, cwd=distdir)
 
-    elif method == 'gradle':
+    elif bmethod == 'gradle':
         logging.info("Building Gradle project...")
 
         cmd = [config['gradle']]
@@ -737,7 +737,7 @@ def build_local(app, build, vcs, build_dir, output_dir, srclib_dir, extlib_dir,
 
         p = FDroidPopen(cmd, cwd=root_dir)
 
-    elif method == 'ant':
+    elif bmethod == 'ant':
         logging.info("Building Ant project...")
         cmd = ['ant']
         if build.antcommands:
@@ -752,7 +752,8 @@ def build_local(app, build, vcs, build_dir, output_dir, srclib_dir, extlib_dir,
         raise BuildException("Build failed for %s:%s" % (app.id, build.version), p.output)
     logging.info("Successfully built version " + build.version + ' of ' + app.id)
 
-    if method == 'maven':
+    omethod = build.output_method()
+    if omethod == 'maven':
         stdout_apk = '\n'.join([
             line for line in p.output.splitlines() if any(
                 a in line for a in ('.apk', '.ap_', '.jar'))])
@@ -772,12 +773,12 @@ def build_local(app, build, vcs, build_dir, output_dir, srclib_dir, extlib_dir,
             raise BuildException('Failed to find output')
         src = m.group(1)
         src = os.path.join(bindir, src) + '.apk'
-    elif method == 'kivy':
+    elif omethod == 'kivy':
         src = os.path.join('python-for-android', 'dist', 'default', 'bin',
                            '{0}-{1}-release.apk'.format(
                                bconfig.get('app', 'title'),
                                bconfig.get('app', 'version')))
-    elif method == 'gradle':
+    elif omethod == 'gradle':
         src = None
         for apks_dir in [
                 os.path.join(root_dir, 'build', 'outputs', 'apk'),
@@ -798,15 +799,23 @@ def build_local(app, build, vcs, build_dir, output_dir, srclib_dir, extlib_dir,
         if src is None:
             raise BuildException('Failed to find any output apks')
 
-    elif method == 'ant':
+    elif omethod == 'ant':
         stdout_apk = '\n'.join([
             line for line in p.output.splitlines() if '.apk' in line])
         src = re.match(r".*^.*Creating (.+) for release.*$.*", stdout_apk,
                        re.S | re.M).group(1)
         src = os.path.join(bindir, src)
-    elif method == 'raw':
-        src = os.path.join(root_dir, build.output)
-        src = os.path.normpath(src)
+    elif omethod == 'raw':
+        globpath = os.path.join(root_dir, build.output)
+        print(globpath)
+        globpath = os.path.normpath(globpath)
+        print(globpath)
+        apks = glob.glob(globpath)
+        if len(apks) > 1:
+            raise BuildException('Multiple apks match %s' % globpath, '\n'.join(apks))
+        if len(apks) < 1:
+            raise BuildException('No apks match %s' % globpath)
+        src = os.path.normpath(apks[0])
 
     # Make sure it's not debuggable...
     if common.isApkDebuggable(src, config):
index 0463db29ad4d7c238db7e6f7edbe0eb341d4e47f..5a6c64ab2eec23de95ad8e1856e9439218f6ff1e 100644 (file)
@@ -1372,7 +1372,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
             f.write(props)
 
     flavours = []
-    if build.method() == 'gradle':
+    if build.build_method() == 'gradle':
         flavours = build.gradle
 
         if build.target:
@@ -1461,7 +1461,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
                                  (app.id, build.version), p.output)
 
     # Generate (or update) the ant build file, build.xml...
-    if build.method() == 'ant' and build.update != ['no']:
+    if build.build_method() == 'ant' and build.update != ['no']:
         parms = ['android', 'update', 'lib-project']
         lparms = ['android', 'update', 'project']
 
index ee4381c0f10c4a4a73adad3a71be4ebc9b6aa281..8760e1db527dc0e4f999f6807b5c69b8b3ace0d5 100644 (file)
@@ -305,7 +305,7 @@ def check_builds(app):
                 ref = srclib.split('@')[1].split('/')[0]
                 if ref.startswith(s):
                     yield "Branch '%s' used as commit in srclib '%s'" % (s, srclib)
-        if build.target and build.method() == 'gradle':
+        if build.target and build.build_method() == 'gradle':
             yield "target= has no gradle support"
 
 
index b1924357eaf8af91d6c4841fcf5db69baf8eb98b..dc0055f21deb310176c3e1cbfd1d02b050227c71 100644 (file)
@@ -331,7 +331,7 @@ class Build():
         else:
             self.__dict__[f].append(v)
 
-    def method(self):
+    def build_method(self):
         for f in ['maven', 'gradle', 'kivy']:
             if self.get_flag(f):
                 return f
@@ -339,6 +339,15 @@ class Build():
             return 'raw'
         return 'ant'
 
+    # like build_method, but prioritize output=
+    def output_method(self):
+        if self.output:
+            return 'raw'
+        for f in ['maven', 'gradle', 'kivy']:
+            if self.get_flag(f):
+                return f
+        return 'ant'
+
     def ndk_path(self):
         version = self.ndk
         if not version: