chiark / gitweb /
Have all multi-value build flags work similarly
authorDaniel Martí <mvdan@mvdan.cc>
Wed, 12 Feb 2014 10:13:20 +0000 (11:13 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Wed, 12 Feb 2014 10:15:19 +0000 (11:15 +0100)
Semicolons are still supported, but commas are now the better standard.

docs/fdroid.texi
fdroidserver/common.py
fdroidserver/metadata.py

index b584deb73837b61c5aaf0668501b609bb319629d..faead290d984f8c2ae75ab71a302d1edf042bdc2 100644 (file)
@@ -884,22 +884,22 @@ which architecture or platform the apk is designed to run on.
 If specified, the package version code in the AndroidManifest.xml is
 replaced with the version code for the build. See also forceversion.
 
-@item rm=<relpath1;relpath2;...>
+@item rm=relpath1,relpath2,...
 Specifies the relative paths of files or directories to delete before
 the build is done. The paths are relative to the base of the build
 directory - i.e. the root of the directory structure checked out from
 the source respository - not necessarily the directory that contains
 AndroidManifest.xml.
 
-Multiple files/directories can be specified by separating them with ';'.
+Multiple files/directories can be specified by separating them with ','.
 Directories will be recursively deleted.
 
-@item extlibs=a;b;c
+@item extlibs=a,b,...
 Specifies a list of external libraries (jar files) from the
 @code{build/extlib} library, which will be placed in the @code{libs} directory
 of the project. Separate items with semicolons.
 
-@item srclibs=[n:]a@@r;[n:]b@@r1;
+@item srclibs=[n:]a@@r,[n:]b@@r1,...
 Specifies a list of source libraries or Android projects. Separate items with
 semicolons, and each item is of the form name@@rev where name is the predefined
 source library name and rev is the revision or tag in source control to use.
@@ -947,7 +947,7 @@ You can use $$SDK$$, $$NDK$$ and $$MVN3$$ to substitute the paths to the
 android SDK and NDK directories, and maven 3 executable respectively e.g.
 for when you need to run @code{android update project} explicitly.
 
-@item scanignore=path1;path2;...
+@item scanignore=path1,path2,...
 Enables one or more files/paths to be exlcuded from the scan process.
 This should only be used where there is a very good reason, and
 probably accompanied by a comment explaining why it is necessary.
@@ -955,7 +955,7 @@ probably accompanied by a comment explaining why it is necessary.
 When scanning the source tree for problems, matching files whose relative
 paths start with any of the paths given here are ignored.
 
-@item scandelete=path1;path2;...
+@item scandelete=path1,path2,...
 Similar to scanignore=, but instead of ignoring files under the given paths,
 it tells f-droid to delete the matching files directly.
 
index 6eac3d0e57dfad832bff1de99ddde06c591c96e6..15dc9ed6f9b7106cac501ed82aa367231afb7b39 100644 (file)
@@ -815,7 +815,7 @@ def getsrclib(spec, srclib_dir, srclibpaths=[], subdir=None,
 
     if srclib["Srclibs"]:
         n=1
-        for lib in srclib["Srclibs"].split(','):
+        for lib in srclib["Srclibs"]:
             s_tuple = None
             for t in srclibpaths:
                 if t[0] == lib:
@@ -894,7 +894,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
 
     # Apply patches if any
     if 'patch' in build:
-        for patch in build['patch'].split(';'):
+        for patch in build['patch']:
             patch = patch.strip()
             logging.info("Applying " + patch)
             patch_path = os.path.join('metadata', app['id'], patch)
@@ -906,7 +906,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
     srclibpaths = []
     if 'srclibs' in build:
         logging.info("Collecting source libraries")
-        for lib in build['srclibs'].split(';'):
+        for lib in build['srclibs']:
             srclibpaths.append(getsrclib(lib, srclib_dir, srclibpaths,
                 preponly=onserver))
 
@@ -1005,7 +1005,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
 
     # Delete unwanted files
     if 'rm' in build:
-        for part in build['rm'].split(';'):
+        for part in build['rm']:
             dest = os.path.join(build_dir, part.strip())
             rdest = os.path.abspath(dest)
             logging.info("Removing {0}".format(rdest))
@@ -1030,7 +1030,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
         libsdir = os.path.join(root_dir, 'libs')
         if not os.path.exists(libsdir):
             os.mkdir(libsdir)
-        for lib in build['extlibs'].split(';'):
+        for lib in build['extlibs']:
             lib = lib.strip()
             logging.info("...installing extlib {0}".format(lib))
             libf = os.path.basename(lib)
@@ -1119,7 +1119,7 @@ def scan_source(build_dir, root_dir, thisbuild):
         paths = []
         if field not in thisbuild:
             return paths
-        for p in thisbuild[field].split(';'):
+        for p in thisbuild[field]:
             p = p.strip()
             if p == '.':
                 p = '/'
index 51b2529fea8b1117ec7c1fe83c76accf1710f1d9..88548d5761bdd1352dfd38897eb51564d550fcf7 100644 (file)
@@ -381,7 +381,6 @@ def parse_srclib(metafile, **kw):
     thisinfo['Subdir'] = None
     thisinfo['Prepare'] = None
     thisinfo['Srclibs'] = None
-    thisinfo['Update Project'] = None
 
     if metafile is None:
         return thisinfo
@@ -451,6 +450,13 @@ def metafieldtype(name):
         return 'unknown'
     return 'string'
 
+def flagtype(name):
+    if name in ['extlibs', 'srclibs', 'patch', 'rm', 'scanignore', 'scandelete']:
+        return 'list'
+    if name in ['init', 'prebuild', 'build']:
+        return 'script'
+    return 'string'
+
 # Parse metadata for a single application.
 #
 #  'metafile' - the filename to read. The package id for the application comes
@@ -507,7 +513,17 @@ def parse_metadata(metafile):
             if pk not in ordered_flags:
                 raise MetaDataException("Unrecognised build flag at {0} in {1}".
                         format(p, metafile.name))
-            thisbuild[pk] = pv
+            t = flagtype(pk)
+            if t == 'list':
+                # Port legacy ';' separators
+                thisbuild[pk] = pv.replace(';',',').split(',')
+            elif t == 'string':
+                thisbuild[pk] = pv
+            elif t == 'script':
+                thisbuild[pk] = pv
+            else:
+                raise MetaDataException("Unrecognised build flag type '%s' at %s in %s" % (
+                        t, p, metafile.name))
 
         return thisbuild
 
@@ -732,9 +748,15 @@ def write_metadata(dest, app):
                 if not value:
                     return
                 value = 'yes'
+            t = flagtype(key)
             logging.debug("...writing {0} : {1}".format(key, value))
             outline = '    %s=' % key
-            outline += '&& \\\n        '.join([s.lstrip() for s in value.split('&& ')])
+            if t == 'string':
+                outline += value
+            elif t == 'script':
+                outline += '&& \\\n        '.join([s.lstrip() for s in value.split('&& ')])
+            elif t == 'list':
+                outline += ','.join(value) if type(value) == list else value
             outline += '\n'
             mf.write(outline)