summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/swift.py
AgeCommit message (Collapse)Author
2025-11-19compilers: Remove Environment parameter from Compiler.get_option_std_argsDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.sanity_checkDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.run_sanity_checkDylan Baker
2025-11-19compilers: Remove Environment parameter from get_compileropt_valueDylan Baker
2025-11-19compilers: Stop passing `is_cross`Dylan Baker
This is calculated by `Environment().is_cross_build(for_machine)`. Since we have that in the Compiler class, just calculate it in the Compiler initializer
2025-11-19compilers: Pass Environment instead of MachineInfoDylan Baker
We end up needing it everywhere, so just store it. This patch is huge already, so it's just the conversion to passing Environment, more cleanups to come.
2025-10-06Revert "compilers: refactor sanity checking code"Dylan Baker
This reverts commit 806289a5d27958a084bc6cba41b7cf9ccee4ecf4.
2025-10-06compilers: refactor sanity checking codeDylan Baker
The goal is to reduce code duplication, and allow each language to implement as little as possible to get good checking. The main motivation is that half of the checks are fragile, as they add the work directory to the paths of the generated files they want to use. This works when run inside mesonmain because we always have an absolute build directory, but when put into run_project_tests.py it doesn't work because that gives a relative build directory.
2025-08-02swift: Pass C++ base compile options to swiftcKatalin Rebhan
2025-08-02Add swift_interoperability_mode kwargKatalin Rebhan
2025-07-24Add -parse-as-library to Swift library targetsKatalin Rebhan
2025-06-23swift: Add support for C++/Objective-C++ interoperabilityAlbert Tang
As of Swift 5.9, C++/Objective-C++ code can be mixed with Swift, and C++ APIs can be imported to Swift. However, this must be explicitly enabled, as it is disabled by default. Xcode 15 introduces a new setting for this, so only set it on Xcode 15 and above.
2025-06-05swift: Pass C base compile options to swiftcKatalin Rebhan
2025-04-30compilers: introduce common helper for sanity checksPaolo Bonzini
Avoid reinventing the wheel and instead use a single helper, taking care of logging and cross compilation. Fixes: #14373 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-08coredata: move MutableKeyedOptionDict to optionsDylan Baker
2025-04-04compilers: move -std options to get_option_std_args, special-casing CUDAPaolo Bonzini
Move building the -std option to the new get_option_std_args method, special casing CUDA to never include the option from the host compiler. This fixes again #8523, which was broken by the option refactoring (unsurprisingly, since the fix was ripped out unceremoniously without a replacement). Fixes: #14365 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-03-01swift: Add swift_std compiler optionMarco Rebhan
2025-02-11ninja backend: Use swiftc flag -working-directory if availableMarco Rebhan
This makes SourceKit-LSP work using a meson-generated compile_commands.json.
2025-01-29swift: Fix duplicate SDK include paths causing a compile errorPiotr Brzeziński
Some dependencies can bring include paths pointing to older macOS SDK's. In this case, it was libffi pointing to SDK from 12.0. When the Foundation framework is imported in Swift, swiftc attempts to import the FFI module from the most recent version of the SDK, which causes a compilation error because of conflicting definitions between the two SDK versions. SwiftPM also had this problem: https://github.com/swiftlang/swift-package-manager/pull/6772 The solution on our side is a simplified version of what SwiftPM did. Let's naively look for .sdk paths in the compile args of our dependencies and replace them with the most recent one. I included a test which is confirmed to fail without the workaround added in this patch. This was not tested on anything else than macOS, but I don't expect it to make the situation worse in any case.
2024-04-27backend/ninja: use generate_basic_compiler_args() for C#, Java, SwiftBenjamin Gilbert
C#, Java, and Swift targets were manually collecting compiler arguments rather than using the helper function for this purpose. This caused each target type to add arguments in a different order, and to forget to add some arguments respectively: C#: /nologo, -warnaserror Java: warning level (-nowarn, -Xlint:all, -Xdoclint:all), debug arguments (-g, -g:none), -Werror Swift: -warnings-as-errors Fix this. Also fix up some no-longer-unused argument processing in the Compiler implementations.
2023-12-23Remove `get_buildtype_args` functionCharles Brunet
This is a first step to make `buildtype` a true alias of `debug` and `optimization` options. See #10808. Relates to: - #11645 - #12096 - #5920 - #5814 - #8220 - #8493 - #9540 - #10487 - #12265 - #8308 - #8214 - #7194 - #11732
2023-12-13Use SPDX-License-Identifier consistentlyDylan Baker
This replaces all of the Apache blurbs at the start of each file with an `# SPDX-License-Identifier: Apache-2.0` string. It also fixes existing uses to be consistent in capitalization, and to be placed above any copyright notices. This removes nearly 3000 lines of boilerplate from the project (only python files), which no developer cares to look at. SPDX is in common use, particularly in the Linux kernel, and is the recommended format for Meson's own `project(license: )` field
2023-08-11treewide: automatic rewriting of all comment-style type annotationsEli Schwartz
Performed using https://github.com/ilevkivskyi/com2ann This has no actual effect on the codebase as type checkers (still) support both and negligible effect on runtime performance since __future__ annotations ameliorates that. Technically, the bytecode would be bigger for non function-local annotations, of which we have many either way. So if it doesn't really matter, why do a large-scale refactor? Simple: because people keep wanting to, but it's getting nickle-and-dimed. If we're going to do this we might as well do it consistently in one shot, using tooling that guarantees repeatability and correctness. Repeat with: ``` com2ann mesonbuild/ ```
2023-06-26linkers: delay implementations import until detect is runEli Schwartz
This saves on a 1500-line import at startup and may be skipped entirely if no compiled languages are used. In exchange, we move the implementation to a new file that is imported instead. Followup to commit ab20eb5bbc21ae855bcd211131132d2778602bcf.
2023-04-11Change "can not" to "cannot" throughout projectHiPhish
The word "cannot" expresses inability to do something whereas "can not" expresses the ability to refrain from doing something.
2022-10-25Compilers: Keep ccache and exelist separatedXavier Claessens
Only combine them in the Compiler base class, this will make easier to run compiler without ccache.
2022-10-24Not all compilers support depfileXavier Claessens
2022-10-09compilers: Add optimization=plain optionJan Tojnar
https://github.com/mesonbuild/meson/pull/9287 changed the `optimization=0` to pass `-O0` to the compiler. This change is reasonable by itself but unfortunately, it breaks `buildtype=plain`, which promises that “no extra build flags are used”. `buildtype=plain` is important for distros like NixOS, which manage compiler flags for optimization and hardening themselves. Let’s introduce a new optimization level that does nothing and set it as the default for `buildtype=plain`.
2022-07-03move various unused typing-only imports into type-checking blocksEli Schwartz
2022-01-10compilers: push the compiler id to a class variableDylan Baker
It really is a per class value, and shouldn't be set per instance. It also allows us to get rid of useless constructors, including those breaking mypy
2021-06-29fix: Always explicitly set encoding for text files (fixes #8263)Daniel Mensinger
2021-01-04use OptionKey for compiler_optionsDylan Baker
2020-10-01compilers/swift: Add type annotationsDylan Baker
2020-09-24compilers: make is_cross part of the base Compiler classDylan Baker
Every class needs to set this, so it should be part of the base. For classes that require is_cross, the positional argument remains in their signature. For those that don't, they just allow the base class to set their value to it's default of False.
2020-09-24compilers: put name_string method in base compilerDylan Baker
Every language had the exact same implementation
2020-03-29compilers: Fix accidental coredata mutationsOle André Vadla Ravnås
2020-01-08types: import typing as T (fixes #6333)Daniel Mensinger
2019-12-12compilers: move language attribute to the class levelDylan Baker
We know that if a compiler class inherits CCompiler it's language will be C, so doing this at the class level makes more sense.
2019-10-07compilers: replace CompilerType with MachineInfoDylan Baker
Now that the linkers are split out of the compilers this enum is only used to know what platform we're compiling for. Which is what the MachineInfo class is for
2019-08-30compilers: Move the compiler argument to proxy linker flags to the compiler ↵Dylan Baker
class Instead of the DynamicLinker returning a hardcoded value like `-Wl,-foo`, it now is passed a value that could be '-Wl,', or could be something '-Xlinker=' This makes a few things cleaner, and will make it possible to fix using clang (not clang-cl) on windows, where it invokes either link.exe or lld-link.exe instead of a gnu-ld compatible linker.
2019-08-14compilers: Dispatch to dynamic linker classDylan Baker
Most of the cuda code is from Olexa Bilaniuk. Most of the PGI code is from Michael Hirsc
2019-08-14compilers/swift: Pass extra args to the Compiler constructorDylan Baker
2019-06-09Purge `is_cross` and friends without changing user interfacesJohn Ericson
In most cases instead pass `for_machine`, the name of the relevant machines (what compilers target, what targets run on, etc). This allows us to use the cross code path in the native case, deduplicating the code. As one can see, environment got bigger as more information is kept structured there, while ninjabackend got a smaller. Overall a few amount of lines were added, but the hope is what's added is a lot simpler than what's removed.
2019-03-27Sanity check with external argsJohn Ericson
Previously cross, but not native, external args were used. Then in d451a4bd97f827bb492fd0c0e357cb20b6056ed9 the cross special cases were removed, so external args are never used. This commit switches that so they are always used. Sanity checking works just the same as compiler checks like has header / has library.
2019-02-15Remove get_cross_extra_flagsJohn Ericson
This is no longer needed, we just remove conditionals around it.
2019-01-06Added more compiler option supportDaniel Mensinger
2019-01-06Absolute path generation refactoringDaniel Mensinger
2019-01-06Added unit testDaniel Mensinger
2019-01-06Fixed list_target_files and list_targetsDaniel Mensinger
2018-08-18Convert buildtype to optimization and debug options (#3489)Jussi Pakkanen