aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2025-01-06 22:22:01 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2025-01-06 22:22:01 +0200
commite40aede233efc0c76a10ef9ac8b3fa5e51c043d5 (patch)
tree2585f4403d3bfe8700bd62a6b13646a08a02b524
parent0b41b364be716064285928c00330d1fc6b07cd88 (diff)
downloadmeson-cmdarrays.zip
meson-cmdarrays.tar.gz
meson-cmdarrays.tar.bz2
Store commands as arrays.cmdarrays
-rw-r--r--mesonbuild/interpreter/interpreter.py2
-rw-r--r--mesonbuild/utils/universal.py14
2 files changed, 9 insertions, 7 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index d717485..c039714 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -1968,7 +1968,7 @@ class Interpreter(InterpreterBase, HoldableObject):
vcs = mesonlib.detect_vcs(source_dir)
if vcs:
mlog.log('Found {} repository at {}'.format(vcs['name'], vcs['wc_dir']))
- vcs_cmd = vcs['get_rev'].split()
+ vcs_cmd = vcs['get_rev']
regex_selector = vcs['rev_regex']
else:
vcs_cmd = [' '] # executing this cmd will fail in vcstagger.py and force to use the fallback string
diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py
index 76a6df8..3d6037f 100644
--- a/mesonbuild/utils/universal.py
+++ b/mesonbuild/utils/universal.py
@@ -751,13 +751,13 @@ def windows_detect_native_arch() -> str:
raise EnvironmentException('Unable to detect native OS architecture')
return arch
-def detect_vcs(source_dir: T.Union[str, Path]) -> T.Optional[T.Dict[str, str]]:
+def detect_vcs(source_dir: T.Union[str, Path]) -> T.Optional[T.Dict[str, T.Union[str, T.List[T.str]]]]:
vcs_systems = [
{
'name': 'git',
'cmd': 'git',
'repo_dir': '.git',
- 'get_rev': 'git describe --dirty=+ --always',
+ 'get_rev': ['git describe', '--dirty=+', '--always'],
'rev_regex': '(.*)',
'dep': '.git/logs/HEAD'
},
@@ -765,7 +765,7 @@ def detect_vcs(source_dir: T.Union[str, Path]) -> T.Optional[T.Dict[str, str]]:
'name': 'mercurial',
'cmd': 'hg',
'repo_dir': '.hg',
- 'get_rev': 'hg id -i',
+ 'get_rev': ['hg', 'id', '-i'],
'rev_regex': '(.*)',
'dep': '.hg/dirstate'
},
@@ -773,7 +773,7 @@ def detect_vcs(source_dir: T.Union[str, Path]) -> T.Optional[T.Dict[str, str]]:
'name': 'subversion',
'cmd': 'svn',
'repo_dir': '.svn',
- 'get_rev': 'svn info',
+ 'get_rev': ['svn', 'info'],
'rev_regex': 'Revision: (.*)',
'dep': '.svn/wc.db'
},
@@ -781,7 +781,7 @@ def detect_vcs(source_dir: T.Union[str, Path]) -> T.Optional[T.Dict[str, str]]:
'name': 'bazaar',
'cmd': 'bzr',
'repo_dir': '.bzr',
- 'get_rev': 'bzr revno',
+ 'get_rev': ['bzr', 'revno'],
'rev_regex': '(.*)',
'dep': '.bzr'
},
@@ -795,7 +795,9 @@ def detect_vcs(source_dir: T.Union[str, Path]) -> T.Optional[T.Dict[str, str]]:
parent_paths_and_self.appendleft(source_dir)
for curdir in parent_paths_and_self:
for vcs in vcs_systems:
- if Path.is_dir(curdir.joinpath(vcs['repo_dir'])) and shutil.which(vcs['cmd']):
+ repodir = T.cast(str, vcs['repo_dir'])
+ cmd = T.cast(str, vcs['cmd'])
+ if Path.is_dir(curdir.joinpath(repodir)) and shutil.which(cmd):
vcs['wc_dir'] = str(curdir)
return vcs
return None