Commit Graph

725 Commits

Author SHA1 Message Date
Dylan Baker 32be9bd6de add support for vs_module_defs to Executables
fixes: #9254
2023-09-28 14:35:01 -04:00
Dylan Baker 5421c24ea0 fix using a CustomTargetIndex for vs_module_defs
Because `CustomTargetIndex`es don't have a `subdir` property, but they do
implement the `get_subdir()` method
2023-09-28 14:35:01 -04:00
Dylan Baker f4ea89be60 interpreter: use typed_kwargs for build_target(vs_module_defs) 2023-09-28 14:35:01 -04:00
Dylan Baker f485a8cf16 interpreter: use typed_kwargs for static_library(pic) 2023-09-28 11:31:56 -07:00
Dylan Baker 798791baac interpreter: use typed_kwargs for static_library(prelink) 2023-09-28 11:31:56 -07:00
Xavier Claessens c6f33aed2d Rust: Fix proc-macro usage when cross compiling
Force BUILD machine and allow to link with HOST machine.
2023-09-19 13:54:49 -04:00
Xavier Claessens 7592003484 Rust: Prevent linking Rust ABI with C library/executable 2023-09-19 13:54:49 -04:00
Xavier Claessens 10dcd87d00 Rust: Replace rust_crate_type with rust_abi
Meson already knows if it's a shared or static library, user only need
to specify the ABI (Rust or C).
2023-09-19 13:54:49 -04:00
Arsen Arsenović 0af126fec7 install_{data,headers,subdir}: implement follow_symlinks
This permits users who rely on following symlinks to stay on the old
default of following them.
2023-09-13 21:44:40 -04:00
Xavier Claessens b2654b2d43 Fix crash when installing a vala library and python sources
Installing python sources causes the python module to call
create_install_data() before Ninja backends adds extra outputs to Vala
targets.

Target objects are supposed to be immutable, adding outputs that late is
totally wrong. Add extra vala outputs immediately, but be careful
because the main output is only added later in post_init(). Luckily
the base class already puts a placeholder item in self.outputs for the
main filename so we can just replace self.outputs[0] instead of
replacing the whole list which would contain vala outputs at that stage.
This is surprisingly what SharedLibrary was already doing.
2023-09-07 10:56:37 -04:00
Xavier Claessens d5f17bc9ff Rename OptionOverrideProxy to OptionsView and move to coredata
Coredata is where all option handling is done so it makes sense there.
It is a view on a list of options for a given subproject and with
optional overrides. This change prepare for using that view in a more
generic way in the future.
2023-09-07 06:55:07 -04:00
Xavier Claessens 4eb9c84cf9 include_directories: Always add both source and build dirs
Compiler checks were not adding build dir side, which prevents using
headers generated with configure_file().
2023-08-28 20:18:26 -04:00
Xavier Claessens 6f87215f1f build: Simplify import_filename handling
This removes deadcode, vs_import_filename and gcc_import_filename were
not needed.
2023-08-24 18:50:12 -04:00
Charles Brunet 7cbe37ebd9 Add more descriptive description to CustomTarget
Allow modules using CustomTarget to modify the command description used by ninja backend. This result in more precise logs when building a project.
2023-08-18 00:36:49 -04:00
Dylan Baker 9d32302032 interpreter: use typed_kwargs for shared_library(darwin_versions) 2023-08-14 09:55:18 -07:00
Dylan Baker 09bc028c71 interpreter: use typed_kwargs for shared_library(soversion) 2023-08-14 09:55:18 -07:00
Dylan Baker cd676e229b interpreter: use typed_kwargs for shared_library(version) 2023-08-14 09:55:18 -07:00
Eli Schwartz 90ce084144
treewide: automatic rewriting of all comment-style type annotations
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-08-11 13:41:03 -04:00
Xavier Claessens 926c3a6919 Error when an installed static library links to internal custom target
When an installed static library A links to an internal static library B
built using a custom_target(), raise an error instead of a warning. This
is because to be usable, A needs to contain B which would require to
extract the archive to get its objects files.

This used to work, but was printing a warning and was installing a
broken static library, because we used to overlink in many cases, and
that got fixed in Meson 1.2.0. It now fails at link time with symbols
from the custom target not being defined. It's better to turn the
warning into a hard error at configure time.

