summaryrefslogtreecommitdiff
path: root/mesonbuild/build.py
AgeCommit message (Collapse)Author
2025-12-22rust: add to_system_dependencyPaolo Bonzini
Move the logic for system dependencies outside Cargo.interpreter and into the rust module, so that it can be reused by the workspace object. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-12-22dependencies: make arguments to InternalDependency.__init__ optionalPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-12-17build: update comments on rust object linkingDylan Baker
Some of these issues have been resolved
2025-12-17build: clean up the `link` helperDylan Baker
Splits the subclass specific code into those classes
2025-12-17build|interpreter: use typed_kwargs for link_withDylan Baker
This replaces the long explanation of `external_library`s in the `link_with` parameter to the simpler one used by declare_dependency. Additionally, declare_dependency now checks that a target is linkable when adding it. This just catches the problem before it goes down into the build layer giving a better error message. There is a bug in the declare_dependency annotations, in that they don't mark Executable as acceptable. So I've fixed that.
2025-12-17build: clean up some some of the link_whole pathDylan Baker
This puts subclass specific logic in the subclasses, and cleans up some typing.
2025-12-17build|interpreter: use the LINK_WHOLE validator for BuildTargetDylan Baker
2025-12-17interpreter|build: Use typed_kwargs for build_target(dependencies)Dylan Baker
What is basically impossible is to handle `SubprojectHolder`, because it's not a true holder but an interpreter object. Well, impossible without changing SubprojectHolder into a true holder, because it's avoiding the circular import becomes extremely convoluted otherwise, and refactoring is difficult because the held object is itself an Interpreter. It's a rather complex problem to solve gracefully. I've punted to avoid the complexity, it does mean that the error message is somewhat less exact. I don't think this is actually a huge problem because we've really guided people away from using `subproject()` and to instead use dependency fallbacks, which don't have this problem to begin with. This removes validation from the build layer, and puts it in interpreter. For code sharing reasons this means that `internal_dependency` also gets more fine grained error messages. The test case for this has been modified to use the `testcase expect_error` construct, and thus has been moved to the common tests directory. It's also been extended to cover both the library case, which gives coverage for the `extra_types` in `KwargInfo`
2025-12-17interpreter: Add type checking for BuildTarget(install_dir: )Dylan Baker
This just puts the type checking in the frontend, there's still some serious cleanup in the build and backend that need to happen.
2025-12-16build: cleanup include_directories codeDylan Baker
With the previous change the build layer no longer needs to be concerned about strings
2025-12-16build: simplify `add_include_dirs`Dylan Baker
By setting the default `set_is_system` to `'preserve'`, we don't have to have a check for None inside the body of the method.
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-12-16remove get_source_subdirPaolo Bonzini
2025-12-08build: Add de-duplication for non-result targets in get_all_link_depsRobotLeopard86
2025-12-08build|interpreter: use typed_kwargs for BuildTarget(install_tag)Dylan Baker
2025-12-08build|interpreter: use typed_kwargs for BuildTarget(link_args)Dylan Baker
2025-11-19compilers: Remove Environment parameter from ↵Dylan Baker
Compiler.get_language_stdlib_only_link_flags
2025-11-19compilers: Remove Environment parameter from Compiler.get_library_dirsDylan Baker
2025-11-19rust: search for native static libs in target libdirAlyssa Ross
Sometimes, a Rust static library's native static libs refer to libraries installed in the rustc target libdir. This is always the case for most musl targets (with the intention of making it easier to use them on non-musl systems), and other targets can also be configured to do this using e.g. the llvm-libunwind option when building the standard libraries for the target. When rustc is responsible for linking it will always add the appropriate directory to the linker search path, but if we're not using Rust for linking, we have to tell the linker about that directory ourselves. The added test demonstrates a scenario where this comes up: linking a static Rust library, built for musl, into a C executable. -lunwind is in the native static libs list from the compiler, but it's referring to the libunwind.a in the self-contained directory.
2025-11-14build: Add `android_exe_type` to the Executable keyword argumentsDylan Baker
Which removes the need to assert it.
2025-11-14Add `os2_emxomf' option to generate OMF files on OS/2KO Myung-Hun
1. Generate OMF objs with `-Zomf' compiler flags 2. Generate OMF libs with `.lib' suffix using `emxomfar' as a librarian
2025-11-14Add `shortname' kwarg for a short DLL name on OS/2KO Myung-Hun
Give an user opportunities to mangle a custom short name for a DLL on OS/2.
2025-11-14Generate a shared library and an import library correctly on OS/2KO Myung-Hun
On OS/2, 1. a shared libary has '.dll' suffix 2. a length of DLL name should not be longer than 8 chars 3. an import library is used to link against a DLL 4. an import library has '_dll.a' suffix.
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-12intepreter: Move remaining PCH validation to InterpreterDylan Baker
2025-11-12interpreter: Move most of the remaining validation to the InterpreterDylan Baker
What's left requires the Environment, so it will have to be handled in the interpreter implementation for now.
2025-11-12interpreter: move deprecation validation for *_pch to the interpreterDylan Baker
2025-11-12Interpreter: do basic validation of PCH files in interpeterDylan Baker
This moves the listification and string checking to the interpreter, as well as some basic size validation.
2025-11-05interpreter: Move validation of BuildTarget(extra_files) to InterpreterDylan Baker
This gets us to the point that the build layer can assume it's getting valid inputs. This does two checks, an initial cheap check for generated sources, and then an I/O check via `source_strings_to_files`.
2025-11-05interpreter: move rust_api/rust_crate_type interaction to the interpreterDylan Baker
These are two ways to implement the same thing, and at the DSL level the `rust_abi` provides needed flexability, but at the lower level where a target is a thing, the `rust_crate_type` is still proving to be more useful. So, keep the `rust_abi` in the Interpreter and don't let it leak into the build layer.
2025-11-05build: Use the Literal for rust_crate_typeDylan Baker
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-10-29build: remove unnecessary try/exceptPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-23build: allow building staticlib and rlib togetherPaolo Bonzini
Fixes: #15028
2025-10-20build: Ensure that `vala_*` properties always exist, and are correctDylan Baker
This allows us to do a lot less proxy checking for vala, and lot more "If this thing says it's going to output vala, it's going to output vala. By only setting them when they use vala, we can also be sure that the fields aren't meaningless.
2025-10-20interpreter|build: Add type checking for vala specific argumentsDylan Baker
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-16build: pass Environment to GeneratedListPaolo Bonzini
GeneratedList does not need the full interpreter, only the source and build directories which can be found in Environment. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-16build: import EnvironmentPaolo Bonzini
2025-10-15backend/ninja: Ensure that a rust file is found when using StructuredSourcesDylan Baker
When a structured source contains non rust files, the backend may select such a file to treat as the main file. That doesn't work obviously, so instead filter the main file such that it must be a rust file.
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-15build: clean up some of the types with swift argumentsDylan Baker
This just prevents some unintended instances of values become None, now they always remain strings or literal-strings
2025-10-15build: simplify validation of BuildTarget(extra_files: )Dylan Baker
There is some validation going on here that cannot (currently) be done the KwargInfo validators, namely that the files exist. Additionally, BuildTarget.extra_files is doing some membership checking for dups, which means it should probably be an OrderedSet instead of a list.
2025-10-15build: Remove validation for `build_by_default`Dylan Baker
2025-10-15build: remove validation for C# resourcesDylan Baker
2025-10-15build: remove implicit_include_directories validationDylan Baker
2025-10-15build: remove validation for name prefix and suffixDylan Baker
2025-10-15build: remove validation from BuildTarget(link_depends: )Dylan Baker