Commit Graph

83 Commits

Author SHA1 Message Date
Jussi Pakkanen ade6e3a19e
Merge pull request #10043 from dcbaker/submit/type-checking-for-subproject
Add typing for subproject()
2022-03-07 16:43:44 +02:00
Eli Schwartz 0f2f87a003
find_program: add a version() method to match the one for dependencies
It is often useful to check the found version of a program without
checking whether you can successfully find
`find_program('foo', required: false, version: '>=XXX')`
2022-03-06 19:41:21 -05:00
Dylan Baker 643b3f227e interpreter: fix mismatched type expectations 2022-03-03 10:30:31 -08:00
Dylan Baker 5787f81615 interpreter: add cm_interpreter to SubprojectHolder
This is used in the cmake module, as an extra attribute we just tack on.
Instead, let's actually define and type it.
2022-03-03 10:29:14 -08:00
Eli Schwartz d39b330075 clean up FeatureCheck signature to move location to use time
The point of a .use() function is because we don't always have the
information we need to use a feature check, so we allow creating the
feature and then storing it for later use. When implementing location
checks, although it is optional, actually using it violated that design.

Move the location out of the init method for FeatureCheck itself. It
remains compatible with all cases of .single_use(), but fix the rest up.
2022-03-01 12:13:24 -08:00
Xavier Claessens 6acfe48f32 Allow setting method/separator in environment() and meson.add_devenv() 2022-02-28 09:03:27 -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
Eli Schwartz 6c79e97eae
add some forgotten FeatureNew annotations
Forgotten in #8512.
2022-02-09 21:44:46 -05:00
Paolo Bonzini fc661c35a2 interpreter: support for forcibly verbose logging of some tests
Add a new keyword argument to test() and benchmark(), completing the
implementation of the feature.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-02-01 09:05:26 +01:00
Dylan Baker 4f40962a05 interpreterobjects: Don't warn on set10(bool)
Python inherited a really bad design from C, booleans happen to be ints.
Which is awful, but it's true.

Fixes: #9858
2022-01-23 17:21:53 -05:00
Dylan Baker 9c7ddf59fe interpreterobjects: deprecated passing a number to configuration_data.set10
This is currently allowed, and is used in at least a few projects. It
was not intended to work or documented, but it does and since it is in
use a full deprecation period must be used. A warning has also been
added for values < 0, which have surprising behavior.
2022-01-18 17:53:29 -05:00
Dylan Baker bf3fa728fa interpreterobjects: remove no-flattening from configuraiton_data.get
It's no longer required because we don't allow arrays as fallbacks
anymore.
2022-01-18 17:53:29 -05:00
Dylan Baker f16956a951 interpreterobjects: don't allow keyword arguments in configuration_data.keys
Which do nothing, and shouldn't be allowed.
2022-01-18 17:53:29 -05:00
Dylan Baker 5074e2d3b5 interpreter: replace ConfigurationDataObject with ConfigurationDataHolder
This is much cleaner, and more in line with the way we handle
interpreter objects in modern meson practice
2022-01-18 17:53:29 -05:00
Dylan Baker 5c979eb21f interpreterobjects: clean up ConfigurationData initializer 2022-01-18 17:53:29 -05:00
Dylan Baker 574525673f interpreterobjects: use typed_* for configuration_data.set*
This removes the ability to use ConfigurationData as a dict, but
restricting the inputs to `str | int | bool`. This may be a little too
soon for this, and we may want to wait on that part, it's only bee 8
months since we started warning about this.
2022-01-18 17:53:29 -05:00
Dylan Baker 7641bfd0ce interpreterobjects: use typed_* with configuration_data.merge_from 2022-01-18 17:53:29 -05:00
Dylan Baker f7cbe89a13 interpreterobjects: use typed_* with configuration_data.get_unquoted 2022-01-18 17:53:29 -05:00
Dylan Baker baa9ecb1c4 interpreterobjects: use typed_args for configuration_data.get 2022-01-18 17:53:29 -05:00
Dylan Baker 65558445ae interpreterobjects: use typed_pos_args and noKwargs for configuration.data.has 2022-01-18 17:53:29 -05:00
Dylan Baker 1ff2abcd9c interpreterobjects: use typed_kwargs for dependency.get_variable 2022-01-18 17:53:29 -05:00
Dylan Baker 1751dc4701 interpreterobjects: use typed_kwargs for dependency.get_pkgconfig_variable 2022-01-18 17:53:29 -05:00
Dylan Baker 6b272973e0 dependencies: don't pass kwargs from get_pkgconfig_variable
This is a layering violation, we're relying on the way the interpreter
handles keyword arguments. Instead, pass them as free variables,
destructuring in the interpreter
2022-01-18 17:53:29 -05:00
Dylan Baker ab9c0c1735 interpreterobjects: use typed_kwargs for FeatureOption.require 2022-01-18 17:53:29 -05:00
Dylan Baker 55055c3e0e interpreterobjects: use typed_pos_args for FeatureOpotion 2022-01-18 17:53:29 -05:00
Dylan Baker 6ad772cb37 interpreterobjects: use typed_pos_args for dependency.as_system_method 2022-01-18 17:53:29 -05:00
Dylan Baker 7537ec3299 interpreterobjects: use typed_pos_args for dependency.get_configtool_variable 2022-01-18 17:53:29 -05:00
Dylan Baker 0fa3436645 interpreterobjects: use typed_pos_args for dependency.get_pkgconfig_variable 2022-01-18 17:53:29 -05:00
Dylan Baker 482ab09a95 interpreterobjects: consistently use dependency. for error messages
We currently use a mixture of dependency, Dependency, and dep
2022-01-18 17:53:29 -05:00
Daniel Mensinger c5ce9744b2 Fix mypy errors 2021-12-17 14:00:28 -05:00
Paolo Bonzini 10329a1ebc interpreter: use build.GeneratedTypes
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-12-06 13:27:12 -08:00
Paolo Bonzini 901f444ea5 interpreter: allow extract_objects to receive generated sources
Fixes: #8333
2021-12-06 13:27:12 -08: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
Eli Schwartz 0ac2e4bb90
fix broken FeatureNew checks that never printed
They passed the arguments in the wrong order, so the version parsed as the
message and the message parsed as a version.

