-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
base: master
Are you sure you want to change the base?
Conversation
c392940
to
c97b55c
Compare
c5af688
to
e79331a
Compare
mesonbuild/compilers/swift.py
Outdated
# 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a mesonlib.first()
helper that I think would simplify this:
lang = mesonlib.first(target.compilers, lambda x: x in {'objc', 'c'})
if lang is not None:
cc = target.compilers[lang]
args.extend(...)
with no need for a try/except block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order is important here though, it should generally prefer objc/c++ when available, so kept the iteration the other way around.
e79331a
to
31441b1
Compare
a3461bb
to
d5df540
Compare
d5df540
to
be6623a
Compare
If the C/Obj-C source code needs a particular standard version, swiftc should know about it so it can parse imported headers correctly.
(This makes more sense with C++ support (commit 2xsaiko@push-nmuxysxxokuy), since setting the standard version is more common there, and was pulled out of #14261, but still applies for C as well)