Skip to content

Commit

Permalink
swift: Pass C base compile options to swiftc
Browse files Browse the repository at this point in the history
  • Loading branch information
2xsaiko committed Feb 25, 2025
1 parent 1b54239 commit c97b55c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions mesonbuild/compilers/swift.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@


if T.TYPE_CHECKING:
from .. import build
from ..dependencies import Dependency
from ..envconfig import MachineInfo
from ..environment import Environment
Expand Down Expand Up @@ -115,6 +116,21 @@ def get_include_args(self, path: str, is_system: bool) -> T.List[str]:
def get_compile_only_args(self) -> T.List[str]:
return ['-c']

def get_option_compile_args(self, target: build.BuildTarget, env: Environment, subproject: T.Optional[str] = None
) -> T.List[str]:
args: T.List[str] = []

# Pass C compiler args to swiftc, notably -std=...
try:
c_langs = ['objc', 'c']
c_lang = next(iter(lang for lang in c_langs if lang in target.compilers))
cc = target.compilers[c_lang]
args.extend(arg for c_arg in cc.get_option_compile_args(target, env, subproject) for arg in ['-Xcc', c_arg])
except StopIteration:
pass

return args

def get_working_directory_args(self, path: str) -> T.Optional[T.List[str]]:
if version_compare(self.version, '<4.2'):
return None
Expand Down

0 comments on commit c97b55c

Please sign in to comment.