While at it, noticed this situation can happen for any internal custom
or rust target we link to, recursively.
get_internal_static_libraries_recurse() could be called on CustomTarget
objects which do not implement it, and even if we did not call that
method, it would still fail when trying to call extract_all_objects() on
it.

Fixes: #12006
2023-08-07 05:44:08 -07:00
Alexandre Janniaux f3b9db9e9d build.py: improve BuildTarget error message
Improve the error message when a build target is assigned as dependency
of another build target, which allows to better pinpoint where the issue
lies on.

In the example that follow, modules/meson.build:294 is in a for loop
creating library targets from an array of dictionary, and doesn't point
to the location where interop_sw_plugin is assigned with vlc_opengl:

Before:

    modules/meson.build:294:17: ERROR: Tried to use a build target as a dependency.
    You probably should put it in link_with instead.

After:

    modules/meson.build:294:17: ERROR: Tried to use a build target vlc_opengl as a dependency of target interop_sw_plugin.
    You probably should put it in link_with instead.

It would probably be best to directly pinpoint where the assignment was
made but it's probably harder so start simple by saying what is
concerned by the error.
2023-08-06 10:24:26 -04:00
Eli Schwartz 404312c6dd do better sanity check for vs_module_defs input
We allow custom_target() but check for it based on hasattr, ever since
the initial implementation way back in the day, in commit
66a6ea984b. This is a bit broken because
various objects might support that but still aren't supposed to work. We
can actually just use isintance checks like we do immediately above,
which are more accurate and avoid crashes on things that aren't even
targets at all, like run_target(). Although custom_target indexes are
actually targets those didn't work either.

Fixes #9648
2023-07-31 11:00:22 -07:00
Dylan Baker 1a182ab599 make 'gui_app' an interpreter only concept
Since it's deprecated anyway, we don't really want to plumb it all the
way down into the build and backend layers. Instead, we can just turn
it into a `win_subsystem` value in the interpreter if `win_subsystem`
isn't already set.
2023-07-25 13:29:08 -04:00
Dylan Baker 1cfbe5279d interpreter: use typed_kwargs for Executable(win_subsystem) 2023-07-25 13:29:08 -04:00
Dylan Baker 67035a181e interpreter: use typed_kwargs for gui_app 2023-07-25 13:29:08 -04:00
Dylan Baker 9faf91d14f build: remove useless method call
This does nothing, so just delete it.
2023-07-24 14:24:15 -04:00
Dylan Baker c8241d79e4 build: remove BuildTarget.need_install
This would be either the value `kwargs['install']`, or `False`. There
isn't any case that `BuildTarget.need_install` handles that
`BuildTarget.install` doesn't handle, if we just initialized it
correctly. So, just set Target.install correctly in the super
initializer, and do away with need_install.
2023-07-24 14:24:15 -04:00
Dylan Baker 01b5581a10 build|interpreter: move main_class to typed_kwargs
Also move it into the Jar class. This is an exclusive Jar keyword
argument, and is only used inside java paths, so there's no reason to
have this in all build targets.
2023-07-20 14:20:46 -04:00
Eli Schwartz 0bb1647fd1
move various bits of type-checking only code to TYPE_CHECKING blocks
Mostly detected with flake8-type-checking. Also quote T.cast() first
arguments, since those are not affected by future annotations.
2023-07-19 18:31:37 -04:00
Eli Schwartz 7afc69254d
fix implicit_reexport issues and enforce them going forward
This detects cases where module A imports a function from B, and C
imports that same function from A instead of B. It's not part of the API
contract of A, and causes innocent refactoring to break things.
2023-07-19 18:31:37 -04:00
Charles Brunet 3e3d5e97c3 Fix display of generator 2023-07-13 13:26:33 -04:00
Xavier Claessens 1fef03c0f0 build: dependencies should come after link_with on link command
This fixes regression caused by
3162b901ca
that changes the order in which libraries are put on the link command.

In addition, that commit was wrong because libraries from dependencies
were processed before process_compiler() is called, which that commit
wanted to avoid.
2023-07-10 23:12:24 +03:00
Xavier Claessens cd63853ad2 build: Fix linking multiple libraries and some are promoted
When a link() is promoted to link_whole() we still have to handle the
rest of the list.

