aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2020-09-09 10:57:32 -0400
committerXavier Claessens <xclaesse@gmail.com>2020-09-10 11:39:30 -0400
commit14c1a6983d8cabd2382b750dd53d004d16449832 (patch)
treeefd1e5881feed53bb97b132069c977e4062805eb
parenta3ac25b0c3b1d671090acb14273af7d942bf07ce (diff)
downloadmeson-14c1a6983d8cabd2382b750dd53d004d16449832.zip
meson-14c1a6983d8cabd2382b750dd53d004d16449832.tar.gz
meson-14c1a6983d8cabd2382b750dd53d004d16449832.tar.bz2
msubprojects: Allow comma separated list of types
-rw-r--r--docs/markdown/Subprojects.md5
-rw-r--r--docs/markdown/snippets/subprojects_update.md7
-rwxr-xr-xmesonbuild/msubprojects.py15
-rw-r--r--mesonbuild/wrap/wrap.py4
4 files changed, 20 insertions, 11 deletions
diff --git a/docs/markdown/Subprojects.md b/docs/markdown/Subprojects.md
index 5dae0e8..379c775 100644
--- a/docs/markdown/Subprojects.md
+++ b/docs/markdown/Subprojects.md
@@ -267,8 +267,9 @@ subcommand fails on any subproject the execution continues with other subproject
All subcommands accept `--sourcedir` argument pointing to the root source dir
of the main project.
-*Since 0.56.0* all subcommands accept `--type <file|git|hg|svn>` argument to
-run the subcommands only on subprojects of the given type.
+*Since 0.56.0* all subcommands accept `--types <file|git|hg|svn>` argument to
+run the subcommands only on subprojects of the given types. Multiple types can
+be set as comma separated list e.g. `--types git,file`.
*Since 0.56.0* If the subcommand fails on any subproject an error code is returned
at the end instead of retuning success.
diff --git a/docs/markdown/snippets/subprojects_update.md b/docs/markdown/snippets/subprojects_update.md
index 598f70d..022545e 100644
--- a/docs/markdown/snippets/subprojects_update.md
+++ b/docs/markdown/snippets/subprojects_update.md
@@ -1,8 +1,9 @@
## `meson subprojects` command
-A new `--type` argument has been added to all subcommands to run the command only
-on wraps with the specified type. For example this command will only print `Hello`
-for each git subproject: `meson subprojects foreach --type git echo "Hello"`.
+A new `--types` argument has been added to all subcommands to run the command only
+on wraps with the specified types. For example this command will only print `Hello`
+for each git subproject: `meson subprojects foreach --types git echo "Hello"`.
+Multiple types can be set as comma separated list e.g. `--types git,file`.
Subprojects with no wrap file are now taken into account as well. This happens
for example for subprojects configured as git submodule, or downloaded manually
diff --git a/mesonbuild/msubprojects.py b/mesonbuild/msubprojects.py
index 22729d4..6329feb 100755
--- a/mesonbuild/msubprojects.py
+++ b/mesonbuild/msubprojects.py
@@ -2,8 +2,8 @@ import os, subprocess
import argparse
from . import mlog
-from .mesonlib import quiet_git, verbose_git, GitException, Popen_safe
-from .wrap.wrap import API_ROOT, Resolver, WrapException
+from .mesonlib import quiet_git, verbose_git, GitException, Popen_safe, MesonException
+from .wrap.wrap import API_ROOT, Resolver, WrapException, ALL_TYPES
from .wrap import wraptool
def update_wrapdb_file(wrap, repo_dir, options):
@@ -257,9 +257,8 @@ def foreach(wrap, repo_dir, options):
def add_common_arguments(p):
p.add_argument('--sourcedir', default='.',
help='Path to source directory')
- p.add_argument('--type', default='',
- choices=['file', 'git', 'hg', 'svn'],
- help='Only subprojects of given type (default: all)')
+ p.add_argument('--types', default='',
+ help='Comma-separated list of subproject types. Supported types are: {} (default: all)'.format(', '.join(ALL_TYPES)))
def add_subprojects_argument(p):
p.add_argument('subprojects', nargs='*',
@@ -318,9 +317,13 @@ def run(options):
wraps = [wrap for name, wrap in r.wraps.items() if name in options.subprojects]
else:
wraps = r.wraps.values()
+ types = [t.strip() for t in options.types.split(',')]
+ for t in types:
+ if t not in ALL_TYPES:
+ raise MesonException('Unknown subproject type {!r}, supported types are: {}'.format(t, ', '.join(ALL_TYPES)))
failures = []
for wrap in wraps:
- if options.type and wrap.type != options.type:
+ if wrap.type not in types:
continue
dirname = os.path.join(subprojects_dir, wrap.directory)
if not options.subprojects_func(wrap, dirname, options):
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py
index 969c82d..98b30ee 100644
--- a/mesonbuild/wrap/wrap.py
+++ b/mesonbuild/wrap/wrap.py
@@ -49,6 +49,8 @@ REQ_TIMEOUT = 600.0
SSL_WARNING_PRINTED = False
WHITELIST_SUBDOMAIN = 'wrapdb.mesonbuild.com'
+ALL_TYPES = ['file', 'git', 'hg', 'svn']
+
def whitelist_wrapdb(urlstr: str) -> urllib.parse.ParseResult:
""" raises WrapException if not whitelisted subdomain """
url = urllib.parse.urlparse(urlstr)
@@ -106,6 +108,8 @@ class PackageDefinition:
self.directory = self.values.get('directory', self.name)
if os.path.dirname(self.directory):
raise WrapException('Directory key must be a name and not a path')
+ if self.type and self.type not in ALL_TYPES:
+ raise WrapException('Unknown wrap type {!r}'.format(self.type))
def guess_type(self) -> None:
if os.path.exists(os.path.join(self.filename, '.git')):