diff options
| author | L. E. Segovia <amy@amyspark.me> | 2025-08-03 22:26:07 -0300 |
|---|---|---|
| committer | Jussi Pakkanen <jussi.pakkanen@mailbox.org> | 2025-09-06 16:58:56 +0300 |
| commit | c3ea8d5aa1b48fbc4137ef783c567a32cd596993 (patch) | |
| tree | a1c729133a5e92ad516623192fd48c742db31fa2 /mesonbuild/envconfig.py | |
| parent | 4b7a23c047ef5139f84cf96da37d132fe5fd84bc (diff) | |
| download | meson-c3ea8d5aa1b48fbc4137ef783c567a32cd596993.tar.gz | |
compilers: Enable out-of-the-box MSVC compatibility with ccache
ccache has been for a long time compatible with MSVC (since 4.6)
but when using debug mode, the /Z7 flag must be passed instead of
/Zi.
See https://ccache.dev/releasenotes.html#_ccache_4_6
Diffstat (limited to 'mesonbuild/envconfig.py')
| -rw-r--r-- | mesonbuild/envconfig.py | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py index 43fad0cd2..447639e00 100644 --- a/mesonbuild/envconfig.py +++ b/mesonbuild/envconfig.py @@ -4,12 +4,12 @@ from __future__ import annotations from dataclasses import dataclass -import subprocess import typing as T from enum import Enum from . import mesonlib from .mesonlib import EnvironmentException, HoldableObject +from .programs import ExternalProgram from . import mlog from pathlib import Path @@ -423,31 +423,23 @@ class BinaryTable: del self.binaries['pkgconfig'] @staticmethod - def detect_ccache() -> T.List[str]: - try: - subprocess.check_call(['ccache', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - except (OSError, subprocess.CalledProcessError): - return [] - return ['ccache'] + def detect_ccache() -> ExternalProgram: + return ExternalProgram('ccache') @staticmethod - def detect_sccache() -> T.List[str]: - try: - subprocess.check_call(['sccache', '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - except (OSError, subprocess.CalledProcessError): - return [] - return ['sccache'] + def detect_sccache() -> ExternalProgram: + return ExternalProgram('sccache') @staticmethod - def detect_compiler_cache() -> T.List[str]: + def detect_compiler_cache() -> ExternalProgram: # Sccache is "newer" so it is assumed that people would prefer it by default. cache = BinaryTable.detect_sccache() - if cache: + if cache.found(): return cache return BinaryTable.detect_ccache() @classmethod - def parse_entry(cls, entry: T.Union[str, T.List[str]]) -> T.Tuple[T.List[str], T.List[str]]: + def parse_entry(cls, entry: T.Union[str, T.List[str]]) -> T.Tuple[T.List[str], T.Union[None, ExternalProgram]]: parts = mesonlib.stringlistify(entry) # Ensure ccache exists and remove it if it doesn't if parts[0] == 'ccache': @@ -458,7 +450,7 @@ class BinaryTable: ccache = cls.detect_sccache() else: compiler = parts - ccache = [] + ccache = None if not compiler: raise EnvironmentException(f'Compiler cache specified without compiler: {parts[0]}') # Return value has to be a list of compiler 'choices' |
