Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swift: Pass C base compile options to swiftc #14296

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(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
Loading