Skip to content

Commit

Permalink
coredata: Transform compilers in copy_as_build()
Browse files Browse the repository at this point in the history
So that e.g. `c_args` is used instead of `native.c_args`.
  • Loading branch information
oleavr committed Mar 18, 2024
1 parent 6a37aa5 commit 5a76b40
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions mesonbuild/compilers/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import abc
import contextlib, os.path, re
import copy
import enum
import itertools
import typing as T
Expand All @@ -16,7 +17,7 @@
from .. import mesonlib
from ..mesonlib import (
HoldableObject,
EnvironmentException, MesonException,
EnvironmentException, MachineChoice, MesonException,
Popen_safe_logged, LibType, TemporaryDirectoryWinProof, OptionKey,
)

Expand All @@ -29,7 +30,6 @@
from ..environment import Environment
from ..linkers import RSPFileSyntax
from ..linkers.linkers import DynamicLinker
from ..mesonlib import MachineChoice
from ..dependencies import Dependency

CompilerType = T.TypeVar('CompilerType', bound='Compiler')
Expand Down Expand Up @@ -463,6 +463,11 @@ def __repr__(self) -> str:
return repr_str.format(self.__class__.__name__, self.version,
' '.join(self.exelist))

def copy_for_build(self) -> Compiler:
new = copy.copy(self)
new.for_machine = MachineChoice.HOST
return new

@lru_cache(maxsize=None)
def can_compile(self, src: 'mesonlib.FileOrString') -> bool:
if isinstance(src, mesonlib.File):
Expand Down
3 changes: 2 additions & 1 deletion mesonbuild/coredata.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,8 @@ def copy_as_build(self) -> CoreData:

# Use only the build deps, not any host ones
new.deps = PerMachineDefaultable(self.deps.build).default_missing()
new.compilers = PerMachineDefaultable(self.compilers.build).default_missing()
new.compilers = PerMachineDefaultable({k: v.copy_for_build() for k, v in self.compilers.build.items()}) \
.default_missing()
new.cmake_cache = PerMachineDefaultable(self.cmake_cache.build).default_missing()

# Drop any cross files, since this is not a cross compile
Expand Down

0 comments on commit 5a76b40

Please sign in to comment.