Commit Graph

577 Commits

Author SHA1 Message Date
Dylan Baker b07d4bb206 build: Add a couple of type annotations for the Interpreter to use 2022-03-03 10:29:14 -08:00
Remi Thebault 4fe6f0dd29 add D features to InternalDependency 2022-03-03 08:42:56 -08:00
Dylan Baker b4a512b9f8 build: Add a `__bool__` dunder to ConfigurationData
Which will be used by the `configure_file` method of the interpreter.
2022-03-01 15:17:59 -05:00
Xavier Claessens 6acfe48f32 Allow setting method/separator in environment() and meson.add_devenv() 2022-02-28 09:03:27 -05:00
Xavier Claessens 24f224777d devenv: Add --dump option
It prints all envorinmente variables that have been modified. Can be
used by shell scripts that wish to setup their environment themself.
2022-02-28 09:03:27 -05:00
Tristan Partin 80cb87e7b7 Change jar() default install dir
The previous install dir seemed incorrect when looking at various Linux
distributions.
2022-02-28 11:44:29 +02:00
Eli Schwartz 9daaece785
flake8: fix various whitespace errors with badly aligned code 2022-02-16 23:00:31 -05:00
Eli Schwartz aa0450adda
fix a couple misuses of textwrap.dedent
A backslash-escape of the last newline before a run of whitespace
leading to the indented string ending and function termination `)` does
not actually escape the entire line and make it do nothing. In fact what
it does is cause all that whitespace to be part of the preceding line,
and get printed.

Meanwhile the textwrap.dedent documentation states that lines with only
whitespace get normalized. When you *don't* mess with that final line,
dedent actually does the right thing and makes the output message end
with a single newline after the important text.
2022-02-16 22:59:48 -05:00
Nirbheek Chauhan 2d56ff135e shared module: Allow linking on Android
Android requires shared modules that use symbols from other shared
modules to be linked before they can be dlopen()ed in the correct
order. Not doing so leads to a missing symbol error:
https://github.com/android/ndk/issues/201

We need to always allow linking for this. Also add a soname, although
it's not confirmed that it's needed, and it doesn't really hurt if it
isn't needed.
2022-02-14 23:30:24 -05:00
Eli Schwartz c0b8e02d9f
FeatureNew: add mypy type annotations for subproject arg
Use a derived type when passing `subproject` around, so that mypy knows
it's actually a SubProject, not a str. This means that passing anything
other than a handle to the interpreter state's subproject attribute
becomes a type violation, specifically when the order of the *four*
different str arguments is typoed.
2022-02-14 20:40:41 -05:00
William Toohey b4d9b2551c Genericise TI compiler and add MSP430 support 2022-02-02 16:45:05 +02:00
Dylan Baker 11f9638035 build: replace kwargs in CustomTarget initializer
Because we don't want to pass the Interpreter kwargs into the build
layer. This turned out to be a mega commit, as there's really on elegant
way to make this change in an incremental way. On the nice side, mypy
made this change super easy, as nearly all of the calls to
`CustomTarget` are fully type checked!

