aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter
AgeCommit message (Collapse)AuthorFilesLines
2022-03-08add early sanity check for test programs existingEli Schwartz1-1/+4
It used to be possible to do this: ``` bomb = find_program('nonexisting', required: false) test('traceback during meson test', bomb) ``` and it would in fact bomb out, with: ``` [0/1] Running all tests. Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/mesonbuild/mesonmain.py", line 149, in run return options.run_func(options) File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 2017, in run return th.doit() File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1685, in doit runners.extend(self.get_test_runner(test) for test in tests) File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1685, in <genexpr> runners.extend(self.get_test_runner(test) for test in tests) File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1586, in get_test_runner return SingleTestRunner(test, env, name, options) File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1308, in __init__ self.cmd = self._get_cmd() File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1374, in _get_cmd test_cmd = self._get_test_cmd() File "/usr/lib/python3.10/site-packages/mesonbuild/mtest.py", line 1352, in _get_test_cmd if self.options.no_rebuild and not os.path.isfile(testentry): File "/usr/lib/python3.10/genericpath.py", line 30, in isfile st = os.stat(path) TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType ERROR: Unhandled python exception This is a Meson bug and should be reported! ``` This is something we explicitly check for elsewhere, for example when using a not-found program as a command in a custom target or generator. Check for it when making a test too, and error out with a similar error. Fixes #10091
2022-03-07move a bunch of imports into TYPE_CHECKING blocksEli Schwartz6-11/+13
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-07treewide: string-quote the first argument to T.castEli Schwartz2-2/+2
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-07remove unused code after subproject conversion to typed_kwargsEli Schwartz1-2/+0
This should have been removed in commit 4a2058cb836242a6423870e671b6b76fa48167f3 but was forgotten.
2022-03-07Fix mypy CI.Jussi Pakkanen1-1/+1
2022-03-07Merge pull request #10043 from dcbaker/submit/type-checking-for-subprojectJussi Pakkanen4-87/+140
Add typing for subproject()
2022-03-06find_program: add a version() method to match the one for dependenciesEli Schwartz1-0/+12
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: annotate the find_program chainDylan Baker1-11/+20
2022-03-03interpreter: fix some low hanging type annotations issuesDylan Baker1-21/+22
2022-03-03interpreter: fix mismatched type expectationsDylan Baker2-3/+3
2022-03-03interpreter: Fix type violation in do_subproject_cmakeDylan Baker1-1/+1
2022-03-03interpreter: replace build_def_files with OrderedSetDylan Baker1-7/+7
We do a bunch of backbending to make sure we don't have duplicates, let's just use the right datastructure to begin with.
2022-03-03interpreter: fix Interpreter type annotationsDylan Baker1-1/+1
default_options should be `T.Dict[OptionKey, str]`, not `T.Dict[str, str]`.
2022-03-03interpreter: add cm_interpreter to SubprojectHolderDylan Baker1-1/+4
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-03interpreter: use typed_kwargs for subproject()Dylan Baker3-20/+55
2022-03-03interpreter: add some simple annotations to subproject methodsDylan Baker1-2/+3
2022-03-03interpreter: Use a literal for the do_subproject helperDylan Baker1-1/+3
Since we only have two valid options and we don't want to allow any others.
2022-03-03interpreter: annotate subproject_stackDylan Baker1-1/+1
2022-03-03interpreter/dependencyfallbacks: fix a number of low hanging type issuesDylan Baker1-8/+10
2022-03-03modules/cmake: add type annotations for subproject methodDylan Baker1-15/+15
This will be used to handle the interpreter subproject as well
2022-03-03add D features to InternalDependencyRemi Thebault1-4/+7
2022-03-02document and raise an error for disallowed combination of install_headers argsEli Schwartz1-2/+5
It makes no sense to specify both: - install_dir, which overrides the -Dincludedir= builtin option - subdir, which suffixes the -Dincludedir= builtin option We've always silently ignored the subdir in this case, which is really surprising if someone actually passed it and expected it to do something. We also confusingly didn't say anything in the documentation about it. Document that the options are incompatible, and explicitly check to see if they are both passed -- if so, raise an error message pointing out that only install_dir should be used. Fixes #10046
2022-03-01interpreter: delete now unnecessary codeDylan Baker1-5/+0
Only func_configure_file could reach this code, but now it cannot due to the use of typed_kwargs, so delete it.
2022-03-01interpreter: use typed_kwargs for configure_fileDylan Baker2-79/+82
2022-03-01interpreter: use a shared KwargInfo for install_tagDylan Baker2-3/+6
The kind that takes a single argument, not the custom_target version that takes an array
2022-03-01interpreter: fix notfound_program methodDylan Baker1-2/+4
Which should take a File or str, but only handles str correctly. Which mypy would have caught for us, if we just had annotations here.
2022-03-01allow dependency checks to bubble up feature warnings to the interpreterEli Schwartz1-0/+5
It would be too difficult and probably a layering violation to give an interpreter handle to the inner guts of every dependency. What we can do instead is let every dependency track: - the Feature checks it can produce, - the version attribute for when it was implemented while leaving the interpreter in charge of actually emitting them.
2022-03-01clean up FeatureCheck signature to move location to use timeEli Schwartz1-2/+2
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 Claessens4-24/+54
2022-02-28Add missing install_tag kwarg to install_emptydir()Christian Wendt1-2/+3
2022-02-16flake8: fix various whitespace errors with badly aligned codeEli Schwartz1-2/+2
2022-02-16flake8: do not use bare exceptionsEli Schwartz1-1/+1
In one case, we actually specifically want to catch IndexError only. In the other case, excepting Exception rather than BaseException is quite fine.
2022-02-16flake8: remove some redundant separatorsEli Schwartz1-1/+1
2022-02-16flake8: fix wrong numbers of blank line separatorsEli Schwartz1-1/+0
2022-02-16flake8: fix typoed whitespace surrounding tokensEli Schwartz1-2/+2
2022-02-14FeatureNew: add mypy type annotations for subproject argEli Schwartz2-2/+6
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-12formatting improvement for include_directories sandbox violation warningEli Schwartz1-2/+2
Print the location the warning was encountered, and quote the string that triggered it. This makes it easier to read what actually happened.
2022-02-12validate the literal directory "subprojects" when checking sandbox violationsEli Schwartz1-1/+2
We do not want anyone touching this entire directory tree, but due to the way it was implemented, we only checked if its direct parent was a subproject violation. This generally worked, unless people tried to add `subprojects/` as an include directory. Patch this hole. It now provides the same warning any sandbox violation does (but is not currently an error, just a "will become an error in the future").
2022-02-09add some forgotten FeatureNew annotationsEli Schwartz1-0/+3
Forgotten in #8512.
2022-02-09fix UI regression in compiler.compiles loggingEli Schwartz1-1/+1
In commit b30dddd4e5b4ae6e5e1e812085a00a47e3edfcf1, various refactorings were done, during which a kwarg got accidentally dropped from the function that determined part of the log message. As a result, a ':' suddenly appeared in the log message where none should be. Example expected output: Checking if "-Werror=shadow with local shadowing" compiles: YES What actually happened: Checking if "-Werror=shadow with local shadowing" : compiles: YES Fixes #9974
2022-02-07mdist: fix dist scripts in subprojects being marked as superproject scriptsEli Schwartz1-7/+7
This has never worked for built/found programs, only for script files. In commit 2fabd4c7dc22373e99fc63823d80083ad30704b8 scripts learned an attribute stating which subproject they came from. In commit 3990754bf55727ef5593769b48f0a03c6b7a3671 dist scripts learned to run even from a subproject, and relied on that attribute to know when, in fact, they came from a subproject. Unfortunately the original attribute was only set in one half of an if/else, and the other half returned early with only part of the work done. Fixes #9964
2022-02-06add FeatureNew check for compiler.* methods with dependency on internal depEli Schwartz1-2/+3
In commit 0deab2ee9efc2ffe9e43f2787611e34656e6a304 we added the ability to pass a declare_dependency() to any compiler method that accepts "dependencies", but we never marked the version it is available since. Fixes #9957
2022-02-05Guard against empty string in subdir().Jussi Pakkanen1-0/+2
2022-02-01interpreter: support for forcibly verbose logging of some testsPaolo Bonzini2-2/+5
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-28build: replace kwargs in CustomTarget initializerDylan Baker3-36/+98
Because we don't want to pass the Interpreter kwargs into the build layer. This turned out to be a mega commit, as there's really on elegant way to make this change in an incremental way. On the nice side, mypy made this change super easy, as nearly all of the calls to `CustomTarget` are fully type checked! It also turns out that we're not handling install_tags in custom_target correctly, since we're not converting the boolean values into Optional values!
2022-01-28interpreter: use find_program_impl instead of shutil.which for vcs_tagDylan Baker1-2/+1
This is the right thing to do, using which is wrong.
2022-01-28interpreter: remove dead code from custom_targetDylan Baker1-2/+0
This has been completely replaced by typed_kwargs now
2022-01-28interpreter: use typed_kwargs for vcs_tagDylan Baker2-24/+45
2022-01-27add location data to various Feature checksEli Schwartz3-20/+21
2022-01-27pkgconfig module: fix incorrect Feature logging for uninstalled_variablesEli Schwartz1-2/+2
The utility function that processes this for both 'variables' and 'uninstalled_variables' accepts a kwarg for the name of the argument, but then hardcodes 'variables' in the warning message. This is misleading.