summaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter/interpreterobjects.py
AgeCommit message (Collapse)Author
2023-02-15interpreter: add a feature.enable_auto_ifDylan Baker
It's always been strange to me we don't have an opposite method of the `disable_auto_if` method, but I've been pressed to find a case where we _need_ one, because `disable_auto_if` can't be logically contorted to work. I finally found the case where they're not equivalent: when you don't want to convert to a boolean: ```meson f = get_option('feat').disable_auto_if(not foo) g = get_option('feat').enable_auto_if(foo) dep1 = dependency('foo', required : f) dep2 = dependency('foo', required : g) ```
2023-01-31log running commands a bit better by doing proper shell quotingEli Schwartz
2022-11-29pylint: enable the bad_builtin checkerDylan Baker
This finds uses of deny-listed functions, which defaults to map and filter. These functions should be replaced by comprehensions in idiomatic python because: 1. comprehensions are more heavily optimized and are often faster 2. They avoid the need for lambdas in some cases, which make them faster 3. you can do the equivalent in one statement rather than two, which is faster 4. They're easier to read 5. if you need a concrete instance (ie, a list) then you don't have to convert the iterator to a list afterwards
2022-11-24Fix various spelling errorsDavid Robillard
Found with codespell.
2022-05-25Make a copy of auto_features options when changing its nameXavier Claessens
This fixes bogus messages "skipped: feature foo disabled" when auto_features=disabled. It was reporting the name of the latest get_option() call instead of the name of the current feature option. This is especially visible in GStreamer summary where it should show a different option name for every subproject but instead shows "tools" everywhere: ``` Subprojects gst-devtools : NO Feature 'tools' disabled gst-editing-services : NO Feature 'tools' disabled ... ```
2022-05-01Merge pull request #10039 from eli-schwartz/wayland-protocols-subproject-filesJussi Pakkanen
dependencies: allow get_variable to expose files from subprojects
2022-04-14typoEli Schwartz
2022-04-13dependencies: move DependencyVariableString handling to declare_dependencyEli Schwartz
This allows tracking which subproject it came from at the time of definition, rather than the time of use. As a result, it is no longer possible for one subproject which knows that another subproject installs some data files, to expose those data files via its own declare_dependency.
2022-04-13dependencies: allow get_variable to expose files from subprojectsEli Schwartz
There are somewhat common, reasonable and legitimate use cases for a dependency to provide data files installed to /usr which are used as command inputs. When getting a dependency from a subproject, however, the attempt to directly construct an input file from a subproject results in a sandbox violation. This means not all dependencies can be wrapped as a subproject. One example is wayland-protocols XML files which get scanned and used to produce C source files. Teach Meson to recognize when a string path is the result of fetching a dep.get_variable(), and special case this to be exempt from subproject violations. A requirement of this is that the file must be installed by install_data() or install_subdir() because otherwise it is not actually representative of what a pkg-config dependency would provide.
2022-04-13dependencies: tighten type checking and fix cmake API violation for get_variableEli Schwartz
dep.get_variable() only supports string values for pkg-config and config-tool, because those interfaces use text communication, and internal variables (from declare_dependency) operate the same way. CMake had an oddity, where get_variable doesn't document that it allows list values but apparently it miiiiiight work? Actually getting that kind of result would be dangerously inconsistent though. Also, CMake does not support lists so it's a lie. Strings that are *treated* as lists with `;` splitting don't count... We could do two things here: - raise an error - treat it as a string and return a string It's not clear what the use case of get_variable() on a maybe-list is, and should probably be a hard error. But that's controversial, so instead we just return the original `;`-delimited string. It is probably the wrong thing, but users are welcome to cope with that somehow on their own.
2022-03-29move a bunch of imports into TYPE_CHECKING blocksEli Schwartz
These are only used for type checking, so don't bother importing them at runtime. Generally add future annotations at the same time, to make sure that existing uses of these imports don't need to be quoted.
2022-03-13Merge pull request #9339 from dcbaker/submit/structured_sourcesJussi Pakkanen
Structured Sources
2022-03-07treewide: string-quote the first argument to T.castEli Schwartz
Using future annotations, type annotations become strings at runtime and don't impact performance. This is not possible to do with T.cast though, because it is a function argument instead of an annotation. Quote the type argument everywhere in order to have the same effect as future annotations. This also allows linters to better detect in some cases that a given import is typing-only.
2022-03-07interpreter: Add a holder for StructuredSourcesDylan Baker
And teach the interpreter how to use it
2022-03-07Fix mypy CI.Jussi Pakkanen
2022-03-07Merge pull request #10043 from dcbaker/submit/type-checking-for-subprojectJussi Pakkanen
Add typing for subproject()
2022-03-06find_program: add a version() method to match the one for dependenciesEli Schwartz
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-03interpreter: fix mismatched type expectationsDylan Baker
2022-03-03interpreter: add cm_interpreter to SubprojectHolderDylan Baker
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-01clean up FeatureCheck signature to move location to use timeEli Schwartz
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-02-28Allow setting method/separator in environment() and meson.add_devenv()Xavier Claessens
2022-02-14FeatureNew: add mypy type annotations for subproject argEli Schwartz
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-09add some forgotten FeatureNew annotationsEli Schwartz
Forgotten in #8512.
2022-02-01interpreter: support for forcibly verbose logging of some testsPaolo Bonzini
Add a new keyword argument to test() and benchmark(), completing the implementation of the feature. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-01-23interpreterobjects: Don't warn on set10(bool)Dylan Baker
Python inherited a really bad design from C, booleans happen to be ints. Which is awful, but it's true. Fixes: #9858
2022-01-18interpreterobjects: deprecated passing a number to configuration_data.set10Dylan Baker
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-18interpreterobjects: remove no-flattening from configuraiton_data.getDylan Baker
It's no longer required because we don't allow arrays as fallbacks anymore.
2022-01-18interpreterobjects: don't allow keyword arguments in configuration_data.keysDylan Baker
Which do nothing, and shouldn't be allowed.
2022-01-18interpreter: replace ConfigurationDataObject with ConfigurationDataHolderDylan Baker
This is much cleaner, and more in line with the way we handle interpreter objects in modern meson practice
2022-01-18interpreterobjects: clean up ConfigurationData initializerDylan Baker
2022-01-18interpreterobjects: use typed_* for configuration_data.set*Dylan Baker
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-18interpreterobjects: use typed_* with configuration_data.merge_fromDylan Baker
2022-01-18interpreterobjects: use typed_* with configuration_data.get_unquotedDylan Baker
2022-01-18interpreterobjects: use typed_args for configuration_data.getDylan Baker
2022-01-18interpreterobjects: use typed_pos_args and noKwargs for configuration.data.hasDylan Baker
2022-01-18interpreterobjects: use typed_kwargs for dependency.get_variableDylan Baker
2022-01-18interpreterobjects: use typed_kwargs for dependency.get_pkgconfig_variableDylan Baker
2022-01-18dependencies: don't pass kwargs from get_pkgconfig_variableDylan Baker
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-18interpreterobjects: use typed_kwargs for FeatureOption.requireDylan Baker
2022-01-18interpreterobjects: use typed_pos_args for FeatureOpotionDylan Baker
2022-01-18interpreterobjects: use typed_pos_args for dependency.as_system_methodDylan Baker
2022-01-18interpreterobjects: use typed_pos_args for dependency.get_configtool_variableDylan Baker
2022-01-18interpreterobjects: use typed_pos_args for dependency.get_pkgconfig_variableDylan Baker
2022-01-18interpreterobjects: consistently use dependency. for error messagesDylan Baker
We currently use a mixture of dependency, Dependency, and dep
2021-12-17Fix mypy errorsDaniel Mensinger
2021-12-06interpreter: use build.GeneratedTypesPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-12-06interpreter: allow extract_objects to receive generated sourcesPaolo Bonzini
Fixes: #8333
2021-12-01add install_symlink functionPablo Correa Gómez
Allows installing symlinks directly from meson, which can become useful in multiple scenarios. Current main use is to help moving forward #9557
2021-11-30fix broken FeatureNew checks that never printedEli Schwartz
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-25interpreter: fix `feature.require` handling of error messageBenoit Pierre
Don't show a blank error when no `error_message` was passed as argument.