summaryrefslogtreecommitdiff
path: root/mesonbuild/ast/introspection.py
AgeCommit message (Collapse)Author
2025-10-15build: Add a TypedDict for BuildTarget keyword argumentsDylan Baker
This has the "processed" keyword arguments that the interpreter is supposed to create for us, or that we expect internal users to build by build. This requires some hacking around in the rust module for the moment because we suddenly have a type.
2025-10-06interpreter: unify and specialize code to set backend optionsPaolo Bonzini
Avoid different but equivalent code between ast and regular interpreter, and avoid using coredata.set_options since all options are known to be backend options. Move to environment since it uses environment.options. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-06introspection: remove dead codePaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-09-24ast/introspection: remove keyword arguments from build targets that are ↵Dylan Baker
UnknownValue It is not the build layer's job to handle ast types, so instead filter out UnknownValues before passing them to the build layer, then fix up any special values we need in the ast layer. This reveals that some of what we were previously doing only works because the build layer is pretty much untyped, if it was typed it would have screamed loudly.
2025-08-10rewriter: Accept UnknownValue() in more placesVolker Weißmann
Fixes #14840
2025-07-07ast, interpreter: look up default_library and default_both_libraries by ↵Paolo Bonzini
subproject This is already done most of the time for default_library but not in these cases. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-29rewriter: Rewrite how we add/remove source filesVolker Weißmann
Change the semantics of IntrospectionBuildTarget.source_nodes and IntrospectionBuildTarget.extra_files . The rewriter and the static introspection tool used to be very broken, now it is *less* broken, hence we add some tests in this commit. Fixes #11763
2025-05-29Add AstInterpreter.funcvalsVolker Weißmann
`AstInterpreter.node_to_runtime_value` can now resolve function calls.
2025-05-29AstInterpreter: Replace resolve_node with node_to_runtime_valueVolker Weißmann
`resolve_node` is simply a half-broken, worse implementation of `node_to_runtime_value` that we recently introduced. In the example below, the static introspection tool/rewriter now understands that the name of the executable is foo instead of bar: ``` var = 'foo' name = var var = 'bar' executable(name, 'foo.c') ```
2025-05-29rewriter: Remove apparently useless code.Volker Weißmann
Without this commit, something like this crashes the static introspection/rewrite tool: ``` default_options : ['warning_level=' + run_command(['echo', '3']).stdout().strip()], ``` This commit does not reintroduce #14382.
2025-05-29rewriter: Replace assignments with cur_assignmentsVolker Weißmann
Replace the variable tracking of `AstInterpreter.assignments` with a slightly better variable tracking called `AstInterpreter.cur_assignments`. We now have a class `UnknownValue` for more explicit handling of situations that are too complex/impossible.
2025-05-29rewriter.py: make type safeVolker Weißmann
2025-05-29rewriter: Add IntrospectionDependencyVolker Weißmann
To improve type-safety and readability we replace a dictionary with a new class `IntrospectionDependency`.
2025-05-29rewriter: Add IntrospectionBuildTargetVolker Weißmann
To improve type-safety and readability we replace a dictionary with a new class `IntrospectionBuildTarget`.
2025-05-29Refactoring and removal of dead codeVolker Weißmann
2025-05-29rewriter: Don't ignore the `name_prefix` kwargVolker Weißmann
2025-05-15coredata: remove unused argumentsPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-15introspection: do not reinvent process_compiler_optionsPaolo Bonzini
Let add_compiler_options and process_compiler_options handle subprojects, and also run it for the main project to ensure that pending_options are properly processed. This exposes a bug because "comp" could have been None, so fix that. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-07options: support non-string data types in more placesPaolo Bonzini
Allow OptionStringLikeDict to use non-string data types, and use it as much as possible instead of string-valued dictionaries. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-07ast: clean up handling of default optionsPaolo Bonzini
Do not go through string first and OptionKey second. Just pass the OptionKeys down. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-04-08coredata: delete set_default_optionsDylan Baker
This was only being used by the introspection interpreter, which meant the two interpreters had different behavior. They still do, which is really bad because the IntrospectionInterpreter doesn't have the command line options or project_default_options. I have a plan to fix that later, and I don't want to spend time on it here, as it's not a regression of this patch, it's just the status quo. This also fixes an issue caused by dead code being left, and hit, due to the option refactor branch. Fixes: #14382
2025-03-14Move options loading to InterpreterBaseCharles Brunet
2025-03-14Move variables to InterpreterBaseCharles Brunet
subproject_dir, environment, and coredata
2025-03-14Move flatten_kwargs to IntrospectionInterpreterCharles Brunet
It is not used elsewhere
2025-03-10coredata: replace get_option with optstore.get_value_forDylan Baker
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-02-13Make all Meson level options overridable per subproject.Jussi Pakkanen
2024-12-19introspect: add machine to target_sourcesPaolo Bonzini
Even though the "targets" introspection info already includes the command line arguments used to invoke the compiler, this is not enough to correlated with the "compilers" introspection info and get extra information from there. Together with the existing "language" key, adding a "machine" key is enough to identify completely an entry in the compilers info. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-11-15ast/introspection: Drop duplicate None checkDylan Baker
The AstInterpreter does this check as well, so don't do it twice.
2024-10-13mintro: Add license and license_files to project introspection dataDaniele Nicolodi
2024-07-11Move OptionKey in the option source file.Jussi Pakkanen
2024-07-11Move backend option check into OptionStore.Jussi Pakkanen
2024-07-11Move project option detection into OptionStore.Jussi Pakkanen
2024-06-14Replace direct indexing with named methods.Jussi Pakkanen
2024-06-14Rename option variable to optstore to make it unique.Jussi Pakkanen
2024-05-23Refactor option classes to their own file.Jussi Pakkanen
2024-05-19pylint: fix useless-returnEli Schwartz
A bare return at the end of a function doesn't do anything. And in the case of a try/except, it's really just an elaborate "pass" anyway.
2024-04-08parser: revert to single StringNode typeCharles Brunet
this will allow transforming string types in the formater
2024-03-18coredata: remove extraneous keys when updating project_optionsDylan Baker
This can happen when a project's meson.options file is updated, and an old option is removed.
2024-03-10fix reconfigure subproject base optionsCharles Brunet
2024-02-23coredata: use a Protocol for shared options between setup configure and distDylan Baker
These are all passed around interchangably inside Meson, so use a shared protocol for them.
2024-01-08ast/interpreter: fix some low hanging type issuesDylan Baker
2024-01-08ast/introspection: make mypy cleanDylan Baker
2023-12-13Use SPDX-License-Identifier consistentlyDylan Baker
This replaces all of the Apache blurbs at the start of each file with an `# SPDX-License-Identifier: Apache-2.0` string. It also fixes existing uses to be consistent in capitalization, and to be placed above any copyright notices. This removes nearly 3000 lines of boilerplate from the project (only python files), which no developer cares to look at. SPDX is in common use, particularly in the Linux kernel, and is the recommended format for Meson's own `project(license: )` field
2023-09-13fix undefined StringNode from previous commitCharles Brunet
2023-09-12Merge pull request #12152 from bruchar1/ast-preserve-allJussi Pakkanen
Preserve whitespaces and comments in AST
2023-09-12msubprojects: Speedup subproject_dir extractionXavier Claessens
The interpreter takes significant amount of time to initialize everything in project() function. We only need to extract a string from AST, just like we do in handle_meson_version_from_ast().
2023-09-11parser: use IdNode for function name and assignment nameCharles Brunet
2023-09-11parser: preserve escape chars in stringsCharles Brunet
use separate Node for multiline strings
2023-08-11treewide: automatic rewriting of all comment-style type annotationsEli Schwartz
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-11remove useless type annotationsEli Schwartz
These annotations all had a default initializer of the correct type, or a parent class annotation.