aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/scripts
AgeCommit message (Collapse)AuthorFilesLines
2023-09-25Add clang-tidy-fix targetLei YU1-1/+6
Add the `clang-tidy-fix` target to apply clang-tidy fixes to the source code. This is done by calling `run-clang-tidy` with `-fix` argument. Add a test case to run `clang-tidy-fix` and verify the file is changed. Signed-off-by: Lei YU <yulei.sh@bytedance.com>
2023-09-15environment, env2mfile: Don't shell split paths if they point to a valid ↵L. E. Segovia1-1/+4
executable Fixes #11128
2023-08-14Python: Add 'limited_api' kwarg to extension_moduleAndrew McNulty1-0/+15
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-11treewide: automatic rewriting of all comment-style type annotationsEli Schwartz2-4/+4
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-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-06-19Add kernel and subsystem properties to machine objects.Jussi Pakkanen1-1/+16
2023-06-12env2mfile: Take pkg-config properties from envXavier Claessens1-0/+10
2023-06-12env2mfile: Take binaries from env for cross file tooXavier Claessens1-0/+1
2023-06-12env2mfile: Not all compilers have env for flagsXavier Claessens1-1/+3
2023-05-16meson_exe: print suitable debug information for DLL not found errorsEli Schwartz1-1/+2
It's particularly inscrutable if you do not know where DLLs weren't found because you don't know what the PATH was in the child process.
2023-05-02bytecompile: switch to handling destdir in the script launcher envEli Schwartz1-14/+12
2023-05-02python module: add an automatic byte-compilation stepEli Schwartz1-0/+67
For all source `*.py` files installed via either py.install_sources() or an `install_dir: py.get_install_dir()`, produce `*.pyc` files at install time. Controllable via a module option.
2023-04-25Fix html coverage report generation when using clang on linuxJakob Widauer1-1/+1
2023-04-11fix various spelling issuesJosh Soref2-2/+2
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-03-28Import cpu detection fix from Debian.Jussi Pakkanen1-0/+1
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1033579
2023-03-21Fix run_tool() when git is not installedAlyssa Ross1-3/+3
Previously, it would raise an exception.
2023-03-16hotdoc: Install devhelp files at the right locationXavier Claessens1-5/+5
When devhelp is enabled, hotdoc generates a devhelp/ subdir that needs to be installed to /usr/share/devhelp/. Otherwise, the html/ subdir needs to be installed to /usr/share/doc/<project>/html/
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-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-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-22python module: move the introspection script into an external scriptEli Schwartz1-0/+75
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
2023-02-01pylint 2.16: remove pointless parens around equality assignmentsEli Schwartz1-1/+1
Given the construct `foo = (bar == baz)` some people like parentheses and some do not. They're pointless and don't mean anything, though. I don't feel this is particularly helpful to code clarity, tbh, and pylint now notices this and warns about it in our current pylint config. I think this is reasonable, so let's remove the odd parens.
2023-02-01simplify instantiation of builtin type using builtins instead of functionsEli Schwartz1-8/+10
2023-02-01treewide: add future annotations importEli Schwartz22-0/+23
2022-12-14depfixer: silence fix_jar() and make it do somethingBenjamin Gilbert1-1/+6
fix_jar() tries to remove an existing Class-Path entry from the jar manifest by postprocessing the manifest and passing it to `jar -um`. However, `jar -um` can only add/replace manifest entries, not remove them, and it also complains loudly when replacing an entry: Dec 13, 2022 7:11:19 PM java.util.jar.Attributes read WARNING: Duplicate name in Manifest: Manifest-Version. Ensure that the manifest does not have duplicate entries, and that blank lines separate individual sections in both your manifest and in the META-INF/MANIFEST.MF entry in the jar file. Thus fix_jar() produces one such warning for each entry in the manifest and accomplishes nothing else. Use jar -uM instead. This completely removes the manifest from the jar and allows adding it back as a normal zip member, fixing fix_jar() and avoiding the warnings. Fixes: https://github.com/mesonbuild/meson/issues/10491 Fixes: c70a051e93 ("java: remove manifest classpath from installed jar")
2022-12-13depfixer: don't extract MANIFEST.MF verboselyBenjamin Gilbert1-1/+1
Avoids non-actionable output when installing a jar: inflated: META-INF/MANIFEST.MF Fixes: c70a051e93 ("java: remove manifest classpath from installed jar")
2022-12-05on newer versions of clang-format, use builtin --check handlingEli Schwartz1-2/+10
Due to a deficiency in upstream clang-format, our automatic target for `ninja clang-format-check` runs clang-format, then compares the bytes of the file before and after to see if anything changed. If it did change, we rewrite the file back to its original form and error out. Since clang-format 10, there is an option to report warnings instead of writing the reformatted file, and also, to make those warnings fatal. This is a much better user experience, to see *what* is wrong, not just that something is wrong, and also gets rid of a pretty gross "modify your files when you didn't ask for it" behavior that is vulnerable to getting interrupted. Let's switch over to the new approach, if we can.
2022-11-30pylint: enable the set_membership pluginDylan Baker3-4/+4
Which adds the `use-set-for-membership` check. It's generally faster in python to use a set with the `in` keyword, because it's a hash check instead of a linear walk, this is especially true with strings, where it's actually O(n^2), one loop over the container, and an inner loop of the strings (as string comparison works by checking that `a[n] == b[n]`, in a loop). Also, I'm tired of complaining about this in reviews, let the tools do it for me :)
2022-11-30pylint: enable simplifiable-if-statementDylan Baker1-4/+2
2022-11-22Fix writing single strings in env2mfile.Jussi Pakkanen1-1/+2
2022-11-12Add CMake to cross file.Jussi Pakkanen1-4/+30
Original patch by Helmut Grohne. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1023744
2022-11-12Fix ppc64 detection in Debian.Jussi Pakkanen1-1/+3
Original patch by Helmut Grohne. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1023744
2022-11-03depfixer: handle darwin dependencies with non-ASCII pathsEli Schwartz1-4/+4
I assume there's no real reason this cannot happen, perhaps if the meson source directory has one. So we should use Popen_safe for safety reasons.
2022-10-24Add yasm as fallback for nasm languageXavier Claessens1-0/+22
2022-10-03pylint: enable unspecified-encodingDylan Baker1-1/+1
2022-09-28Move classes used by scripts to their own moduleXavier Claessens2-3/+14
Those classes are used by wrapper scripts and we should not have to import the rest of mesonlib, build.py, and all their dependencies for that. This renames mesonlib/ directory to utils/ and add a mesonlib.py module that imports everything from utils/ to not have to change `import mesonlib` everywhere. It allows to import utils.core without importing the rest of mesonlib.
2022-09-22pylint: enable global-statementDylan Baker3-5/+2
This does force a number of uses of `# pylint: disable` comments, but it also finds a couple of useless global uses and one place (in the previous commit) that an easy refactor removes the use of global. Global is a code smell, so forcing adding a comment to disable helps force developers to really consider if what they're doing is a good idea.
2022-09-22pylint: enable global-variable-not-assignedDylan Baker1-1/+0
The `global` statement is only needed to assign to global variables, not read or mutate them. So calling `global.mutate()` is fine, but not `var = foo`, which would otherwise shadow `var`.
2022-09-21Fix cmd_or_ps.ps1 script with pwsh7Xavier Claessens1-12/+7
gwmi command does not exist any more and is replaced by Get-CimInstance. See https://github.com/PowerShell/PowerShell/issues/4766. While at it, use a do..while loop to avoid duplicated lines. Fixes: #10820
2022-09-19pylint: enable use-maxsplit-argDylan Baker1-1/+1
This finds a bunch of places where we can do more efficient string splitting.
2022-09-01env2mfile: reuse logical lists of interesting facts from meson itselfEli Schwartz1-45/+12
Meson internally knows about many languages and tools, and *FLAGS variables, and which languages to use them for. Instead of duplicating this logic, import it from mesonbuild.* This logic was originally standalone, but now that it is merged into the Meson tree we can have a single source of truth.
2022-08-26Fix purely white space issues reported by flake8Alf Henrik Sauge2-2/+1
2022-07-25ninja depscanner: handle C++ sources named capital CEli Schwartz1-1/+3
In commit 4ca9a16288f51cce99624a2ef595d879acdc02d8 we added unreliable support (it warns you if you try it) for gcc-compatible treatment of uppercase-C files being C++ instead of C. In order to handle it correctly, we needed to evaluate can-compile by special-casing "C" to avoid lowercasing it for comparisons. This didn't cover all cases where we check if "C" is a C++ language file. We also straight-up check the language of a file (rather than working backwards to see if a C++ compiler can compile it) when doing module scanning, and this needs to special-case "C" as well. We also had one case where we only checked lowercase fortran extensions, but not lowercase C++ extensions. While we are at it, use lowercase for C++ as well, except the "C" special case. Fixes #10629
2022-07-16Ignore encoding errors when scanning. Closes #10571.Jussi Pakkanen1-2/+2
In Fortran and C++ all the bits we care about are in ASCII. 8-bit characters can only occur in comments and string literals and we don't parse those.
2022-06-26Fix destdir_joinAkihiko Odaki1-3/+3
The old implementation assumed a path is of Windows iff the second character is a colon. However, that is not always true. First, a colon can be included in a non-Windows path. For example, it is totally fine to have a directory named ':' on Linux 5.17.0 tmpfs. Second, a Windows path may start with \\ for UNC or extended length. Use pathlib to handle all of these cases.
2022-06-17always run external projects multi-threaded if possibleStaz M1-4/+3
The check for if the project supports the -j flag was needlessly complex. We support two types of project: - waf, always supports -j - make, if GNU, supports -j We never checked waf, and the make check assumed that the entire command, rather than just the last component, was "make". It also neglects "gmake". Since any possible build command *may* support -j, always run the --version check. Detect either build command in the output.
2022-06-17always set DESTDIR via the environment for external projectsStaz M1-4/+1
It doesn't matter whether it is make or not, because make, too, supports setting it via the env. This reduces the use of special cases in the code.