Commit Graph

795 Commits

Author SHA1 Message Date
Florian "sp1rit"​ 855cf199fc android: Added android_exe_type kwargs to executable
By setting android_exe_type to `application`, the executable gets
actually built as a shared library instead of an executable. This makes
it possible to use an application within an android application process.

mesonbuild#13758
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/7555/
2025-04-17 19:01:22 +03:00
Florian "sp1rit"​ da28caa63d build/executable: Respect name_prefix
executable did not respect the name_prefix kwarg
2025-04-17 19:01:22 +03:00
Kacper Michajłow e574889f68 ninjabackend: ensure that native static libraries use Unix-style naming
Depending on the target/linker, rustc --print native-static-libs may
output MSVC-style names. Converting these to Unix-style is safe, as the
list contains only native static libraries.

Fixes linking with C targets built with clang on x86_64-pc-windows-msvc
target.

Fixes: #14366
2025-04-16 13:02:28 -04:00
Charles Brunet 43816f6643 fixes for mypy 2025-04-09 18:41:00 +03:00
Dylan Baker 3c4417f381 backend/ninja: Fortran targets need to -I transitive deps private dirs
Otherwise they won't be able to find their module outputs.

This requires a new method to look at dependencies, as the existing ones
wont find static libraries that were linked statically into previous
targets (this links with A which link_whole's B). We still need to have
B in that case because we need it's BMI outputs.
2025-04-03 12:27:07 -07:00
Paolo Bonzini b13cd10516 build, interpreter: associate a doctest target to a BuildTarget
A doctest target is a separate build target (with its own linker
arguments, including dependencies) that is built and added as a
unit test whenever the parent target is built.  The doctest's
target is not accessible via ninja.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-02 08:44:37 -07:00
Eli Schwartz e5286aefd9
handle monorepo license files specified in project() via ../
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-20 13:44:41 -04:00
Dylan Baker 4fa5292545 coredata: replace get_option with optstore.get_value_for
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-10 14:14:25 -04:00
Paolo Bonzini 528696300a mesonlib: extract and optimize is_parent_path
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-03-09 13:05:08 -04:00
Paolo Bonzini e0fd2ffae5 build: cache target id at time of first use 2025-03-06 13:47:55 -08:00
Jussi Pakkanen 910bfb997b Remove unused variable left over from option refactor. 2025-02-25 19:46:34 +02:00
Jussi Pakkanen f44689645e Use override value when setting up Cython language.
Closes #14284.
2025-02-25 19:46:34 +02:00
Campbell Jones df79a51571 build: Optimize transitive link dep resolution
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-19 14:01:56 -05:00
Jussi Pakkanen d37d649b08 Make all Meson level options overridable per subproject. 2025-02-13 23:57:48 +02:00
Dylan Baker ea678ed829 build: fix typing of `Target.get_option`
Which can return any of `ElementaryOptionValues`, but is currently typed
as if it only returns `str | int | bool`.
2025-02-12 10:35:35 -08:00
Charles Brunet 843895b860 Fix broken both_libraries transitive dependencies
#13837 broke both_lib transitive deps, because the
`as_static` and `as_shared` functions return libraries
that still contain references to the other lib type.
2025-01-19 20:51:30 +02:00
Jussi Pakkanen 5713f6a7ef
Merge pull request #12342 from gerioldman/TaskingCCompiler
Add support for the TASKING compiler family, and its MIL linking feature
2025-01-09 14:50:49 +02:00
Benjamin Gilbert c508b26867 Copyedit an error message
Fixes: 47acce8ec9 ("Provide a better error message when mixing host and build machines")
2025-01-08 17:14:40 -05:00
gerioldman b95e1777dd First draft version of Tasking MIL linking with b_lto and prelinking 2025-01-08 01:52:03 +01:00
gerioldman 62c5db2cb3 Add TASKING compiler support 2025-01-08 01:52:03 +01:00
Charles Brunet b7260e8031 Fix internal dependency names
Internal dependency names were generated from object id. This cause
problem when objects are copied, especially when generating partial
dependency, or when extracting shared or static dependencies from
both_library, because dependency names in target and dependencies
introspection files become unrelated.

This fixes that by generating the dependency name from the internal id,
and by using that base name when generating partial dependencies.
2025-01-07 20:43:28 +02:00
Charles Brunet d8ea5c4d88 fix generate_gir with BothLibraries dependency
Co-authored-by: Xavier Claessens <xclaesse@gmail.com>
2024-12-06 10:50:32 -08:00
Nick 7b10f48d1c De-duplicate BuildTarget.sources
If the same source is provided by multiple dependencies it was added
multiple times, as `added_sources` was only guarding against duplicates
within the same source list. This was not a problem with ninja, but it
triggers multiple sanity checks within xcode backend while attempting to
create multiple ids for the same file.

Rename `added_sources` to `seen_sources` as per reviewers request
2024-11-20 01:53:20 -05:00
Dylan Baker f1a09aabf1 build: store Build.modules as a set
Since it's only used to check membership, a set makes more sense. Also
add some documentation to the attribute
2024-11-15 11:32:50 -08:00
Florent Valette 1aac6cc1ec compiler,rust: fix sanity check and internal deps for baremetal rust project/target
Sanity check for bare metal rust wasn't working for a while and there is a pending PR (#12175).
To workaround this problem, we used to let sanity check for build machine and manually defined
rustc target.

Commit 18f8aeda8b breaks this workaround as, even without an
exe_wrapper, native_static_libs are appends as internal deps.

This behaviour makes sense for cross compiled rust in a rich environment but not any for
no-std rust. As said in comments, one can't tell if the code is no-std or not because this is
an annotation from sources. From our point of view, it is pretty clear that building a no-std
rust target means that one has to define system='bare metal' and kernel='none' in his cross-file.

According to that, sanity_check for rust compiler is modified to handle kernel == 'none' case
by building a specific no-std rust snippet, with an extra args if rust_ld is ls.bfd (in order
to prevent the linker to link with a potentially non existing startfile for the given target).
'native_static_libs' is also leave empty in that very case.

This commit fix the spurious native static libs for no-std case and allow us to remove
our dirty workaround which by-passed non working sanity check for bare metal rust.

One who wants to use meson for baremetal Rust project only have to define the rust target
in their cross file.
 e.g.
   rust = ['rustc', '--target', '<rustc valid target>']
2024-09-24 14:56:01 -07:00
Charles Brunet ce1602c1ee alias_target with both_libs builds both 2024-09-06 10:56:44 -07:00
Charles Brunet 0fc363021e auto select static or shared when linking both_libraries together 2024-09-06 10:56:44 -07:00
Charles Brunet 2d6915a598 add default_both_libraries core option 2024-09-06 10:56:44 -07:00
Charles Brunet 7b3169f464 allow internal_dependency object to carry both_lib
Otherwise, the both_libs object is resolved by the interpreter and we no
longer have access to it from the dependency object.
2024-09-06 10:56:44 -07:00
Eli Schwartz 19847ba24a
update various deprecation notices to call out meson 2.0 2024-08-30 15:44:13 -04:00
Nirbheek Chauhan bdc2f2774c Fix some small typing issues in interpreter.py 2024-07-31 10:31:26 -04:00
Dylan Baker a51be6b1c7 backend/ninja: stop adding random attributes to BuildTargets
Instead of storing the generated header cache in the Target, store it in
the NinjaBackend, as it really is just data for the NinjaBackend to use.
2024-07-30 14:40:41 -07:00
Eli Schwartz 823779a9b1
mypy: add annotation for object attribute used as a private cache via hasattr
If it exists, we want to know it has the right type when we use it in
ninjabackend.py.
2024-07-30 14:13:11 -04:00
Alyssa Ross a05f6a260e rust: recursively pull proc-macro deps for rust targets
aee941559 ("rust: recursively pull proc-macro dependencies as well")
had to be reverted (in a66cb97e8) because it broke Mesa cross
compilation.  This happened because a C shared library was linked with
a Rust C-ABI static library, which caused it to inherit the proc macro
dependency the Rust static library was linked with.

The right way to handle this is for only Rust targets to inherit proc
macro dependencies from static libraries they link with.  A Rust
executable, library, or whatever will need the proc macros its Rust
dependencies use, as illustrated in the test case that I've
reintroduced here.

I've verified that Mesa still cross compiles correctly with this
change.  The same failure was also identified by the "rust/21
transitive dependencies" test case, but only when cross compiling, so
it wasn't caught by CI.

Co-authored-by: Xavier Claessens <xavier.claessens@collabora.com>
2024-07-17 13:20:16 -04:00
Jussi Pakkanen 61c742fae9 Remove language (AKA compiler) type from OptionKey. 2024-07-17 18:37:51 +03:00
Jussi Pakkanen 0d7bb776e2 Move OptionKey in the option source file. 2024-07-11 11:53:39 +03:00
Jussi Pakkanen 9a6fcd4d9a Replace direct indexing with named methods. 2024-06-14 17:19:53 +03:00
Jussi Pakkanen c0d86024f5 Rename option variable to optstore to make it unique. 2024-06-14 17:19:53 +03:00
Sam James a66cb97e8c
Revert "rust: recursively pull proc-macro dependencies as well"
This reverts commit aee941559c.

The commit being reverted breaks compilation of a major Meson consumer
(Mesa). As a result, various distros are either pinning to <1.4.0 (before
the commit) or performing this same revert downstream.

Fixing a regression takes priority, so let's revert.

Fixes: https://github.com/mesonbuild/meson/issues/12973
2024-05-24 17:10:20 -04:00
Jussi Pakkanen 128f0e828e
Pass wrapmode value around as a string. (#13229) 2024-05-19 20:58:46 +03:00
Tristan Partin 23eb7ba700 Use correct subdir when generating processed file path
We need the subdir of where the output file will actually be created,
not the current subdir of the interpreter.

Fixes: #13168
2024-05-07 13:20:39 -07:00
Gerion Entrup 06bc8a8d37 depends keyword argument: accept CustomTargetIndex
That holds for all of these meson function: run_target, generator and
custom_target and additionally to the Windows and Gnome module.
2024-04-05 09:36:59 -07:00
Petr Machacek eb74bb8dbf Added support for Texas Instruments C6000 compiler. 2024-03-12 20:38:30 +02:00
Xavier Claessens aee941559c rust: recursively pull proc-macro dependencies as well
When the proc-macro rlib is in a different subdir, it would miss the
needed -L argument and rustc would not find it. Meson was assuming that
proc-macros are only needed when building libraries that uses it, but it
turns out that was wrong, as show by the unit test.
2024-02-29 11:35:28 -05:00
Dylan Baker 8283e4900d build: get_default_install_dir() can be (None, None) or (str, str) 2024-02-22 09:05:07 -08:00
Dylan Baker 477783a65b build: fix some type annotations for get_install_dir 2024-02-22 09:05:07 -08:00
Eli Schwartz 4e5df4b3b7
fix crash in generator.process() with an invalid preserve_path_from
This code cleverly tried to use a fancy new pathlib.Path method to get
the os.path.commonpath of two paths and check whether one is inside the
other. It failed pretty badly, because of a hidden secret of pathlib: it
is designed to throw random exceptions at all times (except when
building os.PathLike interfaces) instead of performing useful work.
Return to `os.path`.

In particular, before this change, we wanted to check if files are NOT
in a subpath of `preserve_path_from`, and raise a meson "ERROR: xxx" in
such a case. However, the code to check for it would raise a python
ValueError if that was the case, so we never got to the properly
formatted error.
2024-02-21 16:38:29 -05:00
Dylan Baker 47acce8ec9 Provide a better error message when mixing host and build machines
Since we don't get a location for these errors, we can at least tell you
which targets you happen to be mixing together that produce this
problem.

Ran into while trying to debug a target mixing bug.
2024-02-20 09:50:44 -08:00
Charles Brunet d7bf365acd Fix compiler.preprocess compile_args not used
As described in
https://github.com/mesonbuild/meson/issues/12715#issuecomment-1883448780,
the compiler.preprocess function ignores compile_args. This should fix
it in both ninja and visualstudio backends.
2024-01-25 11:06:56 -08:00
Stas Sergeev 92f638e1f9 compiler.preprocess: add depends kwarg
This patch adds 'depends' keyword to compiler.preprocess().
It allows to execute other targets before doing the preprocessing.
Test-case is added to demonstrate that functionality: it
generates the header before preprocessing the C source that
uses that generated header.

Thanks to @bruchar1 for getting this patch to work.
2024-01-17 13:37:36 -08:00