aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
AgeCommit message (Collapse)AuthorFilesLines
2023-08-17fix style errors in fs.relative_to implementationEli Schwartz1-8/+2
In commit f52bcaa27fc125ab9ae583af466ba99c164169f3 a few issues were added: - doc typo - imports for utils.universal are not intended to be directly used, it's an internal wrapper that exists solely to make mesonlib work well as it always did while simultaneously allowing `meson --internal` codepaths to avoid importing anything other than an extremely stripped down core - type annotation specific import was imported at runtime scope
2023-08-17Remove XML filter from testlog.{json,txt} and std streamsTristan Partin1-6/+6
This was an unintended consequence of the original patch in #11977. Co-authored-by: Benoit Pierre <benoit.pierre@gmail.com>
2023-08-17Add fs.relative_to()Tristan Partin1-1/+22
Returns a relative path from arg 2 to arg 1 similar to os.path.relpath().
2023-08-16fs.read(): Catch FileNotFoundErrorXavier Claessens1-1/+3
2023-08-14Python: Add 'limited_api' kwarg to extension_moduleAndrew McNulty4-12/+100
This commit adds a new keyword arg to extension_module() that enables a user to target the Python Limited API, declaring the version of the limited API that they wish to target. Two new unittests have been added to test this functionality.
2023-08-14interpreter: use typed_kwargs for shared_library(darwin_versions)Dylan Baker3-43/+49
2023-08-14interpreter: use typed_kwargs for shared_library(soversion)Dylan Baker3-9/+5
2023-08-14interpreter: use typed_kwargs for shared_library(version)Dylan Baker3-10/+19
2023-08-11treewide: automatic rewriting of all comment-style type annotationsEli Schwartz38-214/+214
Performed using https://github.com/ilevkivskyi/com2ann This has no actual effect on the codebase as type checkers (still) support both and negligible effect on runtime performance since __future__ annotations ameliorates that. Technically, the bytecode would be bigger for non function-local annotations, of which we have many either way. So if it doesn't really matter, why do a large-scale refactor? Simple: because people keep wanting to, but it's getting nickle-and-dimed. If we're going to do this we might as well do it consistently in one shot, using tooling that guarantees repeatability and correctness. Repeat with: ``` com2ann mesonbuild/ ```
2023-08-11rewrite a couple comment-style type annotations for oddly indented dictsEli Schwartz2-14/+20
Make them into real type annotations. These are the only ones that if automatically rewritten, would cause flake8 to error out with the message: "E128 continuation line under-indented for visual indent".
2023-08-11remove useless type annotationsEli Schwartz15-43/+43
These annotations all had a default initializer of the correct type, or a parent class annotation.
2023-08-10hotdoc module: add a bunch more type annotationsEli Schwartz1-51/+74
2023-08-10hotdoc module: avoid monkeypatch crime by properly subclassing ExternalProgramEli Schwartz1-7/+8
2023-08-10python module: add a few more type annotationsEli Schwartz1-5/+8
2023-08-10allow some ObjectHolder subclasses to continue to be genericEli Schwartz3-11/+21
ExternalProgram and CustomTarget have some use cases for producing subclassed interpreter holders with more specific types and methods. In order for those subclasses to properly refer to their held_object, we need a shared base class that is still generic, though bound. For the derived held objects, inherit from the base class and specify the final types as the module-specific type.
2023-08-10Popen_safe_logged: Also log exceptionsXavier Claessens1-1/+7
Popen can raise OSError when program is not found, or PermissionError if not executable, etc.
2023-08-09Optimize CLikeCompiler._get_file_from_list()Charles Brunet1-13/+11
Simplify and optimize the function. When not on Mac OS, it was iterating two times the list when there were no files in it.
2023-08-08correct cmakedefine behaviorJan2001011-10/+28
- allow defines with leading whitespace - always do replacement for cmakedefine - output boolean value for cmakedefine01 - correct unittests for cmakedefine - add cmakedefine specific unittests
2023-08-08clang: use gcc syntax to enable diagnostics colorkiwixz1-3/+3
clang has supported gcc syntax since version 3.3.0 from 10 years ago. It's better than its own version because it takes a "when" verb which allows us to explicitely ask for "auto". This is useful when overriding flags that came from elsewhere. Before this patch, meson was just treating b_colorout="auto" as "always".
2023-08-08tests: fix test_vsenv_option with Python 3.11+ on WindowsChristoph Reiter1-1/+3
meson tests enable PYTHONWARNDEFAULTENCODING by default and make EncodingWarning fatal too. Starting with Python 3.11 CPython not only warns if no encoding is passed to open() but also to things like subprocess.check_output(). This made the call in vsenv.py fail and in turn made test_vsenv_option fail. check_output() here calls a .bat file which in turn calls vcvars. I don't know what the encoding is supposed to be used there, so just be explicit with the locale encoding to silence the warning.
2023-08-08interpreter|dependencies: Fix issues spotted by mypyDylan Baker1-5/+4
Which is mostly that other annotations are wrong.
2023-08-08interpreter: delete dead code in func_declare_dependencyDylan Baker1-3/+0
2023-08-08interpreter: add type annotations to func_declare_dependencyDylan Baker2-3/+22
2023-08-08Detect version for Vulkan system dependencyLucas Alber1-5/+29
2023-08-07machine file: Fix crash on empty valueXavier Claessens1-2/+4
Fixes: #12025
2023-08-07Error when an installed static library links to internal custom targetXavier Claessens1-28/+31
When an installed static library A links to an internal static library B built using a custom_target(), raise an error instead of a warning. This is because to be usable, A needs to contain B which would require to extract the archive to get its objects files. This used to work, but was printing a warning and was installing a broken static library, because we used to overlink in many cases, and that got fixed in Meson 1.2.0. It now fails at link time with symbols from the custom target not being defined. It's better to turn the warning into a hard error at configure time. While at it, noticed this situation can happen for any internal custom or rust target we link to, recursively. get_internal_static_libraries_recurse() could be called on CustomTarget objects which do not implement it, and even if we did not call that method, it would still fail when trying to call extract_all_objects() on it. Fixes: #12006
2023-08-07c_std, cpp_std: Change to a list of desired versions in preference orderXavier Claessens4-95/+150
Projects that prefer GNU C but can fallback to ISO C can now set for example `default_options: 'c_std=gnu11,c11'` and it will use gnu11 when available, fallback to c11 otherwise. It is an error only if none of the values are supported by the current compiler. This allows to deprecate gnuXX values from MSVC compiler, that means that `default_options: 'c_std=gnu11'` will now print warning with MSVC but still fallback to 'c11' value. No warning is printed if at least one of the values is valid, i.e. `default_options: 'c_std=gnu11,c11'`. In the future that deprecation warning will become an hard error because `c_std=gnu11` should mean GNU is required, for projects that cannot be built with MSVC for example.
2023-08-07Compiler: Add werror kwarg to compiles(), links() and run() methodsXavier Claessens1-27/+29
Fixes: #5399
2023-08-06build.py: improve BuildTarget error messageAlexandre Janniaux1-2/+2
Improve the error message when a build target is assigned as dependency of another build target, which allows to better pinpoint where the issue lies on. In the example that follow, modules/meson.build:294 is in a for loop creating library targets from an array of dictionary, and doesn't point to the location where interop_sw_plugin is assigned with vlc_opengl: Before: modules/meson.build:294:17: ERROR: Tried to use a build target as a dependency. You probably should put it in link_with instead. After: modules/meson.build:294:17: ERROR: Tried to use a build target vlc_opengl as a dependency of target interop_sw_plugin. You probably should put it in link_with instead. It would probably be best to directly pinpoint where the assignment was made but it's probably harder so start simple by saying what is concerned by the error.
2023-08-06UserArrayOption: Make listify_value() a static methodXavier Claessens2-3/+7
2023-08-06UserArrayOption: Remove user_input argumentXavier Claessens4-16/+14
The only place it can be set to False is from optinterpreter. Better check value there and deprecate string usage.
2023-08-06environment: Don't override mips64 to mips if no compilers are availableSimon McVittie1-2/+2
If we have a build- or host-architecture compiler, we can detect mips64 vs. mips by the fact that mips64 compilers define __mips64. However, machine_info_can_run() doesn't provide any compilers, because it is interested in the architecture of the underlying kernel. If we don't return mips64 when running on a mips64 kernel, machine_info_can_run() will wrongly say that we can't run mips64 binaries. If we're running a complete 32-bit mips user-space on a mips64 kernel, it's OK to return mips64 in the absence of any compilers, as a result of the previous commit "environment: Assume that mips64 can run 32-bit mips binaries". Resolves: https://github.com/mesonbuild/meson/issues/12017 Bug-Debian: https://bugs.debian.org/1041499 Fixes: 6def03c7 "detect_cpu: Fix mips32 detection on mips64" Signed-off-by: Simon McVittie <smcv@debian.org>
2023-08-06environment: Assume that mips64 can run 32-bit mips binariesSimon McVittie1-0/+1
The relationship between mips64 and mips is similar to the relationship between x86_64 and x86. Representing it here is necessary so that we will not require an exe_wrapper when cross-compiling for 32-bit mips on mips64, or when a complete 32-bit mips user-space runs on a 64-bit kernel without using linux32 to alter uname(2) to pretend to be 32-bit. Signed-off-by: Simon McVittie <smcv@debian.org>
2023-08-05fixup: since: 1.1.0 -> 1.3.0Milan Hauth1-1/+1
2023-08-05compiler: Add required keyword to has_* methodsXavier Claessens1-40/+100
add the "required" keyword to the functions has_function has_type has_member has_members has_argument has_multi_arguments has_link_argument has_multi_link_argument has_function_attribute Co-authored-by: Milan Hauth <milahu@gmail.com>
2023-08-04Add default_options argument to find_program()Nomura2-5/+11
2023-08-03PkgConfigDependency: Move CLI handling into its own abstractionXavier Claessens6-169/+233
This makes the code cleaner and will allow to have other implementations in the future.
2023-08-03MachineChoice: Implement __str__ for easier debugXavier Claessens1-0/+3
2023-08-03run_command: Remove useless node argumentXavier Claessens2-5/+4
There is no need to pass it, we already have self.current_node.
2023-08-03ExecutableSerialisation: capture and feed are optional stringsXavier Claessens2-10/+8
capture is the optional filename stdout is redirected to. feed is the optional filename stdin reads from.
2023-08-02convert booleans in summary function to correct representationEli Schwartz1-3/+6
str() is going to return titlecased "True" which is not how meson works. This is misleading, so use the meson-specific format instead.
2023-08-02Unify message(), format() and fstring formattingXavier Claessens5-32/+56
Share a common function to convert objects to display strings for consistency. While at it, also add support for formatting user options.
2023-08-02treewide: internally avoid deprecated machine file uses of "pkgconfig"Eli Schwartz1-1/+1
We support this in a machine file: ``` [binaries] pkgconfig = 'pkg-config' pkg-config = 'pkg-config' ``` and you can use either one, because internally we look up both. If you only set *one* of them, this plays awkwardly with setting $PKG_CONFIG, since we don't know which one you set in the machine file and the *other* one will be initialized from the environment instead. In commit 22df45a31981874310a78dde0df59a6a7c5ebb29 we changed program lookup of config-tool style dependencies to use the regular tool names and only fall back on the strange internal names. This affected the pkg-config class too. The result is that instead of preferring `pkgconfig =` followed by $PKG_CONFIG followed by `pkg-config =`, we inverted the lookup order. This is a good idea anyway, because now it behaves consistently with `find_program('pkg-config')`. Unfortunately, we documented the wrong name in a bunch of places, and also used the wrong name in various testsuite bits, which meant that if you set $PKG_CONFIG and then ran the testsuite, it would fail. Correct these references, because they are buggy. One test case expected to find_program() a native copy for convenience of testing against natively installed glib. Force it to resolve a native copy.
2023-08-02Optimize extract_dll_paths in ninja backendCharles Brunet1-24/+29
On my project, this function was a bottleneck in setup time. By properly caching it, the cumtime for this function went from 26s to 4.3s when I profiled it.
2023-07-31fix lint errors revealed by pycodestyle 2.11Eli Schwartz2-5/+5
When performing isinstance checks, an identity comparison is automatically done, but we don't use isinstance here because we need strict identity equality *without allowing subtypes*. Comparing type() == type() is a value comparison, but could produce effectively the same results as an identity comparison, usually, despite being semantically off. pycodestyle learned to detect this and warn you to do strict identity comparison.
2023-07-31do better sanity check for vs_module_defs inputEli Schwartz1-1/+1
We allow custom_target() but check for it based on hasattr, ever since the initial implementation way back in the day, in commit 66a6ea984bc43d9ac144e22cf411c16e9f911bb3. This is a bit broken because various objects might support that but still aren't supposed to work. We can actually just use isintance checks like we do immediately above, which are more accurate and avoid crashes on things that aren't even targets at all, like run_target(). Although custom_target indexes are actually targets those didn't work either. Fixes #9648
2023-07-31Merge pull request #11986 from williamspatrick/clang-enable-cpp23Jussi Pakkanen1-2/+24
add support for newer C++ -std= flags on Clang/GCC
2023-07-28modules/python3: exclude name_prefix and name_suffixDylan Baker1-5/+1
We can remove these from `permittedKwargs` (like we've already done for `typed_kwargs`) and then remove the in body checks.
2023-07-28modules/python3: use typed_pos_args for extension_moduleDylan Baker1-4/+9
2023-07-28modules/python3: use typed_kwargs for extension_moduleDylan Baker1-3/+12
Just like python, but for the python3 module