It also turns out that we're not handling install_tags in custom_target
correctly, since we're not converting the boolean values into Optional
values!
2022-01-28 15:53:20 -05:00
Dylan Baker 214ce0dc8b build: Fix return types of a couple of methods
These don't return `Target`, they return `BuildTarget | CustomTarget |
CustomTargetIndex`
2022-01-18 21:58:24 -05:00
Dylan Baker ce5f56f266 build: Fix annotations to RunTarget and AliasTarget
RunTargets and AliasTargets may depend on RunTargets, so annotate them
that way. The Gnome module relies on this internally.
2022-01-18 21:58:24 -05:00
Dylan Baker 23af9e4c1a build: move configuration_data initial value handling to build.ConfigurationData
It really belongs here, not in the interpreter
2022-01-18 17:53:29 -05:00
Eli Schwartz 4b351aef26
first pass at migrating to dataclasses
In some cases, init variables that accept None as a sentinel and
immediately overwrite with [], are migrated to dataclass field
factories. \o/

Note: dataclasses by default cannot provide eq methods, as they then
become unhashable. In the future we may wish to opt into declaring them
frozen, instead/additionally.
2022-01-10 18:36:57 -05:00
Jussi Pakkanen 251d6f0f5d
Merge pull request #9739 from mathstuf/armclang-support
Armclang support
2022-01-10 19:01:11 +02:00
Xavier Claessens 95a4c6a62a pkgconfig: Fix linking to a custom target
When generating pkgconfig file for a library that links to an
uninstalled static library built by custom_target() Meson was crashing
when trying to access some attributes that does not exist on that class.

Also fix is_internal() implementation, it only really make sense on a
CustomTargetIndex or if CustomTarget has only a single output.
2021-12-22 08:04:08 +05:30
Daniel Mensinger c5ce9744b2 Fix mypy errors 2021-12-17 14:00:28 -05:00
Ben Boeckel 786d437982 armclang: extend the prefix detection for Keil armclang
This will avoid false positives with the ARM Ltd. `armclang` compiler.
2021-12-16 17:08:26 -05:00
Paolo Bonzini 901f444ea5 interpreter: allow extract_objects to receive generated sources
Fixes: #8333
2021-12-06 13:27:12 -08:00
Eli Schwartz 4b2c54569d
clean up function signatures in preparation for dataclasses
FeatureCheck always immediately sets extra_message to '' if it isn't
explicitly passed, so there is really no point in using None as a
sentinel that is never used.

Names used in init functions are sometimes pointlessly different from
the class instance attributes they are immediately assigned to. They
would make more sense if defined properly.
2021-12-05 11:39:20 -05:00
Pablo Correa Gómez 4f882ff8ec add install_symlink function
Allows installing symlinks directly from meson, which can
become useful in multiple scenarios. Current main use is to
help moving forward #9557
2021-12-01 13:59:54 -05:00
Jussi Pakkanen bd509d11a5
Merge pull request #9531 from dcbaker/submit/interpreter-more-typing
More use of typed_* in the interpreter module
2021-11-27 21:44:41 +02:00
Mike Gilbert 91a099f3a7 Remove premature return in BuildTarget.check_module_linking()
We want to loop over all link_targets to update
backwards_compat_want_soname if necessary.

Fixes: ec9bdc6edb17d1d9da5df2d6525025242c119f3a
2021-11-27 20:16:34 +02:00
Nirbheek Chauhan af5993fffd shared_module: Add soname when used as a link target
Emit a detailed deprecation warning that explains what to do instead.
Also add a unittest.

```
DEPRECATION: target prog links against shared module mymod, which is incorrect.
             This will be an error in the future, so please use shared_library() for mymod instead.
             If shared_module() was used for mymod because it has references to undefined symbols,
             use shared_libary() with `override_options: ['b_lundef=false']` instead.
