aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter/interpreter.py
AgeCommit message (Collapse)AuthorFilesLines
2023-03-20backends: add a new "none" backendEli Schwartz1-0/+2
It can only be used for projects that don't have any rules at all, i.e. they are purely using Meson to: - configure files - run (script?) tests - install files that exist by the end of the setup stage This can be useful e.g. for Meson itself, a pure python project.
2023-03-09configure_file: emit FeatureNew when a cmake-formatted file has too many tokensEli Schwartz1-1/+1
In commit 97a72a1c53e68cf53541285075b4000f7c85ccc6 we started to allow cmakedefine with 3 tokens, as cmake expects (unlike mesondefine). This would silently start working even if the declared minimum version was older than 0.54.1
2023-03-09interpreter: Add missing Union annotationDylan Baker1-1/+1
2023-03-01interpreter: report FeatureNew for kwargs to project()Eli Schwartz1-1/+1
We need to know the project minimum version before evaluating the rest of the function. There's three basic approaches: - try to set it inside KwargInfo - just run a minimal version of func_project for this, then load everything after - drop down to the AST and set it before anything else In order to handle FeatureNew emitted by a FunctionNode evaluated before project() due to being inlined, such as `version: run_command()`, only option 3 suffices, the rest all happen way too late. Since we have just added AST handling support for erroring out, we can do that to set the version as well.
2023-03-01handle meson_version even when the build file fails to parseEli Schwartz1-4/+19
If the meson.build file is sufficiently "broken", even attempting to lex and parse it will totally fail, and we error out without getting the opportunity to evalaute the project() function. This can fairly easily happen if we add new grammar to the syntax, which old versions of meson cannot understand. Setting a minimum meson_version doesn't help, because people with a too-old version of meson get parser errors instead of advice about upgrading meson. Examples of this include adding dict support to meson. There are two general approaches to solving this issue, one of which projects are empowered to do: - refactor the project to place too-new syntax in a subdir() loaded build file, so the root file can be interpreted - teach meson to catch errors in building the initial AST, and just load enough of the AST to check for meson_version advice This implements the latter, allowing to future-proof the build grammar.
2023-03-01interpreter: Add testcase..endtestcase clause supportXavier Claessens1-1/+21
This is currently only enabled when running unit tests to facilitate writing failing unit tests. Fixes: #11394
2023-02-20interpreter: Do not ignore all exceptions when adding compilerXavier Claessens1-1/+1
Suppressing all exceptions was hidding even syntax errors in compiler source code. If a compiler cannot be found, a MesonException is raised, we should only expect that type.
2023-02-09respect the machine file binary overrides, even if it doesn't existEli Schwartz1-1/+3
If someone specifies a binary in a machine file, but the resulting prog.found() is false because it doesn't actually exist on disk, then the user was probably trying to disable finding that program. But find_program() currently doesn't distinguish between a machine file lookup returning a not-found program, and returning a dummy program because there's no entry at all. Explicitly check for a dummy program, rather than checking if the program was found, before deciding whether to discard the lookup results and continue trying other program lookup methods.
2023-02-01pylint 2.16: raise a more intentional exceptionEli Schwartz1-1/+1
Include a frivolous error message too. We never see it, but if someone reads the code and wonders why on *earth* there's a DSL function to raise a RuntimeError, the message string will clue them in.
2023-01-18interpreter: use typed_pos_args for build_targetsDylan Baker1-11/+48
We have to allow through build.BuildTarget and build.ExtractedObjects, which is what our previous level of checking did, even though they are ignored. I've used FeatureDeprecated calls here, so that we have a clear time of "this was officially deprecated in 1.1.0"
2023-01-04add objects keyword argument to declare_dependenciesPaolo Bonzini1-1/+4
2023-01-03reformat some warnings for better code readabilityDylan Baker1-4/+6
2022-12-27add license_files kwarg to projectEli Schwartz1-3/+16
Hook this up to installed dependency manifests. This is often needed above and beyond just an SPDX string -- e.g. many licenses have custom copyright lines.
2022-12-24interpreter: use static_lib's already calculated pic valueDylan Baker1-9/+1
Instead of re-calculating it when building both libraries
2022-12-11typing: fix some broken Sequence annotationsEli Schwartz1-1/+1
T.Sequence is a questionable concept. The idea is to hammer out generic, maximally forgiving APIs that operate on protocols, which is a fancy way of saying "I don't care if you use tuples or lists". This is rarely needed, actually, and in exchange for this fancy behavior you get free bugs. Specifically, `somestr` is of type `T.Sequence[str]`, and also `somestr[0]` is another string of type you guessed it. It's ~~turtles~~ strings all the way down. It's worth noting that trying to code for "protocols" is a broken concept if the contents have semantic meaning, e.g. it operates on "the install tags of this object" rather than "an iterable that supports efficient element access". The other way to use T.Sequence is "I don't like that T.List is invariant, but also I don't like that T.Tuple makes you specify exact ordering". This sort of works. In fact it probably does work as long as you don't allow str in your sequences, which of course everyone allows anyway. Use of Sequence has cute side effects, such as actually passing lists around, knowing that you are going to get a list and knowing that you need to pass it on as a list, and then having to re-allocate as `list(mylist)` "because the type annotations says it could be a str or tuple". Except it cannot be a str, because if it is then the application is fatally flawed and logic errors occur to disastrous end user effects, and the type annotations: - do not enforce their promises of annotating types - fail to live up to "minimal runtime penalties" due to all the `list()` Shun this broken concept, by hardening the type annotations. As it turns out, we do not actually need any of this covariance or protocol-ism for a list of strings! The whole attempt was a slow, buggy waste of time.
2022-12-05when generating optional utility targets in ninja, skip existing aliases tooEli Schwartz1-3/+0
When auto-generating e.g. a `clang-format` target, we first check to see if the user has already defined one, and if so we don't bother creating our own. We check for two things: - if a ninja target already exists, skip - if a run_target was defined, skip The second check is *obviously* a duplicate of the first check. But the first check never actually worked, because all_outputs was only generated *after* generating all utility rules and actually writing out the build.ninja file. The check itself compares against nothing, and always evaluates to false no matter what. Fix this by reordering the target creation logic so we track outputs immediately, but only error about them later. Now, we no longer need to special-case run_target at all, so we can drop that whole logic from build.py and interpreter.py, and simplify the tracked state. Fixes defining an `alias_target()` for a utility, which tried to auto-generate another rule and errored out. Also fixes doing the same thing with a `custom_target()` although I cannot imagine why anyone would want to produce an output file named `clang-format` (unless clang itself decided to migrate to Meson, which would be cool but feels unlikely).
2022-12-05interpreter: move TEST_KW from interpreter.py to type_checking.pyDylan Baker1-21/+3
Since it's also used in the rust module, it should be in a common place. Also rename from `TEST_KWARGS` to `TEST_KWS`, which is more in line with the `*_KW` naming scheme used in the type_checking module.
2022-12-04dependencies: only print not_found_message onceMichael Champanis1-1/+0
Due to an accidentally repeated line it would print twice unless required. Fixes #8150
2022-11-29pylint: enable the bad_builtin checkerDylan Baker1-1/+1
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 Robillard1-1/+1
Found with codespell.
2022-11-16Fix deprecation message, the function name is fs.copyfile()Xavier Claessens1-1/+1
2022-11-16Change the warning generated by importing an unstable module to non-fatalTristan Partin1-1/+1
Penalizing users for helping to test unstable modules really makes no sense. As a fatal warning, users can no longer use `--fatal-meson-warnings`.
2022-10-31both_libraries: Make sure to select the right linker for static libXavier Claessens1-3/+2
Regression test: libccpp has both C and C++ sources. The executable only has C sources. It should still link using the C++ compiler. When using both_libraries the static has no sources and thus no compilers, resulting in the executable linking using the C compiler. https://github.com/Netflix/vmaf/issues/1107
2022-10-31emit a FeatureNew when using include_directories as a stringEli Schwartz1-0/+7
This was introduced in commit 3a6e2aeed9737f1082571e868ba50e72957f27c7 as part of 0.50.0, but did not contain a FeatureNew. As a result, people would use it without realizing that they broke support for versions of Meson included in their minimum requirements.
2022-10-24Add missing since annotations in docsElliott Sales de Andrade1-1/+1
This is based on searching for `@FeatureNew*` decorators. There is also one correction to a version in a decorators; `build_by_default` was added in #1303, which is 0.38.0, not 0.40.0.
2022-10-24Accept disablers in summary valuesElliott Sales de Andrade1-1/+4
They are commonly used as a replacement for a `dependency`, and not accepting them in `summary` breaks the last example in [1] when used as a value. [1] https://mesonbuild.com/Disabler.html#disabling-parts-of-the-build
2022-10-24Add missing doc for NASM languageXavier Claessens1-0/+2
2022-10-23Fix excluding sources for static lib in both_libraries()Xavier Claessens1-10/+12
When using both_libraries(), or library() with default_library=both, we remove all sources from args and kwargs when building the static library, and replace them by the objects from the shared library. But sources could also come from any InternalDependency, in which case we currently build them twice (not efficient) and link both objects into the static library. It also means that when we needlessly build those source for the static library, it miss order dependency on generated headers that we removed from args/kwargs, which can cause build errors in the case the source from static lib is compiled before the header in shared lib gets generated. This happened in GLib: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2917.
2022-09-19pylint: enable use-sequence-for-iterationDylan Baker1-1/+1
This found a couple of places where we *don't* want to use set(), and want to use list() instead.
2022-09-06Fix install_subdirs not showing up in intro-install_plan.jsonThomas Li1-0/+5
2022-09-05interpreter: name typing-only kwargs import with an underscoreEli Schwartz1-41/+41
To differentiate it from the function parameter itself. Annotating a function as ``` def func_foo(kwargs: kwargs.FooKwargs): ``` is confusing, both visually and to static linters.
2022-09-05interpreter: add a few small func annotationsEli Schwartz1-4/+4
2022-08-29flake8: fix unnecessary f-strings without any format placeholdersEli Schwartz1-1/+1
These can just be ordinary strings.
2022-08-29flake8: fix lingering whitespace errorsEli Schwartz1-2/+0
2022-08-26Fix indentation issues reported by flake8, requiring code restructuringAlf Henrik Sauge1-9/+11
Strictly speaking code restructuring isn't needed, but making this PEP8 compliant results in indentation of the code that reduces the readability. By moving the offending code on the outside of the method call, the readability is maintained.
2022-08-26Fix purely white space issues reported by flake8Alf Henrik Sauge1-1/+1
2022-08-23install modes should not apply sticky bit to filesEli Schwartz1-6/+27
This is generally a bad idea, e.g. it causes OSError on freebsd. It also gets ignored by solaris and thus causes unittest failures. The proper solution is to simply reject any attempt to set this, and log a warning. The install_emptydir function does apply the mode as well, and since it is a directory it actually does something. This is the only place where we don't reset the mode. Although install_subdir also installs directories, and in theory it could set the mode as well, that would be a new feature. Also it doesn't provide much granularity and has mixed semantics with files. Better to let people use install_emptydir + install_subdir. Fixes #5902
2022-08-22introspection: untangle install_plan implemetation, fix a bunch of wrong onesEli Schwartz1-9/+8
Generally plumb through the values of get_option() passed to install_dir, and use this to establish the install plan name. Fixes several odd cases, such as: - {datadir} being prepended to "share" or "include" - dissociating custom install directories and writing them out as {prefix}/share/foo or {prefix}/lib/python3.10/site-packages This is the second half of #9478 Fixes #10601
2022-08-22interpreter: add a special class to track the lifecycle of get_option() stringsEli Schwartz1-0/+6
2022-08-18modules/pkgconfig: Use typed_kwargsDylan Baker1-25/+0
2022-08-18modules/fs: Replace configure_file(copy:) with fs.copyfileDylan Baker1-1/+4
`configure_file` is both an extremely complicated implementation, and a strange place for copying. It's a bit of a historical artifact, since the fs module didn't yet exist. It makes more sense to move this to the fs module and deprecate this `configure_file` version. This new version works at build time rather than configure time, which has the disadvantage it can't be passed to `run_command`, but with the advantage that changes to the input don't require a full reconfigure.
2022-08-17interpreter: deprecate the ability import unstable modules as `unstable_*`Dylan Baker1-0/+3
This was never meant to work, it's an implementation detail of using `importlib.import_module` and that our modules used to be named `unstable_` that this ever worked.
2022-08-17interpreter: move handling of module stability to interpreterDylan Baker1-31/+50
Thanks to `ModuleInfo`, all modules are just named `foo.py` instead of `unstable_foo.py`, which simplifies the import method a bit. This also allows for accurate FeatureNew/FeatureDeprecated use, as we know when the module was added and if/when it was stabilized.
2022-08-17modules: use module level information about new and deprecationDylan Baker1-6/+9
Instead of using FeatureNew/FeatureDeprecated in the module. The goal here is to be able to handle information about modules in a single place, instead of having to handle it separately. Each module simply defines some metadata, and then the interpreter handles the rest.
2022-08-15make add_project_dependencies respect build version of include dirsEli Schwartz1-1/+1
Fixes #10695
2022-08-10cmake: Add rule relaxations for CMake subprojectsDaniel Mensinger1-2/+27
fixes #10566
2022-07-17interpreter: Add return type to func_dependencyDylan Baker1-1/+1
2022-07-08implement the new preserve_path kwarg for install_data tooEli Schwartz1-7/+25
Primarily interesting to me because it is then available for the python module's install_sources method. Based on the new feature in install_headers.
2022-07-08fix incorrect type annotationEli Schwartz1-1/+1
In my attempts at actually using this, I discovered that no, it actually does take None.
2022-07-06Improve error message for `include_directories(abs_path_intree)`Ralf Gommers1-2/+7
This error message was quite confusing when triggered by use of an absolute path to the include dir of an external dependency (numpy in my case). Changing that to a relative dir also isn't a solution, because Meson will *not* do the "busywork to make paths work" that the error message says it will.