Skip to content

Commit

Permalink
fix ninja backend rules containing internal enum reprs
Browse files Browse the repository at this point in the history
Partially reverts commit 1624354 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.
  • Loading branch information
eli-schwartz authored and xclaesse committed Oct 20, 2023
1 parent 1cf0ed0 commit 34ac2e4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mesonbuild/compilers/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions mesonbuild/compilers/mixins/clike.py
Original file line number Diff line number Diff line change
Expand Up @@ -1359,14 +1359,14 @@ def get_assert_args(self, disable: bool) -> T.List[str]:
@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)

def get_preprocessor(self) -> 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
2 changes: 1 addition & 1 deletion mesonbuild/compilers/mixins/visualstudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def sanitizer_compile_args(self, value: str) -> T.List[str]:
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]
Expand Down

0 comments on commit 34ac2e4

Please sign in to comment.