Skip to content

Commit c5af688

Browse files
committed
swift: Pass C base compile options to swiftc
1 parent 1b54239 commit c5af688

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

mesonbuild/compilers/swift.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414

1515
if T.TYPE_CHECKING:
16+
from .. import build
1617
from ..dependencies import Dependency
1718
from ..envconfig import MachineInfo
1819
from ..environment import Environment
@@ -115,6 +116,21 @@ def get_include_args(self, path: str, is_system: bool) -> T.List[str]:
115116
def get_compile_only_args(self) -> T.List[str]:
116117
return ['-c']
117118

119+
def get_option_compile_args(self, target: build.BuildTarget, env: Environment, subproject: T.Optional[str] = None
120+
) -> T.List[str]:
121+
args: T.List[str] = []
122+
123+
# Pass C compiler args to swiftc, notably -std=...
124+
try:
125+
c_langs = ['objc', 'c']
126+
c_lang = next(lang for lang in c_langs if lang in target.compilers)
127+
cc = target.compilers[c_lang]
128+
args.extend(arg for c_arg in cc.get_option_compile_args(target, env, subproject) for arg in ['-Xcc', c_arg])
129+
except StopIteration:
130+
pass
131+
132+
return args
133+
118134
def get_working_directory_args(self, path: str) -> T.Optional[T.List[str]]:
119135
if version_compare(self.version, '<4.2'):
120136
return None

0 commit comments

Comments
 (0)