|
|
|
@ -41,7 +41,7 @@ if T.TYPE_CHECKING: |
|
|
|
|
|
|
|
|
|
from .._typing import ImmutableListProtocol |
|
|
|
|
from ..build import ConfigurationData |
|
|
|
|
from ..coredata import KeyedOptionDictType, UserOption |
|
|
|
|
from ..coredata import KeyedOptionDictType, UserOption, StrOrBytesPath |
|
|
|
|
from ..environment import Environment |
|
|
|
|
from ..compilers.compilers import Compiler |
|
|
|
|
from ..interpreterbase.baseobjects import SubProject |
|
|
|
@ -194,14 +194,15 @@ class GitException(MesonException): |
|
|
|
|
self.output = output.strip() if output else '' |
|
|
|
|
|
|
|
|
|
GIT = shutil.which('git') |
|
|
|
|
def git(cmd: T.List[str], workingdir: T.Union[str, bytes, os.PathLike], check: bool = False, **kwargs: T.Any) -> T.Tuple[subprocess.Popen, str, str]: |
|
|
|
|
cmd = [GIT] + cmd |
|
|
|
|
def git(cmd: T.List[str], workingdir: StrOrBytesPath, check: bool = False, **kwargs: T.Any) -> T.Tuple[subprocess.Popen[str], str, str]: |
|
|
|
|
assert GIT is not None, 'Callers should make sure it exists' |
|
|
|
|
cmd = [GIT, *cmd] |
|
|
|
|
p, o, e = Popen_safe(cmd, cwd=workingdir, **kwargs) |
|
|
|
|
if check and p.returncode != 0: |
|
|
|
|
raise GitException('Git command failed: ' + str(cmd), e) |
|
|
|
|
return p, o, e |
|
|
|
|
|
|
|
|
|
def quiet_git(cmd: T.List[str], workingdir: T.Union[str, bytes, os.PathLike], check: bool = False) -> T.Tuple[bool, str]: |
|
|
|
|
def quiet_git(cmd: T.List[str], workingdir: StrOrBytesPath, check: bool = False) -> T.Tuple[bool, str]: |
|
|
|
|
if not GIT: |
|
|
|
|
m = 'Git program not found.' |
|
|
|
|
if check: |
|
|
|
@ -212,7 +213,7 @@ def quiet_git(cmd: T.List[str], workingdir: T.Union[str, bytes, os.PathLike], ch |
|
|
|
|
return False, e |
|
|
|
|
return True, o |
|
|
|
|
|
|
|
|
|
def verbose_git(cmd: T.List[str], workingdir: T.Union[str, bytes, os.PathLike], check: bool = False) -> bool: |
|
|
|
|
def verbose_git(cmd: T.List[str], workingdir: StrOrBytesPath, check: bool = False) -> bool: |
|
|
|
|
if not GIT: |
|
|
|
|
m = 'Git program not found.' |
|
|
|
|
if check: |
|
|
|
@ -595,7 +596,7 @@ class PerMachineDefaultable(PerMachine[T.Optional[_T]]): |
|
|
|
|
return m.default_missing() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PerThreeMachineDefaultable(PerMachineDefaultable, PerThreeMachine[T.Optional[_T]]): |
|
|
|
|
class PerThreeMachineDefaultable(PerMachineDefaultable[T.Optional[_T]], PerThreeMachine[T.Optional[_T]]): |
|
|
|
|
"""Extends `PerThreeMachine` with the ability to default from `None`s. |
|
|
|
|
""" |
|
|
|
|
def __init__(self) -> None: |
|
|
|
@ -1259,7 +1260,7 @@ def get_variable_regex(variable_format: Literal['meson', 'cmake', 'cmake@'] = 'm |
|
|
|
|
regex = re.compile(r'(?:\\\\)+(?=\\?\$)|\\\${|\${([-a-zA-Z0-9_]+)}') |
|
|
|
|
return regex |
|
|
|
|
|
|
|
|
|
def do_conf_str(src: str, data: list, confdata: 'ConfigurationData', |
|
|
|
|
def do_conf_str(src: str, data: T.List[str], confdata: 'ConfigurationData', |
|
|
|
|
variable_format: Literal['meson', 'cmake', 'cmake@'], |
|
|
|
|
encoding: str = 'utf-8', subproject: T.Optional[SubProject] = None) -> T.Tuple[T.List[str], T.Set[str], bool]: |
|
|
|
|
def line_is_valid(line: str, variable_format: str) -> bool: |
|
|
|
|