aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter
AgeCommit message (Collapse)AuthorFilesLines
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-23pkgconfig: Variables can be a single stringXavier Claessens1-3/+9
It used to be listified and libxml2 wrap relies on that.
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 Schwartz3-2/+34
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 Schwartz2-7/+27
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.
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>