While we are at it, pass the location node in too.
2021-11-30 00:16:14 -05:00
Benoit Pierre 007c4659c2 interpreter: fix `feature.require` handling of error message
Don't show a blank error when no `error_message` was passed as argument.
2021-11-25 20:13:53 -05:00
Eli Schwartz 038b31e72b
various manual conversion of percent-formatted strings to f-strings 2021-11-01 20:26:18 -04:00
rusty-snake 85e92b5c4e Typo fixes (CustomTaget -> CustomTarget) 2021-10-30 14:29:17 -04:00
Christian Clauss a5020857f3 Fix typos discovered by codespell 2021-10-10 16:12:25 -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
Eli Schwartz 1bb2523e58
remove f from f-string that has no formatting 2021-10-04 16:29:31 -04:00
Daniel Mensinger 6b00c7dc81 Remove helpers.check_stringlist() 2021-09-25 12:44:11 +02:00
Daniel Mensinger 43a6b5bd5e interpreter: Remove permissive from _unholder 2021-09-01 19:17:01 +02:00
Dylan Baker 1fc3d8608d pylint: enable unnecessary-not check
This finds things like
```python
if not x == 1:
```
which should be
```python
if x != 1:
```
2021-08-31 16:28:54 -04:00
Dylan Baker 81f5cee218 interpreter: rename EnvironmentVariablesObject -> EnvironmentVariablesHolder
This is more consistent with other Holder classes
2021-08-30 18:05:02 -07:00
Dylan Baker 43f942be34 interpreterobjects: Use typed_kwargs for EnvironmentVariablesObject 2021-08-30 18:05:02 -07:00
Dylan Baker 3731e1d8f3 make EnvironmentVariablesObject a proper holder
Currently, EnvironmentVariablesObject is a strange
holder-that's-not-a-holder. This has implicaitons for things that expect
to get an EnvironmentVariables object, as we can't automatically
unholder it, and instead have to to manually do so. Now we can
automatically unholder it, which makes everything much nicer.
2021-08-30 18:05:02 -07:00
Dylan Baker d6a1f85248 Allow EnvironmentVariablesObject to be passed an EnvironmentVariables instance 2021-08-30 18:05:02 -07:00
Dylan Baker 11fbaf29d8 interpreter: fix cases of `KwargInfo(..., T, default=None)`
The correct way to mark these is `KwargInfo(..., (T, type(None)))`.
There's also a few cases of `(T, None)` which is invalid, as `None`
isn't a type
2021-08-27 14:54:29 -07:00
Dylan Baker abababfb93 interpreterobjects: fix Test annotations 2021-08-20 18:57:19 +02:00
Dylan Baker a1fb3199c8 interpreterobjects: Add TypedDict annoations for `extract_search_dirs`
This allows for more accurate type checking
2021-08-16 16:21:51 -07:00