summaryrefslogtreecommitdiff
path: root/mesonbuild/backend/backends.py
AgeCommit message (Collapse)Author
2025-12-17backend: improve error message about install_dir install_count mismatchDylan Baker
Among other things it will say "expects X but only has Y", even if Y > X.
2025-12-16review get_subdir vs get_builddirPaolo Bonzini
Comparing the implementation of build_subdir with https://github.com/mesonbuild/meson/pull/12258, both of them introduced a similar separation between srcdir and builddir. There were some differences in the choices of srcdir vs builddir; this commit tries to identify which are bugs in which implementation, and get the best of both worlds.
2025-11-19compilers: Remove Environment parameter from Compiler.get_option_compile_argsDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.get_option_std_argsDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.get_program_dirsDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.get_library_dirsDylan Baker
2025-11-17Support Visual Studio 2026.Jussi Pakkanen
2025-11-14Extension of the executable is `exe' on OS/2KO Myung-Hun
2025-11-12build: Use a tuple for pch dataDylan Baker
This really isn't a list because it's not homogenous data, it's really `tuple[str, str | None] | None`, but we're using list length to decide what to do with it, and that makes for strict null issues, as an accurate annotation would be `list[str | None]`, which would require a lot of `is not None` checking. By using a tuple we don't need to keep checking length, which is more expensive than null checking. To ensure correctness I annotated some things in the VS backend
2025-11-11vala: Remove space from --target-glib versionChris Mayo
If the dependency version contains a space: dependency('glib-2.0', version: '>= 2.40.0') Then the --target-glib version has a space: --target-glib ' 2.40.0' The quotes and space have no effect on valac. Tidy the output.
2025-11-04Add build target keyword parameter 'build_subdir' [v8]Keith Packard
Place the build products in a directory of the specified name somewhere within the build directory. This allows use of the target that includes a specific directory name: #include <subdir/configure.h> This also allows creating targets with the same basename by using different subdirectory names. v2: Move build_subdir to Target class. Error if path separator in build_dir v3: Rename to 'build_subdir' to make it clear that the name is appended to a meson-specific build directory, and does not provide the user with a way to define the overall meson build hierarchy. Allow build_subdir to include path separators. Support 'build_subdir' for configure_file. build_subdir must not exist in the source directory and must not contain '..' Add documentation and tests v4: Rebase and prepare for version 1.9.1 Add failing test case when build_subdir is present in the project. Add release note snippet v5: Clarify wording on restrictions on the value of build_subdir. Use the same wording in each place this restriction is described. v6: Move path validation to shared function, validate_build_subdir, instead of duplicating the tests in two places. v7: Update version numbers to 1.10.0 Add TypedDict updates. Remove spurious build_subdir instance variable v8: Oops, missed one version number update. Signed-off-by: Keith Packard <keithp@keithp.com>
2025-11-03backends: add CustomTargetIndexes to meson-{test,benchmark}-prereqPaolo Bonzini
If a CustomTargetIndex is passed as an argument to a test, running meson test (with no test glob) does not automatically build the custom_target before running the test, because CustomTargetIndex outputs are not added as prerequisites to the meson-test-prereq and meson-benchmark-prereq targets. Fixes: #14743 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-29environment, backends: remove is_* methodsPaolo Bonzini
They are duplicates of what is already in compilers and have no state. Just use compilers. Fixes: #15082 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-16backend: remove InterpreterPaolo Bonzini
No one is accessing backend.interpreter anymore, get rid of it to avoid future temptations. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-16build, backend: store build_def_files in BuildPaolo Bonzini
The interpreter's build_def_files are the only remaining piece of interpreter state used by the backend. Compute it once and store it in build, using a property to ensure that it's initialized and accessed correctly. This also removes one of the cases in which introspection uses the interpreter object. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-16build: do not pass Interpreter to Generator.process_filesPaolo Bonzini
All that is needed is the subdir, pass it explicitly (and make it an optional argument so that the backend does not have to pass it). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-16build: store Environment in GeneratorPaolo Bonzini
Objects like targets already store the environment in which they were created, do the same for Generator: pass it to the constructor and use it in process_files. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-15revert local_program()Eli Schwartz
This reverts https://github.com/mesonbuild/meson/pull/15107 Explicit objections regarding the design were raised and not answered, so it shouldn't have been merged. It needs to be discussed and revisited.
2025-10-15Add support for LocalProgram to override_find_program()Xavier Claessens
2025-10-14Make use of build TypeAliasesDylan Baker
There are a lot of spelled out unions for these types, lets reduce that number
2025-10-03backend: fix typing of get_target_dir_relative_toDylan Baker
Which should be `Target | CustomTargetIndex`, not just `Target`
2025-09-22utils, backends: add and use unique_listPaolo Bonzini
backends.py has an interesting idiom for keeping the unique elements of a list. This is much faster than OrderedSet: * dict.fromkeys() vs. OrderedSet.__init__(): 35% faster on Python 3.13, 50-60% faster on Python 3.10 * list(d) (d is a dict) vs. list(os) (os is an OrderedSet): up to 25% faster on Python 3.13, up to 15% faster on Python 3.10 though it tapers out after a few hundred elements. Add a function to mesonlib to encapsulate this idiom. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-08-25linkers: Fix dsymutil being unable to symbolicate binaries with LTOL. E. Segovia
According to https://clang.llvm.org/docs/CommandGuide/clang.html#cmdoption-flto, the -object_path_lto flag is needed to preserve the intermediate object files.
2025-08-18Revert "backends: Use POSIX paths for target paths"Jussi Pakkanen
This reverts commit 12563f74a9f3dda70dcd4778aa958de355d1fae7.
2025-08-10minstall: allow missing symlink destination in `install_symlink`Konstantin Kharlamov
Currently there's an undocumented behavior where using `install_symlink()` to point to a file that does not exist results in failure `ERROR: Tried to install symlink to missing file`. Such behavior makes little sense because there's no reason the destination file should exist. The "destination file" may belong to another package, in particular to a package inside the same repo the Meson is controlling, in both cases there's no reason the other package should be present in the system, because installation does not typically happen into the system but rather to DESTDIR. And the file may not be present in DESTDIR either because it may belong to a different installation target (and different DESTDIR) even if it's in the same repo. Best backward-compatible decision here would be to just remove the check, which is done by this commit. Fixes: https://github.com/mesonbuild/meson/issues/12253
2025-08-01move rpath functions from Backend to BuildTargetCharles Brunet
It is more logical, since those functions depend on a build target, and do not require anything specific to the backend. Furthermore, it will allow us to call determine_rpath_dirs from the linker in a following commit, without the need to depend on the backend.
2025-08-01typing: determine_rpath_dirs is only called with BuildTargetCharles Brunet
2025-08-01simplify get_external_rpath_dirsCharles Brunet
coredata.get_external_link_args always returns a list
2025-07-29ninjabackend: pass objects to generate_rust_target from non-Rust sourcesPaolo Bonzini
Make generate_rust_target essentially a replacement from generate_link, plus the actual generation of rustc compiler arguments. Remove the parts (especially flatten_object_list and get_fortran_order_deps) that generate_target already does, and add any objects files that were produced by compiling non-Rust sources. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-07-13backends: Use POSIX paths for target pathsL. E. Segovia
This commit completes 5de09cbe8838e8febf1ca3aa83b53cf06972bff3, ensuring that only POSIX style paths are passed to the compiler line, and thus fixing UNIX-style tools that treat single backward slashes as Unicode escaped characters. Fixes #12191 Completes #12534 Completes #12564
2025-06-23vala: Also add --target-glib if glib is built as subprojectFlorian "sp1rit"​
Previously, meson would only check if glib was part of target.external_dependencies and add --target-glib appropriately. This however had the downside of meson not adding --target-glib if glib was included as a subproject, potentially breaking otherwise builds. Instead of checking external_dependencies, check target.added_deps for an occurrence of 'glib-2.0' and then pick the appropriate codepath (either from the external dependency based on version_reqs or for the internal dependency based on the actual version, potentially downgraded to the latest release version) Related-to: #14694
2025-06-17Test serialization: Simplify determination of Windows extra pathsLuca Bacci
Pointed out by Charles Brunet
2025-06-17Test serialization: Also look for depends when setting PATH on WindowsLuca Bacci
Fixes https://github.com/mesonbuild/meson/issues/4668
2025-06-17Test serialization: set LD_LIBRARY_PATH also on DarwinLuca Bacci
It's needed on Darwin for the same reason it's needed on generic UNIX. Darwin supports both LD_LIBRARY_PATH and DYLD_LIBRARY_PATH, but the two are not quite equivalent [1], so we set both. [1] https://github.com/ffi/ffi/blob/29ad900a/lib/ffi/dynamic_library.rb#L40
2025-06-03gnome.mkenums: Fix get_executable_serialisation passing ExternalPrograms ↵L. E. Segovia
script without interpreter This is an indirect regression of e8c715786d85dcdbc367f3e379acae25a899c235; the code never accounted for ExternalPrograms that needed a harness.
2025-05-22gnome.mkenums: Allow passthrough of ExternalPrograms to enable converting ↵L. E. Segovia
only the real arguments to response file
2025-05-22gnome.mkenums: Use rspfiles on Windows when possibleL. E. Segovia
Fixes #6710
2025-04-23determine_windows_extra_paths: sort internal dependencies firstLuca Bacci
Fixes #12330
2025-04-04compilers: introduce get_option_std_argsPaolo Bonzini
Allow CUDA to completely override the -std arguments but not the rest. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-02compilers: introduce get_exe() and get_exe_args()Paolo Bonzini
This will be used by rustdoc tests because the Test objects takes a single string for the command and everything else goes in the args. But apart from this, the need to split the executable from the arguments is common so create new methods to do it. While at it, fix brokenness in the handling of the zig compiler, which is checking against "zig" but failing to detect e.g. "/usr/bin/zig". Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-03-20handle monorepo license files specified in project() via ../Eli Schwartz
We should simply remap these to elide the ../ as it's pretty obviously the natural expectation of using ../ to fetch files from outside the project and then drop them *into* the project. Monorepos will likely have a single license file (or set) under which the monorepo is licensed. But there will be many components, each of which may use a different build system, which are "standalone" for the most part. We already support this case as long as you build from the monorepo, but the resulting license file gets installed to ``` {licensedir}/../ ``` which is silly and unhelpful. Bug: https://github.com/apache/arrow/issues/36411
2025-03-10coredata: replace get_option with optstore.get_value_forDylan Baker
This is an old method, that is now just a wrapper around the OptionStore method, that doesn't add any value. It's also an option related method attached to the CoreData instead of the OptionStore, so useless and a layering violation.
2025-03-09Optimize canonicalize_filenameCharles Brunet
Using str.split is faster than Path.parts
2025-03-09mesonlib: extract and optimize is_parent_pathPaolo Bonzini
Introduce an alternative to os.path.commonpath(name, path) == path, which is a common idiom throughout Meson. Call it is_parent_path just like the existing static method in Generator. It is a bit faster and handles drives on Windows without the need for an exception handler. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-02-27use ElementaryOptionValues instead of open coding... againDylan Baker
2025-02-19build: Optimize transitive link dep resolutionCampbell Jones
In large repositories, transitive link dependency resolution using the current recursive algorithm can result in enough duplicate calls to cause the full system memory space to be used up. This commit simplifies link dep resolution by converting the currently used recursive algorithm to an iterative one that avoids performing work more than once. If a target's direct dependencies have already been processed, that target will not be processed again. These changes result in multiple orders of magnitude of improvements to dep resolution time and memory usage in the worst case. Co-authored-by: Xavier Claessens <xavier.claessens@collabora.com>
2025-02-13Make all Meson level options overridable per subproject.Jussi Pakkanen
2025-01-31Fix PATH for SharedModule in Windows devenvCharles Brunet
SharedModule (like Python extension modules) are loaded dynamically. Therefore, they cannot be detected from executable dependencies, and we must call `determine_windows_extra_paths` on them as well. Also, those extra paths need to be computed even if the module or the executable is not installed in the default location.
2025-01-27backends: cache file names for ExtractedObjectsPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-01-27backends: remove proj_dir_to_build_root from _determine_ext_objsPaolo Bonzini
This is a very hot function, improve the memoization of the results by removing an argument (that is almost always empty, in fact). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>