fix ninja backend rules containing internal enum reprs

Partially reverts commit 1624354f33 which
moved a bunch of stuff from strings to enums. The issue here is that
Compiler.mode is not just, or primarily, something we compare, but is
instead written in as e.g. `rule c_{compiler.mode}` to build.ninja, so
this identifier needs to be a string.

Ultimately, the issue is that the commit tried to rewrite a bunch of
things called "mode" that had a couple of TODOs saying to use enums...
but it rewrote everything called "mode" regardless of whether it was a
function kwarg or a compiler property, even though the TODO only applied
to one of them.
pull/12064/merge
Eli Schwartz 2 years ago committed by Xavier Claessens
parent 1cf0ed0997
commit 34ac2e4af6
  1. 2
      mesonbuild/compilers/compilers.py
  2. 4
      mesonbuild/compilers/mixins/clike.py
  3. 2
      mesonbuild/compilers/mixins/visualstudio.py

@ -527,7 +527,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
language: str
id: str
warn_args: T.Dict[str, T.List[str]]
mode = CompileCheckMode.COMPILE
mode = 'COMPILER'
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str,
for_machine: MachineChoice, info: 'MachineInfo',

@ -1359,7 +1359,7 @@ class CLikeCompiler(Compiler):
@functools.lru_cache(maxsize=None)
def can_compile(self, src: 'mesonlib.FileOrString') -> bool:
# Files we preprocess can be anything, e.g. .in
if self.mode == CompileCheckMode.PREPROCESS:
if self.mode == 'PREPROCESSOR':
return True
return super().can_compile(src)
@ -1367,6 +1367,6 @@ class CLikeCompiler(Compiler):
if not self.preprocessor:
self.preprocessor = copy.copy(self)
self.preprocessor.exelist = self.exelist + self.get_preprocess_to_file_args()
self.preprocessor.mode = CompileCheckMode.PREPROCESS
self.preprocessor.mode = 'PREPROCESSOR'
self.modes.append(self.preprocessor)
return self.preprocessor

@ -182,7 +182,7 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta):
return ['/fsanitize=address']
def get_output_args(self, outputname: str) -> T.List[str]:
if self.mode == CompileCheckMode.PREPROCESS:
if self.mode == 'PREPROCESSOR':
return ['/Fi' + outputname]
if outputname.endswith('.exe'):
return ['/Fe' + outputname]

Loading…
Cancel
Save