aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter
AgeCommit message (Collapse)AuthorFilesLines
2022-06-21fix type checking for declare_dependency to allow linking to executableEli Schwartz1-3/+3
We have to handle this, because Windows needs to link to the implib of the executable (???) in order to create a shared module. This is explicitly checked for and handled in the backend, and creating a build target with `link_with: some_exe` still works, even. But updating declare_dependency to typed_kwargs neglected to take that into account, so creating a convenience interface for those same arguments failed.
2022-06-17migrate declare_dependency to typed_kwargsEli Schwartz2-32/+94
2022-06-17refactor logic for parsing dependency variables into type_checking moduleEli Schwartz2-12/+41
We will momentarily use this to implement typed_kwargs, but not for all usage sites.
2022-06-17fix confusing incorrect default name for a KwargInfoEli Schwartz1-1/+1
We can use this lots of places, and it's always the same kwarg. There doesn't seem to be a point in naming it badly, then evolving it to the standard name in the one place it is currently used. This made it not shareable.
2022-06-17interpreter: fix a subproject check with symlinksHemmo Nieminen1-1/+1
The check for whether or not a file is allowed to be accessed from a subproject fails if the subproject is accessed via a symlink. Use the absolute path of the subproject without resolving symlinks to fix the check. Extend unit test 106 to check for this in the future.
2022-06-17fix parameter expansion in several error messagesMichael Mera1-1/+1
At several points in the code base, f-strings are not correctly expanded due to missing 'f' string prefix. This fixes all the occurrences I could find.
2022-06-14Fix crash when a reconfigure adds a new subprojectXavier Claessens1-2/+1
When a subproject is disabled on the initial configuration we should not add it into self.coredata.initialized_subprojects because that will prevent calling self.coredata.init_builtins() on a reconfigure if the subproject gets enabled. Fixes: #10225.
2022-06-13flake8: fix various whitespace nitsEli Schwartz1-1/+1
2022-06-10add Feature checks for install_subdir creating an empty directoryEli Schwartz1-0/+7
Most importantly, tell people it's broken and to stop using it for 0.62.0
2022-06-08interpreter/kwargs: fix typoDylan Baker1-1/+1
2022-06-01interpreter: add missing type annotationDylan Baker1-1/+1
2022-06-01interpreter: add location to a FeatureNew callDylan Baker1-2/+3
2022-06-01interpreter: use a shared KwargInfo for install_dirDylan Baker2-4/+7
CustomTarget allows multiple install dirs, while basically everything else allows only one. So this provides a shared instance for that.
2022-06-01Fix sandbox violation when using subproject as a symlinkVili Väinölä1-1/+1
Fix "Tried to grab file outside current (sub)project" error when subproject exists within a source tree but it is used through a symlink. Using subprojects as symlinks is very useful feature when migrating an existing codebase to meson that all sources do not need to be immediately moved to subprojects folder.
2022-05-31rename a badly named KwargInfoEli Schwartz2-4/+4
CT_OUTPUT_KW is the same OUTPUT_KW we use in lots of places. The most distinctive thing about it is not that it's part of custom_target (basically any other function that uses such a kwarg follows the same rules due to using CustomTarget under the hood), but the fact that it takes multiple outputs.
2022-05-31fix regression that broke type checking of CustomTarget outputsEli Schwartz2-3/+9
We validate a few things here, such as the non-presence of '@INPUT' in an output name. These got moved out of the CustomTarget constructor in commit 11f96380351a88059ec55f1070fdebc1b1033117 and into KwargInfo, but only for kwargs that took multiple values. This caused configure_file() and unstable_rust.bindgen() to stop checking for this. Add a shared single-output KW and use it in both places. This now dispatches to _output_validator. configure_file now validates subdirectories in output names the same way we do elsewhere, directly in the typed_kwargs and by specifying the erroring kwarg.
2022-05-31make sure no custom_target outputs are named "all" or "meson-internal__*"Eli Schwartz1-9/+15
Or any other reserved names. We check in add_target that the primary name of any build target isn't on the forbidden list, but custom_target allows names that are distinct from the output filenames, so we need to check those too. We would eventually still error out all the way at the end, with: ``` ERROR: Multiple producers for Ninja target "all". Please rename your targets. ``` But, if we can check that early and provide the underlying reason (reserved name) alongside actually useful debugging info (a line number), then why not? Refactor the check into a small helper function in the process.
2022-05-31relax target name restrictions to cater to internal useEli Schwartz1-2/+5
We don't want to allow targets that conflict with: - our aliased meson-* targets for phony commands - any meson-*/ directories we create for internal purposes We do want to allow targets such as: - our own meson-*.X manpages There are a couple routes we could take. Using a better restriction, such as `meson-internal__*`, is trivially done for our aliased targets, but changing directory names is... awkward. We probably cannot do this, and doing the former but not the latter is not very useful. We could also carefully allow patterns we know we won't use, such as file extensions, but which the manpages need, which works for our directories and for many aliased targets, but run_target() is user-specified and can be anything. Use a hybrid approach to cover both use cases. We will now allow target names that fulfill *all* the following criteria: - it begins with "meson-" - it doesn't continue with "internal__" - it has a file extension
2022-05-30Implement `preserve_path` for install_headersFlorian "sp1rit"​1-4/+18
The `install_headers` function now has an optional argument `preserve_path` that allows installing multi-directory headerfile structures that live alongside sourcecode with a single command. For example, the headerfile structure headers = [ 'one.h', 'two.h', 'alpha/one.h', 'alpha/two.h', 'alpha/three.h' 'beta/one.h' ] can now be passed to `install_headers(headers, subdir: 'mylib', preserve_path: true)` and the resulting directory tree will look like {prefix} └── include    └── mylib       ├── alpha       │   ├── one.h       │   ├── two.h       │   └── three.h       ├── beta       │   └── one.h       ├── one.h       └── two.h Fixes #3371
2022-05-30fix invalid type for default_optionsEli Schwartz1-1/+1
We have two checks for the type accepted here. One is the basic typed_kwargs type-checking, which declares it accepts: str | include_directories The other is the custom validator which further narrows it to strings with certain option-like properties (needs to be an = assignment). The former is obviously wrong, which doesn't really matter all that much but still isn't very nice... Introduced in commit f34013fb08b8d24d570c96084c5d58c5eaf4f5da.
2022-05-30fix incorrectly allowed kwarg for custom_targetEli Schwartz2-5/+2
override_options makes no sense for custom_target as we don't use it for anything. Also, this was added in commit c3c30d4b060239654c9b848092692ab346ebed9d despite not being allowed in permittedKwargsc3c30d4b0. For inexplicable reasons, we had a known_kwargs for custom_target that looped over kwargs and issued a warning, not an error, for unknown kwargs. It was impossible to ever hit that check to begin with, though, ever since commit e08d73510552fa4a3a087af1a9e5fded8f5749fd which added permittedKwargs and obsoleted those manual checks with real errors. So at one point override_options was specially permitted to be used without emitting a warning, and then for about half a decade it was an error, and then based on some dead code it was allowed again for a bit. But through all this it doesn't do anything and isn't documented.
2022-05-26fix custom_target crash if boolean true is specified in install_dirEli Schwartz2-2/+3
We accept boolean false to indicate "do not install this one particular output", but the type checking simply checked if it is a bool. We do this correctly for configure_file, so copy the same validator from there.
2022-05-25Make a copy of auto_features options when changing its nameXavier Claessens1-1/+2
This fixes bogus messages "skipped: feature foo disabled" when auto_features=disabled. It was reporting the name of the latest get_option() call instead of the name of the current feature option. This is especially visible in GStreamer summary where it should show a different option name for every subproject but instead shows "tools" everywhere: ``` Subprojects gst-devtools : NO Feature 'tools' disabled gst-editing-services : NO Feature 'tools' disabled ... ```
2022-05-25interpreter: add type restrictions to declare_dependency link_wholeDylan Baker1-2/+11
Including that we don't accept SharedLibraries or CustomTarget[Index]s that are a shared library
2022-05-25interpreter: add annotations to extract_variablesDylan Baker1-2/+4
2022-05-24ast: cmake: Generate line numbers while printing the AST for better debuggingDaniel Mensinger1-1/+1
2022-05-24Tweak "header has symbol" messagePeter Eisentraut1-2/+2
Change message Header <foo.h> has symbol "BAR" to Header "foo.h" has symbol "BAR" with the first part also now in bold. This is more consistent with other messages like Has header "foo.h" and Checking whether type "foo" has member "bar"
2022-05-24fix traceback when run_command has a find_program as the inline argEli Schwartz1-1/+6
We were poking directly at the node, so if it was a FunctionNode then this broke. Instead, just do a reverse lookup in the overrides table to get the original find_program name.
2022-05-23interpreter: Add another overload to source_strings_to_filesDylan Baker1-0/+3
Which doesn't have `StructuredSources`, as is actually quite common.
2022-05-23move various imports into TYPE_CHECKING blocks for neatnessEli Schwartz1-3/+2
2022-05-23fix typing regressionEli Schwartz1-1/+1
In commit f2d21bf8a98fe4eb528a077f3faf5d68cd35c244 a type annotation was added that does not exist. The referenced type is present but only as a dotted name.
2022-05-17fix incorrect FeatureNew for separator kwarg in environment object methodsEli Schwartz1-1/+1
In commit 6acfe48f32110671a0adf80ad3497a35105b265d, the kwarg was added to environment() in addition to the env object methods. As part of the associated refactor, a shared KwargInfo was used, and evolved to be new since 0.62.0 in the two cases where it is in fact new. However, it *also* set the base KwargInfo for the exact same newness, which is wrong as it was present ever since the initial introduction in 0.34.0 As usual for anything that predates 0.37.0 we simply don't tag FeatureNew. Revert this back to the same KwargInfo definition from before the refactoring commit. Fixes #10402
2022-05-03add prefer_static built-in optionDudemanguy1-0/+4
By default, meson will try to look for shared libraries first before static ones. In the meson.build itself, one can use the static keyword to control if a static library will be tried first but there's no simple way for an end user performing a build to switch back and forth at will. Let's cover this usecase by adding an option that allows a user to specify if they want dependency lookups to try static or shared libraries first. The writer of the meson.build can manually specify the static keyword where appropriate which will override the value of this option.
2022-05-03dependencies: handle one more case of subproject installed filesEli Schwartz1-1/+1
Some projects treat meson.project_source_root() as the root of the dependency files, because the project itself merely wraps a bunch of datafiles. Our validation to make sure this doesn't point to another subproject, made use of pathlib.Path's generator for all component paths, which... did not include the path itself. So go ahead and explicitly check that too. Add a test case to verify it while we are at it. Fixes https://github.com/mesonbuild/meson/pull/10103#issuecomment-1114901033
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.