aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter
AgeCommit message (Collapse)AuthorFilesLines
2023-02-15interpreter: add FeatureOption.enable_if and .disable_ifDylan Baker1-5/+39
This adds two new methods, that are conceptually related in the same way that `enable_auto_if` and `disable_auto_if` are. They are different however, in that they will always replace an `auto` value with an `enabled` or `disabled` value, or error if the feature is in the opposite state (calling `feature(disabled).enable_if(true)`, for example). This matters when the feature will be passed to dependency(required : …)`, which has different behavior when passed an enabled feature than an auto one. The `disable_if` method will be controversial, I'm sure, since it can be expressed via `feature.require()` (`feature.require(not condition) == feature.disable_if(condition)`). I have two defences of this: 1) `feature.require` is difficult to reason about, I would expect require to be equivalent to `feature.enable_if(condition)`, not to `feature.disable_if(not condition)`. 2) mixing `enable_if` and `disable_if` in the same call chain is much clearer than mixing `require` and `enable_if`: ```meson get_option('feat') \ .enable_if(foo) \ .disable_if(bar) \ .enable_if(opt) ``` vs ```meson get_option('feat') \ .enable_if(foo) \ .require(not bar) \ .enable_if(opt) ``` In the first chain it's immediately obvious what is happening, in the second, not so much, especially if you're not familiar with what `require` means.
2023-02-15interpreter: add a feature.enable_auto_ifDylan Baker1-1/+12
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-02-15preprocess: Add dependencies kwargXavier Claessens1-0/+3
2023-02-15preprocess: Allow custom_tgt, custom_idx and generated_listXavier Claessens1-3/+12
It was documented to be supported but only File and str were actually working.
2023-02-14allow install script to run in dry-run modeCharles Brunet1-0/+3
2023-02-13Fix displaying outputs with add_*_scriptCharles Brunet1-1/+1
#8259 induced a regression, causing Meson 0.57.0 and upward to stop printing outputs of scripts added using `meson.add_*_script()`. This makes _find_source_scripts() mark executables as verbose in meson_exe.
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-02-01micro-optimize: define typing-only objects in TYPE_CHECKINGEli Schwartz1-5/+6
Union types that exist solely for use as annotations don't need to be created in normal runs.
2023-02-01treewide: add future annotations importEli Schwartz3-0/+3
2023-01-31log running commands a bit better by doing proper shell quotingEli Schwartz1-3/+3
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 Schwartz2-3/+24
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-06interpreter: compiler: Allow array for the prefix kwargMarvin Scholz1-1/+7
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-05type_checking: add a type checking helper for strings in include_directoriesDylan Baker1-0/+9
2022-12-05interpreter: move TEST_KW from interpreter.py to type_checking.pyDylan Baker2-21/+22
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 Baker2-2/+2
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 Robillard3-3/+3
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-11-08Fix since annotation for str "in" operatorXavier Claessens1-2/+2
2022-11-06Implement `in` operator on stringXavier Claessens1-0/+12
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-23Merge pull request #10916 from xclaesse/preprocessJussi Pakkanen1-0/+38
Add cc.preprocess() method
2022-10-23Add cc.preprocess() method for c-like compilersXavier Claessens1-0/+38
This introduce a new type of BuildTarget: CompileTarget. From ninja backend POV it is the same thing as any other build target, except that it skips the final link step. It could be used in the future for transpilers too.
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-10-12interpreter: Fix msg when none of the dependencies have namesNirbheek Chauhan1-5/+3
This case is identical to the case when there's no dependencies specified, so it should behave the same way.
2022-10-12interpreter: Don't say we're using -lfoo args when we're notNirbheek Chauhan1-9/+11
cc.compiles(), and other compiler checks that use cc.compiles() under the hood, do not use link args at all when doing the compile check, so messages like this: ``` Checking if "have zlib" with dependency -lz compiles: YES ``` is very misleading. The compiler check command-line for that is: ``` cc [...]/testfile.c -o [...]/output.obj -c -D_FILE_OFFSET_BITS=64 -O0 ``` Note the lack of linker args.
2022-10-09Get fallback varname from wrap file after it has been configuredXavier Claessens1-8/+8
When _subproject_impl() is called the wrap file could not have been downloaded form wrapdb yet, it is done when fetching the subproject. Delay getting the variable name to when we actually need it, at that point we are sure the wrap file has been downloaded.
2022-09-28Move classes used by scripts to their own moduleXavier Claessens1-2/+4
Those classes are used by wrapper scripts and we should not have to import the rest of mesonlib, build.py, and all their dependencies for that. This renames mesonlib/ directory to utils/ and add a mesonlib.py module that imports everything from utils/ to not have to change `import mesonlib` everywhere. It allows to import utils.core without importing the rest of mesonlib.
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-19declare_dependency: fix regression in printing the correct errorEli Schwartz1-1/+1
In commit 47426f3663f795ae9af59075297bf8215ae81f40 we migrated to typed_kwargs, but the validator accepted a list and checked to see if it was a single Dependency object. Fixes #10813
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 warnings for unused importsEli Schwartz1-0/+2
This is supposed to expose all primitives together, but to do that we need to actually "use" each variable in `__all__`, which we... didn't. Sorry about that.
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 Sauge2-2/+2