chiark / gitweb /
add force_build_tools config option
authorHans-Christoph Steiner <hans@eds.org>
Mon, 20 Jun 2016 18:00:59 +0000 (20:00 +0200)
committerHans-Christoph Steiner <hans@eds.org>
Tue, 21 Jun 2016 08:29:56 +0000 (10:29 +0200)
This replaces the current default behavior of always forcing the
build_tools version and allows the user to set build-tools forcing in
config.py.

closes #147

examples/config.py
fdroidserver/build.py
fdroidserver/common.py
tests/build.TestCase

index 56ed7b86cd3c4172da07c5c9316a97bc5a771a06..1a3367e86a9fc2c24e1366ea941e899c4ca78aa3 100644 (file)
 # Build tools version to be used
 # build_tools = "23.0.3"
 
+# Force all build to use the above version of build -tools, good for testing
+# builds without having all of the possible build-tools installed.
+# force_build_tools = True
+
 # Command or path to binary for running Ant
 # ant = "ant"
 
@@ -232,10 +236,10 @@ The repository of older versions of applications from the main demo repository.
 # --server option on dedicated secure build server hosts.
 # build_server_always = True
 
-# By default, fdroid will use YAML and the custom .txt metadata formats. It
+# By default, fdroid will use YAML .yml and the custom .txt metadata formats. It
 # is also possible to have metadata in JSON and XML by adding 'json' and
 # 'xml'.
-# accepted_formats = ['txt', 'yaml']
+# accepted_formats = ['txt', 'yml']
 
 # Limit in number of characters that fields can take up
 # Only the fields listed here are supported, defaults shown
index 7709a6bf104772ba1c16afe947b1e34d8bf0745e..bad025a6d9a37258aedad1bada262e1a82301f6e 100644 (file)
@@ -431,8 +431,7 @@ def build_server(app, build, vcs, build_dir, output_dir, force):
         release_vm()
 
 
-def adapt_gradle(build_dir):
-    filename = 'build.gradle'
+def force_gradle_build_tools(build_dir, build_tools):
     for root, dirs, files in os.walk(build_dir):
         for filename in files:
             if not filename.endswith('.gradle'):
@@ -440,9 +439,9 @@ def adapt_gradle(build_dir):
             path = os.path.join(root, filename)
             if not os.path.isfile(path):
                 continue
-            logging.debug("Adapting %s at %s" % (filename, path))
+            logging.debug("Forcing build-tools %s in %s" % (build_tools, path))
             common.regsub_file(r"""(\s*)buildToolsVersion([\s=]+).*""",
-                               r"""\1buildToolsVersion\2'%s'""" % config['build_tools'],
+                               r"""\1buildToolsVersion\2'%s'""" % build_tools,
                                path)
 
 
@@ -512,9 +511,10 @@ def build_local(app, build, vcs, build_dir, output_dir, srclib_dir, extlib_dir,
 
         gradletasks += ['assemble' + flavours_cmd + 'Release']
 
-        adapt_gradle(build_dir)
-        for name, number, libpath in srclibpaths:
-            adapt_gradle(libpath)
+        if config['force_build_tools']:
+            force_gradle_build_tools(build_dir, config['build_tools'])
+            for name, number, libpath in srclibpaths:
+                force_gradle_build_tools(libpath, config['build_tools'])
 
         cmd = [config['gradle']]
         if build.gradleprops:
index 17df02aec47117e0b360763f6f349d90a3406595..f27177fe1f4ad44d28a3add0f8d750c3c36398f6 100644 (file)
@@ -59,6 +59,7 @@ default_config = {
         'r10e': "$ANDROID_NDK",
     },
     'build_tools': "23.0.3",
+    'force_build_tools': False,
     'java_paths': None,
     'ant': "ant",
     'mvn3': "mvn",
index 369c3836f250996e2ee0cd995e760aeb4b0f6ebb..9391a0423e01ef768621ce03d29d08e3772256f1 100755 (executable)
@@ -46,7 +46,7 @@ class BuildTest(unittest.TestCase):
                 self.assertTrue(os.path.exists(path))
                 self.assertTrue(os.path.isfile(path))
 
-    def test_adapt_gradle(self):
+    def test_force_gradle_build_tools(self):
         testsbase = os.path.join(os.path.dirname(__file__), '..', '.testfiles')
         if not os.path.exists(testsbase):
             os.makedirs(testsbase)
@@ -54,9 +54,7 @@ class BuildTest(unittest.TestCase):
         shutil.copytree(os.path.join(os.path.dirname(__file__), 'source-files'),
                         os.path.join(testsdir, 'source-files'))
         teststring = 'FAKE_VERSION_FOR_TESTING'
-        fdroidserver.build.config = {}
-        fdroidserver.build.config['build_tools'] = teststring
-        fdroidserver.build.adapt_gradle(testsdir)
+        fdroidserver.build.force_gradle_build_tools(testsdir, teststring)
         pattern = re.compile(bytes("buildToolsVersion[\s=]+'%s'\s+" % teststring, 'utf8'))
         for p in ('source-files/fdroid/fdroidclient/build.gradle',
                   'source-files/Zillode/syncthing-silk/build.gradle',
@@ -67,6 +65,7 @@ class BuildTest(unittest.TestCase):
                 filedata = f.read()
             self.assertIsNotNone(pattern.search(filedata))
 
+
 if __name__ == "__main__":
     parser = optparse.OptionParser()
     parser.add_option("-v", "--verbose", action="store_true", default=False,