Fixes: #11956
2023-07-10 23:12:24 +03:00
Dylan Baker 8369dbbfec build: use self.compilers instead of all_compilers for stdlib langs
We need a union of the compilers used by the target, and by those used
by all dependencies, not all the compilers in all projects. We do,
however, need to look compilers up from all possible compilers, as a
dependency that is a subproject could use a language not present in the
current project.
2023-07-05 07:17:26 -04:00
Jussi Pakkanen d391e5281c
Merge pull request #11742 from xclaesse/link-whole-cases
Fix niche cases when linking static libs
2023-07-05 01:10:58 +03:00
Dylan Baker 772cb92624 rust: get stdlib arguments for non-rust languages when linking
Otherwise we might not get things like libstdc++, which we need.
2023-06-27 11:53:18 -07:00
Eli Schwartz a1ef957e34
linkers: delay implementations import until detect is run
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 ab20eb5bbc.
2023-06-26 13:10:33 -04:00
Xavier Claessens 6c480085d5 rust: PIC is always enabled
rustc enables PIC by default and Meson currently has no way to force
disabling PIC, it can only force enable or use compiler's default.
2023-06-07 13:18:58 -04:00
Volker Weißmann 12a2dc86ca Allow generator.process(generator.process(...))
Fixes #1141
2023-05-21 22:12:57 +03:00
Xavier Claessens c6db870fc7 rust: Add system libs used by rust std to staticlib external deps 2023-05-20 10:35:42 -04:00
Xavier Claessens ff86e799a4 extract_all_objects: Include PCH object with MSVC
This changes the object file name with ninja backend to match the
name used by vs backend and add it in outputs of the ninja rule.
2023-05-01 12:57:45 -04:00
Xavier Claessens 25f4f77a3b Rust: Allow Rust static libraries to link_whole other libraries
Rustc can do it without needing Meson to extract all objects.
2023-05-01 12:57:45 -04:00
Xavier Claessens 3162b901ca build: Process compilers before calling link() and link_whole()
To take good decisions we'll need to know if we are a Rust library which
is only know after processing source files and compilers.

Note that is it not the final list of compilers, some can be added in
process_compilers_late(), but those are compilers for which we don't
have source files any way.
2023-05-01 12:57:45 -04:00
Xavier Claessens 01949df4f6 build: Don't do a deep copy of kwargs
It seems to only be used by the Rust module now, and it already does a
copy.
2023-05-01 12:57:45 -04:00
Xavier Claessens 2dadc3ae5b Rust: C static library cannot link_whole Rust static library 2023-05-01 12:57:45 -04:00
Xavier Claessens a78af23686 Fix niche cases when linking static libs
Case 1:
- Prog links to static lib A
- A link_whole to static lib B
- B link to static lib C
- Prog dependencies should be A and C but not B which is already
  included in A.

Case 2:
- Same as case 1, but with A being installed.
- To be useful, A must also include all objects from C that is not
  installed.
- Prog only need to link on A.
2023-05-01 12:57:45 -04:00
Nomura 18cfa545f0 Initial support for Metrowerks C/C++ compiler 2023-04-24 09:07:37 -04:00
Sebastian Dröge 01420bf8fc rust: Add new `rust_dependency_map` target configuration
This allows changing the crate name with which a library ends up being
available inside the Rust code, similar to cargo's dependency renaming
feature or `extern crate foo as bar` inside Rust code.
2023-04-21 15:35:06 -04:00
Charles Brunet fbab1488ae extra_files keyword in declare_dependency() 2023-04-20 18:31:39 +03:00
Sebastian Dröge e2c454b86e rust: Also disallow `.` in Rust library target names 2023-04-20 13:53:26 +05:30
Sebastian Dröge 3c9817fe7f rust: Don't allow spaces/dashes in Rust library names
The library names are directly mapped to filenames by meson while the
crate name gets spaces/dashes replaced by underscores. This works fine
to a certain degree except that rustc expects a certain filename scheme
for rlibs that matches the crate name.

When using such a library as a dependency of a dependency compilation
will fail with a confusing error message.

See https://github.com/rust-lang/rust/issues/110460
2023-04-20 13:53:26 +05:30