diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2025-01-06 22:22:01 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2025-01-06 22:22:01 +0200 |
commit | e40aede233efc0c76a10ef9ac8b3fa5e51c043d5 (patch) | |
tree | 2585f4403d3bfe8700bd62a6b13646a08a02b524 /mesonbuild/utils/universal.py | |
parent | 0b41b364be716064285928c00330d1fc6b07cd88 (diff) | |
download | meson-cmdarrays.zip meson-cmdarrays.tar.gz meson-cmdarrays.tar.bz2 |
Store commands as arrays.cmdarrays
Diffstat (limited to 'mesonbuild/utils/universal.py')
-rw-r--r-- | mesonbuild/utils/universal.py | 14 |
1 files changed, 8 insertions, 6 deletions
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 |