aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter
AgeCommit message (Collapse)AuthorFilesLines
2022-05-03interpreter: new function add_project_dependencies()Paolo Bonzini1-0/+22
This function can be used to add fundamental dependencies such as glib to all build products in one fell swoop. This can be useful whenever, due to a project's coding conventions, it is not really possible to compile any source file without including the dependency. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-05-03dependencies: extract code to get all leaf dependenciesPaolo Bonzini1-14/+1
Extract to a separate function the code that resolves dependencies for compiler methods. We will reuse it for add_project_dependencies(). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-05-03interpreter: simplify checks in declare_dependencyPaolo Bonzini1-5/+3
Both dependencies.ExternalLibrary and dependencies.InternalDependency are subclasses of dependencies.Dependency, no need to list them separately. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-05-01use shared implementation to convert files() strings to File objectsEli Schwartz1-1/+1
This handles various edge cases: - checks for sandbox violations just like all other functions - warn for direntry issues - check for generated files referred to via strings instead of the returned object (All valid use cases for wanting to sneak around the checks, are made to work via commit bba588d8b03a9125bf5c4faaad31b70d39242b68.)
2022-05-01Merge pull request #10039 from eli-schwartz/wayland-protocols-subproject-filesJussi Pakkanen4-3/+63
dependencies: allow get_variable to expose files from subprojects
2022-04-20vcs_tag: handle non-str / non-file argumentsKirill Isakov1-5/+8
This makes vcs_tag behave like other commands so it accepts not only string and file arguments, but also exe, custom_tgt, and external_program.
2022-04-20vcs_tag: document the already supported file argKirill Isakov1-0/+2
2022-04-14typoEli Schwartz1-1/+1
2022-04-14remove useless conditionEli Schwartz1-1/+0
not is_subproject() is the same check as self.subproject == ''
2022-04-13dependencies: move DependencyVariableString handling to declare_dependencyEli Schwartz3-7/+22
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 Schwartz4-4/+49
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 Schwartz1-1/+1
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-04-07Revert "wayland: Also lookup scanner in pkgconfig"Eli Schwartz1-20/+4
This reverts commit 7954a4c9cbf8355d8c8ea9b3d98df45d9f96f66e.
2022-04-04wayland: Also lookup scanner in pkgconfigXavier Claessens1-4/+20
This moves generally useful logic from GNOME module's _get_native_binary() into find_program() implementation. We could decide later to expose it as public API.
2022-03-30Add new debug() functionMarvin Scholz1-0/+8
Adds a new debug() function that can be used in the meson.build to log messages to the meson-log.txt that will not be printed to stdout when configuring the project.
2022-03-29move a bunch of imports into TYPE_CHECKING blocksEli Schwartz2-7/+9
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-29Pass environment down to base Target classXavier Claessens1-2/+5
2022-03-24Make compilers list per subprojectXavier Claessens1-18/+19
Previously subprojects inherited languages already added by main project, or any previous subproject. This change to have a list of compilers per interpreters, which means that if a subproject does not add 'c' language it won't be able to compile .c files any more, even if main project added the 'c' language. This delays processing list of compilers until the interpreter adds the BuildTarget into its list of targets. That way the interpreter can add missing languages instead of duplicating that logic into BuildTarget for the cython case.
2022-03-22interpreter: Make compiler options per-subprojectXavier Claessens1-0/+10
2022-03-18structured_sources: fix subdir handlingDylan Baker1-1/+5
We currently don't handle subdirectories correctly in structured_sources, which is problematic. To make this easier to handle correctly, I've simply changed `structured_sources` to only use Files and not strings as an implementation detail.
2022-03-13give subproject interpreters a view of user defined optionsEli Schwartz1-1/+2
We need this for the python module, as implemented in commit e8375d20a9aeb8c3b0ad58f299ded0e5e978b447, but that then crashed in subprojects because those options were never forwarded to the subproject interpreter.
2022-03-13Merge pull request #9339 from dcbaker/submit/structured_sourcesJussi Pakkanen2-4/+68
Structured Sources
2022-03-12fix regression in vcs_tag when the VCS program is not installedEli Schwartz1-1/+3
We are supposed to fallback on the fallback when running the vcstagger, but instead we errored out during configure. Fixes regression in commit b402817fb6f0392812bfa272bdbc05c9c30139fa. Before this, we used shutil.which || relative paths, and in the latter case if it could not be found we still wrote out that path but it failed to run in vcstagger. Now, we use find_program under the hood, so it needs to be run in non-fatal mode, and if it is not found, we simply keep the original command string. It's a VCS command, so if we magically end up finding it at runtime because it was installed after running configure, that is *fine*.
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-07build: plumb structured sources into BuildTargetsDylan Baker1-3/+34
2022-03-07interpreter: add an implementation for structured_sourcesDylan Baker1-0/+26
2022-03-07interpreter: Add a holder for StructuredSourcesDylan Baker2-0/+7
And teach the interpreter how to use it
2022-03-07interpreter: teach source_strings_to_files about StructuredSourcesDylan Baker1-1/+1
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.