aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-03-01interpreter: report FeatureNew for kwargs to project()Eli Schwartz3-2/+10
We need to know the project minimum version before evaluating the rest of the function. There's three basic approaches: - try to set it inside KwargInfo - just run a minimal version of func_project for this, then load everything after - drop down to the AST and set it before anything else In order to handle FeatureNew emitted by a FunctionNode evaluated before project() due to being inlined, such as `version: run_command()`, only option 3 suffices, the rest all happen way too late. Since we have just added AST handling support for erroring out, we can do that to set the version as well.
2023-03-01handle meson_version after parsing but before invalid project() kwargsEli Schwartz4-1/+12
If we add new kwargs to a function invoked on the first line, we also need to validate the meson_version before erroring out due to unknown kwargs. Even if the AST was successfully built. Amusingly, we also get to improve the error message a bit. By passing the AST node instead of an interpreter node, we get not just line numbers, but also column offsets of the issueful meson_version. That broke the stdout of another failing test; adapt it.
2023-03-01handle meson_version even when the build file fails to parseEli Schwartz4-7/+41
If the meson.build file is sufficiently "broken", even attempting to lex and parse it will totally fail, and we error out without getting the opportunity to evalaute the project() function. This can fairly easily happen if we add new grammar to the syntax, which old versions of meson cannot understand. Setting a minimum meson_version doesn't help, because people with a too-old version of meson get parser errors instead of advice about upgrading meson. Examples of this include adding dict support to meson. There are two general approaches to solving this issue, one of which projects are empowered to do: - refactor the project to place too-new syntax in a subdir() loaded build file, so the root file can be interpreted - teach meson to catch errors in building the initial AST, and just load enough of the AST to check for meson_version advice This implements the latter, allowing to future-proof the build grammar.
2023-03-01mparser: Add partial AST to exceptionsEli Schwartz1-6/+17
Surprisingly enough we need to do this twice. In some cases (failing-meson/72 triggers this) we can error out after parsing the codeblock, but without getting the expected eof. We need to catch both exceptions as either one can interrupt the built codeblock object. Co-authored-by: Xavier Claessens <xavier.claessens@collabora.com>
2023-03-01mparser: use an inherited ParseException everywhereEli Schwartz1-3/+3
2023-03-01Revert "Exit meson with an error if an invalid escape sequence is found in a"Eli Schwartz1-13/+2
This reverts commit 348248f0a19bdc80e8a184befb2faaa1d5e66f40. The rules were relaxed in commit ccc4ce28cc9077d77a0bc9e72b1177eba1be7186 to permit this, so it's never possible to raise this exception anymore. But that commit was incomplete, and didn't remove the now-useless infrastructure for exception handling. The test needed to test this was always broken, and then removed in commit 465ef856ac9b978f13414db4aff649c66f2e6be5, and still this useless try/except persisted.
2023-03-01interpreter: Add testcase..endtestcase clause supportXavier Claessens8-1/+113
This is currently only enabled when running unit tests to facilitate writing failing unit tests. Fixes: #11394
2023-03-01docs: document default_options behaviourJohn Levon1-0/+5
As discussed in issue #8037, using `c_args` in `project()` leads to `CFLAGS` not being respected, which is a common mistake. Document this and suggest using `add_project_arguments()` instead. Signed-off-by: John Levon <levon@movementarian.org>
2023-03-01docs: fix a small typoJohn Levon1-1/+1
s/Accecpts/Accepts/ Signed-off-by: John Levon <levon@movementarian.org>
2023-03-01rust: Fix handling of proc-macros in rust-project.jsonSebastian DrΓΆge1-7/+9
The proc-macro code was not running at all because of a missing dash in the crate type, and the proc macro dylib path was not generated as a path but including the `-o ` commandline parameter prefix.
2023-03-01rust: Store absolute paths in rust-project.jsonSebastian DrΓΆge1-2/+6
As meson requires source_dir!=build_dir and stores the rust-project.json inside the build directory, while software like rust-analyzer expects it at the root of the source directory, manual steps are needed for making them work together. One option, as described in the documentation, is per project configuration. Another option, that works correctly with compile-commands.json and clangd, is to store a symlink to the file in the build directory at the root of the source directory. As currently rust-project.json stores paths relative to the location of the file itself and rust-analyzer does not resolve symlinks, this does not work. To solve this, store absolute paths in rust-project.json as is already done in compile_commands.json for the directory.
2023-03-01unittests: add test for source dir stripping from rpathsStefan Hajnoczi1-0/+42
This test checks that rpaths are stripped correctly when their prefix matches the source directory. This test fails without the previous commit: 1/4 visitation FAIL 0.01s exit status 127 >>> MALLOC_PERTURB_=150 meson/tmpy7c0joy5/patron ――――――――――――――――――――――――――――――――――――― βœ€ ――――――――――――――――――――――――――――――――――――― stderr: meson/tmpy7c0joy5/patron: error while loading shared libraries: libalexandria.so: cannot open shared object file: No such file or directory Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
2023-03-01backends: fix source dir stripping from rpathsStefan Hajnoczi1-2/+9
Commit e88887be4a08 ("Only remove substring if it is part of string") removed the source dir from the rpath when the following check succeeds: if absdir.startswith(self.environment.get_source_dir()): rel_to_src = absdir[len(self.environment.get_source_dir()) + 1:] For example, absdir '/myproject/foo' starts with source dir '/myproject', so we want to generate the relative path 'foo'. This code doesn't work with absdir '/myproject-libs/foo' though, because we'll incorrectly turn it into a relative path 'libs/foo' after stripping away '/myproject-'. Use os.path.commonpath() instead of str.startswith() so path components are correctly handled. Cc: Niklas Claesson <niklas.claesson@cosylab.com> Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
2023-02-28refactor a few subsystem-relative imports that imported the wrong locationEli Schwartz2-2/+2
Inside of mesonbuild.ast.* we can and should import from .foobar, rather than importing from .__init__'s re-exported version of that object. Failing to do so results in an extremely brittle codebase where simply changing the order of lines in __init__.py can result in ImportError.
2023-02-28doc: Be more specific about warning_level optionXavier Claessens1-0/+17
Fixes: #11469
2023-02-28Add detection code for powerpc64le.Jussi Pakkanen1-1/+3
Originally from: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1019413
2023-02-28Add a deb_ prefix to constants that are only used in Debian system detection.Jussi Pakkanen1-6/+6
2023-02-28Handle a cross compilation setup that only has a C compiler.Jussi Pakkanen1-1/+4
2023-02-28Add Debian platform autodetect to env2mfile.Jussi Pakkanen1-1/+1
2023-02-28msetup: clarify error message when wrong directories are specifiedEli Schwartz1-10/+13
This can happen from typos, which then confusingly claim that neither build directory has a meson.build file because the implicit . directory was not actually one of the directories. Instead a random command line argument was interpreted as a directory name. Fixes #11472
2023-02-27Use caching in Compiler.sizeof() and Compiler.alignment()Andres Freund4-30/+36
2023-02-27Add Compiler.cached_run()Andres Freund2-2/+33
Caching Compiler.run() seems likely to cause problems, but some users, like .sizeof(), we know enough about the program run to make it safe. This commit just adds the Compiler.cached_run(), a subsequent commit makes use of it.
2023-02-27interpreter: bolden result of compiler.alignment(), compiler.sizeof()Andres Freund1-2/+2
This is more in line with other tests. It also looks better when introducing caching, as a subsequent commit will.
2023-02-27Improve unity build documentationCharles Brunet1-1/+15
2023-02-27docs: add Criterionandy59951-0/+1
2023-02-27prevent unhandled exception for operations on NoneCharles Brunet1-9/+47
For instance, when writing `-subdir('a')` or `not subdir('a')`. Fixes #11225.
2023-02-27documentation: there is no unary + operatorCharles Brunet1-1/+1
2023-02-27python dependency: Fix typo in placeholder stringDaniele Nicolodi1-1/+1
2023-02-27minstall: Replace non-breakable space with plain space in commentDaniele Nicolodi1-1/+1
2023-02-27mintro: Add exclude_{files, dirs} to install_subdir install_planDaniele Nicolodi6-3/+30
These are necessary for projects outside Meson itself that want to extend the 'meson install' functionality as meson-python does to assemble Python package wheels from Meson projects. Fixes #11426.
2023-02-25Misleading comment mtribiere1-1/+1
Code moved to detect.py in recent version
2023-02-24docs: fix bad advice to use python module to find pythonEli Schwartz1-2/+2
2023-02-24test cases: use best practices method to find the python3 programEli Schwartz13-15/+18
We do not need the python module's find_installation() for this, as this does various things to set up building and installing python modules (pure python and C-API). This functionality is already tested in the python tests. Elsewhere, when we just need an interpreter capable of running python scripts in order to guarantee a useful scripting language for custom commands, it suffices to use find_program(), which does not run an introspection script or do module imports, and is thus faster and a bit cleaner. Either way, both methods are guaranteed to find the python3 interpreter, deferring to mesonlib.python_command for that guarantee. test "71 summary" can sometimes return the python command with the ".exe" part all uppercased for mysterious Windows reasons. Smooth this over with ExternalProgram.
2023-02-24work around circular imports in python probe scriptEli Schwartz1-3/+7
It seems this happens because at some point setuptools imports gettext, and we have a script by the same name. In general, this path injection by default is bad news for our use case. Python 3.11 introduced -P for this reason, but we cannot depend on that. Instead, check for it first, and delete it, before doing more imports.
2023-02-24mcompile: Do not exclude targets from subprojectsXavier Claessens1-5/+3
When giving full path to a target there is no reason to skip targets from subprojects, the path can start with `subprojects/`.
2023-02-23docs: add gcc to list of compilers with sanitize toolsandy59951-1/+1
2023-02-23Update Vs-External.mdValeri1-1/+1
Fix minor typo
2023-02-23clangformat: don't noisily print status messages for every checked fileEli Schwartz1-4/+8
The version lookup should be silent. While we're at it, the version lookup should not be happening more than once, which printing multiple messages indicated we were doing. Pass the version into the per-file function rather than looking it up fresh each time. Fixes https://github.com/mesonbuild/meson/pull/11054#issuecomment-1430169280
2023-02-22Implement rustc controlled whole-archive linkingDylan Baker14-14/+113
Rustc as of version 1.61.0 has support for controlling when whole-archive linking takes place, previous to this it tried to make a good guess about what you wanted, which worked most of the time. This is now implemented. Additionally, rustc makes some assumptions about library names (specifically static names), that meson does not keep. This can be fixed with rustc 1.67, where a new +verbatim modifier has been added. We can then force rustc to use the name we give it. Before that, we can sneak through `/WHOELARCHIVE:` in cases of dynamic linking (into a dll or exe), but we can't force the archiver to do what we want (rustc considers the archiver to be an implementation detail). The only solution I can come up with is to copy the library to the format that rustc expects. I've run into some issues with that as well, so we warn in that case. The decisions to leave static into static broken on MSVC for 1.61–1.66 was made because: 1) The work around is non-trivial, and we would have to support that workaround for a long time 2) The number of users of Rust in Meson is small 3) The number of users of Rust in Meson on Windows, with MSVC is tiny 4) Using rustup to update rustc on windows is trivial, and solves the problem completely Fixes: #10723 Fixes: #11247 Co-authored-by: Nirbheek Chauhan <nirbheek@centricular.com>
2023-02-22python dependency: handle broken pylong on many more versions of pythonEli Schwartz1-1/+2
This workaround was never exclusive to python2, and in fact only just got fixed in the upcoming python 3.12 release. Extend the version comparison to cover all those other cases.
2023-02-22python dependency: fix embed handling for system dependencyEli Schwartz1-16/+20
Only search for and provide linkage to libpython, if the dependency expects to be linked to it. Fixes overlinking on Linux / macOS when pkg-config isn't installed and the sysconfig lookup is used instead. This was correctly handled for pkg-config rather than deferring it until use, since commit bf832743441a1171518d7a436164c989be679410 -- but that handling neglected to cover sysconfig dependencies. And sysconfig would always try to link to libpython, it just respected the dependency configuration barely enough to allow falling back to "don't link" if both link_libpython=False and the library wasn't found.
2023-02-22python dependency: verify that the python header is installed for sysconfigEli Schwartz1-0/+3
We may or may not care that the library can be found. If link_libpython is false, we allow it to be missing and still find the dependency.
2023-02-22python dependency: simplify compile args handlingEli Schwartz1-19/+13
We can set it once instead of tangling it inside the guts of the overly specialized library lookups. It is mostly identical anyway.
2023-02-22merge the python dependency from the python module into dependenciesEli Schwartz3-257/+147
We have two copies of this code, and the python module one is vastly superior, not just because it allows choosing which python executable to base itself on. Unify this. Fixes various issues including non-Windows support for sysconfig, and pypy edge cases.
2023-02-22partial migration of the python module dependency into dependenciesEli Schwartz2-60/+62
In preparation for wholly merging the dependency handling from the python module into dependencies.*, move the unique class definitions from there into their new home in dependencies.python, which is semantically convenient.
2023-02-22python module/dependency: move the specialized external programEli Schwartz2-79/+90
In preparation for handling more work inside dependencies.*, we need to be able to run a PythonExternalProgram from the python dependency. Move most of the definition -- but only the parts that have no interest in a ModuleState -- and subclass a bit of sanity checking that we need to handle specially when used in the module.
2023-02-22remove pointless, unused typing-only import in the test runnerEli Schwartz1-1/+0
In the commit that originally added this import, it wasn't even used. Now the implementation is being moved, so it will fail to work. I do not know why I originally added it, but it needs to go. :)
2023-02-22python module: inline the dependency methods checkingEli Schwartz1-3/+3
It can go directly inside the function which immediately uses it. There's no purpose in looking it up exactly once and using it exactly once, but looking it up outside the function and complicating the function signature in order to pass it as a function argument.
2023-02-22dependencies: refactor python3 into its own fileEli Schwartz3-118/+146
2023-02-22python module: move the introspection script into an external scriptEli Schwartz2-79/+81
We write this out as an embedded string to a tempfile in order to run it, which is pretty awkward. And usually Meson's files are already files on disk, not packed into a zip, so we can simply run it directly. Since python 3.7, which is our new minimum, we can handle this well via the stdlib. (There's also mesonbuild.mesondata, but we do not need persistence in the builddir.) This also solves the problem that has always been there, of giant python programs inside strings occasionally confusing syntax highlighters. Or even, it would be nice if we had syntax highlighting for this introspection program. :D