```

Fixes https://github.com/mesonbuild/meson/issues/9492
2021-11-24 23:18:53 +05:30
Dylan Baker f29b54dfe4 build|backend: Fix some type annotations
These currently say the take `Target`, but the really take
`BuildTarget | CustomTarget | CustomTargetIndex`.
2021-11-24 02:23:57 +05:30
Dylan Baker 75d163f56d build: TestSetup.exe_wrapper doesn't need to be optional
It works fine as-is with an empty list, and since that's easier to get
using our typed_kwargs, and thus is what we're passing, go ahead and
simplify the class to only take a list of strings.
2021-11-22 11:28:43 -08:00
Eli Schwartz dbb109703e
convert more mlog.deprecation into FeatureDeprecated 2021-11-20 20:48:29 -05:00
Eli Schwartz 1104b82137 fix custom_target with install: true and no install_dir, crashing
It's supposed to emit an error message, but instead it did a traceback.
It used to be, if no install_dir was specified then it was simply not in
kwargs, but due to typed_kwargs it will now be there, but not have
viable contents, so the dict membership check got skipped.

Fixes #9522
2021-11-02 19:56:10 -07:00
Dylan Baker 526b6b763a build: Add type annotations to BuildTarget.get_all_link_deps 2021-11-01 12:24:25 -07:00
Dylan Baker ac02521954 build: Add annotations to CustomTarget.extra_depends 2021-11-01 12:24:25 -07:00
Dylan Baker b572a7980e build: Add a get_command method to Executable
Since Executable can be used in places where ExternalProgram is, simply
having a wrapper that gives them the same API is pretty useful.
2021-11-01 12:24:25 -07:00
Dylan Baker 68c1669ae6 build: IncludeDirs extend `to_string_list` method to handle builddir 2021-11-01 12:24:25 -07:00
Dylan Baker 6472f013a1 build: Add type annotations for BuildTarget.include_dirs
The gnome module uses these, so to be able to fully type that we need
this.
2021-11-01 12:24:25 -07:00
Jussi Pakkanen c1b686e395 Make environment objects hash deterministically. 2021-10-29 22:47:06 +03:00
Jussi Pakkanen af85738daf
Merge pull request #9375 from dcbaker/submit/windows-module-typing
Typing for the Windows module
2021-10-29 22:45:04 +03:00
Eli Schwartz 8947352889 fix various flake8 whitespace errors 2021-10-27 09:51:52 -04:00
Xavier Claessens 928078982c Add --vsenv command line option and active VS only when needed 2021-10-10 23:15:18 +03:00
Christian Clauss a5020857f3 Fix typos discovered by codespell 2021-10-10 16:12:25 -04:00
Dylan Baker 0d52a6161a build: Add missing type annotation 2021-10-09 21:34:54 -07:00
Xavier Claessens 2628ce576c Add support for module options 2021-10-08 17:47:35 -04:00
Eli Schwartz 108bd996ee
add install_emptydir function
This replaces the absolute hack of using

```
install_subdir('nonexisting', install_dir: 'share')
```

which requires you to make sure you don't accidentally or deliberately
have a completely different directory with the same name in your source
tree that is full of files you don't want installed. It also avoids
splitting the name in two and listing them in the wrong order.

You can also set the install mode of each directory component by listing
them one at a time in order, and in fact create nested structures at
all.

Fixes #1604
Properly fixes #2904
2021-10-08 14:35:00 -04:00
Andres Freund 6b8f10cf6b backend/vs: Generate dependencies for CustomTargetIndex for a CustomTarget.
Test & fix.
2021-10-04 22:42:27 -04:00
Andres Freund a1542720f4 Record build in BuildTarget.link_depends, not just output of targets.
To be able to handle link_depends in backends that do not just operate on a
file basis like ninja, information about the targets, not just their output is
required.
2021-10-04 22:34:57 -04:00
Eli Schwartz e8a85fa8a2
various python neatness cleanups
All changes were created by running

"pyupgrade --py3-only"

and committing the results. Although this has been performed in the
past, newer versions of pyupgrade can automatically catch more
opportunities, notably list comprehensions can use generators instead,
in the following cases:
- unpacking into function arguments as function(*generator)
- unpacking into assignments of the form x, y = generator
- as the argument to some builtin functions such as min/max/sorted

Also catch a few creeping cases of new code added using older styles.
2021-10-04 16:29:30 -04:00
Dylan Baker c3c30d4b06 interpreter: Use typed_kwargs for func_custom_target
This does not convert the build side, or remove any of the checking it
does. We still need that for other callers of custom target. What we'll
do for those is add an internal interface that defaults things, then
we'll be able to have those callers do their own validation, and the
CustomTarget validation machinary can be removed.

Fixes #9096
2021-09-30 21:01:38 +02:00
Dylan Baker bb706231bd build: Prepare CustomTarget.process_kwargs to co-exist
We still need this to co-exist as long as there are interfaces for
CustomTarget other than `func_custom_target`, this gets us there.
2021-09-30 21:01:38 +02:00
Dylan Baker 7e417ac0fa build: Allow `Dict[OptionKey, str` in parse_overrides
We really want to move all of this option handling into the interpreter
through the typed_kwargs, this is the first step to that
2021-09-30 21:01:38 +02:00
Dylan Baker d25349e8cf build: Use isinstance(other, Target) instead of hasattr
In the comparison methods of Target. There are several problems with the
old implementation:
1. It's not idiomatic
2. It can match on things that It shouldn't (like a Compiler, which has
   a `get_id() -> str` method, but not one that we should compare with
   Targets
3. It confuses mypy, which doesn't handle hasattr
2021-09-30 21:01:38 +02:00