Commit Graph

467 Commits

Author SHA1 Message Date
Andrew McNulty 74712f2dbc scan-build: Exclude subprojects from scan-build report
When a user invokes the scan-build target that Meson generates
all subprojects are included in the resulting report. This commit
modifies the invocation of scan-build to exclude all bugs that
scan-build finds in the subprojects from the final report.

A release note has also been added describing the changed behaviour.
2023-11-02 18:41:51 -04:00
Luke Elliott ce691f8c98 Add comments suggesting to keep shell completion scripts up-to-date near cmd line argument code 2023-11-01 00:06:19 +02:00
Chun-wei Fan ada6236f76 i18n module: Invoke itstool with the full command line
Certain envs may not support invoking itstool by itself directly as a script
as shebang lines are not supported, such as under cmd.exe shells on Windows,
that are normally used for Visual Studio (and the like, such as clang-cl)
builds.

This will call the corresponding interpreter to invoke itstool when needed, so
that itstool can be properly run, even if shebang lines are not supported by
the env.

This will fix building appstream on Windows using clang-cl, for instance.
2023-10-26 01:12:14 -04:00
Eli Schwartz 1cf0ed0997 add missing imports for future annotations 2023-10-20 18:07:05 -04:00
Nigel Kukard 2c4a1b6324 Add support for lcov 2.0
lcov 2.0 deprecates `--rc lcov_branch_coverage=1` for `--rc branch_coverage=1` and
gives an error when an exclude is used on a non existing directory.

I added a version check for lcov and removed the subprojects directory from the
exclusion list if it does not exist.

Fixes #11995
2023-10-08 23:13:06 -04:00
Eli Schwartz 2d6c10908b
python module: stop using distutils "link to libpython" probe on recent python
On python >=3.8, this information is expected to be encoded in the
sysconfig vars.

In distutils, it is always necessary to link to libpython on Windows;
for posix platforms, it depends on the value of LIBPYTHON (which is the
library to link to, possibly the empty string) as generated by
configure.ac and embedded into python.pc and python-config.sh, and then
coded a second time in the distutils python sources.

There are a couple of caveats which have ramifications for Cygwin and
Android:

- python.pc and python-config.sh disagree with distutils when python is
  not built shared. In that case, the former act the same as a shared
  build, while the latter *never* links to libpython

- python.pc disagrees with python-config.sh and distutils when python is
  built shared. The former never links to libpython, while the latter do

The disagreement is resolved in favor of distutils' behavior in all
cases, and python.pc is correct for our purposes on python 3.12; see:
https://github.com/python/cpython/pull/100356
https://github.com/python/cpython/pull/100967

Although it was not backported to older releases, Cygwin at least has
always patched in a fix for python.pc, which behavior is now declared
canonical. We can reliably assume it is always correct.

This is the other half of the fix for #7702
2023-10-02 18:15:16 -04:00
Eli Schwartz 3d3a10ef02
python module: refactor pypy detection into a consistent variable 2023-10-02 18:15:16 -04:00
Eli Schwartz 40f897fa92
python module: stop using distutils schemes on sufficiently new Debian
Since 3.10.3, Debian finally started patching sysconfig with custom
paths, instead of just distutils. This means we can now go use that
instead. It reduces our reliance on the deprecated distutils module.

Partial fix for #7702
2023-10-02 18:15:16 -04:00
Charles Brunet a843a99743
mypy: replace fchmod by chmod
The former is unix-only, which complains when running on the Windows
platform -- even though this code is in a unix-specific branch.

But per the docs:

> As of Python 3.3, this is equivalent to os.chmod(fd, mode).

So we can just use the identical function that is available in more
places.
2023-09-26 18:13:31 -04:00
Lei YU 8d6b474bf6 Add clang-tidy-fix target
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-25 16:25:01 +03:00
L. E. Segovia 878d950887 environment, env2mfile: Don't shell split paths if they point to a valid executable
Fixes #11128
2023-09-15 07:31:37 -04:00
Andrew McNulty c730807696 Python: Add 'limited_api' kwarg to extension_module
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-14 20:02:09 -04:00
Eli Schwartz 90ce084144
treewide: automatic rewriting of all comment-style type annotations
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-11 13:41:03 -04:00
Eli Schwartz 13f8eba9b6
treewide: internally avoid deprecated machine file uses of "pkgconfig"
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 22df45a319 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-02 01:35:16 -04:00
Jussi Pakkanen b0d2a92584 Add kernel and subsystem properties to machine objects. 2023-06-19 18:03:57 +03:00
Xavier Claessens dbb857dd71
env2mfile: Take pkg-config properties from env 2023-06-12 15:08:30 -04:00
Xavier Claessens 62a5673b98
env2mfile: Take binaries from env for cross file too 2023-06-12 15:08:28 -04:00
Xavier Claessens 1ab7d3b28e
env2mfile: Not all compilers have env for flags 2023-06-12 15:08:26 -04:00
Eli Schwartz 0b5e95ae71 meson_exe: print suitable debug information for DLL not found errors
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-16 11:19:43 -04:00
Eli Schwartz 877d5ea8e0
bytecompile: switch to handling destdir in the script launcher env 2023-05-02 19:28:35 -04:00
Eli Schwartz 0e7fb07f91
python module: add an automatic byte-compilation step
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-05-02 19:28:35 -04:00
Jakob Widauer 07bd28732e Fix html coverage report generation when using clang on linux 2023-04-25 23:48:56 -04:00
Josh Soref cf9fd56bc9 fix various spelling issues
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-11 19:21:05 -04:00
Jussi Pakkanen 65482497d3 Import cpu detection fix from Debian.
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1033579
2023-03-28 11:50:44 +03:00
Alyssa Ross b85ffbacb1 Fix run_tool() when git is not installed
Previously, it would raise an exception.
2023-03-21 19:17:05 -04:00
Xavier Claessens 340aedc0d9 hotdoc: Install devhelp files at the right location
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-03-16 10:36:33 -04:00
Jussi Pakkanen 5ccac0699f Add detection code for powerpc64le.
Originally from:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1019413
2023-02-28 20:24:51 +02:00
Jussi Pakkanen 38b6d6d61a Add a deb_ prefix to constants that are only used in Debian system detection. 2023-02-28 20:24:51 +02:00
Jussi Pakkanen 2aa4d6e54e Handle a cross compilation setup that only has a C compiler. 2023-02-28 20:24:51 +02:00
Jussi Pakkanen bc38db035e Add Debian platform autodetect to env2mfile. 2023-02-28 20:24:51 +02:00
Eli Schwartz 9f05d45b70 work around circular imports in python probe script
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-24 20:45:00 -05:00
Eli Schwartz 023a0db04c
clangformat: don't noisily print status messages for every checked file
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-23 01:31:51 -05:00
Eli Schwartz 3bbfd4d4b8 python module: move the introspection script into an external script
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-22 10:32:09 -08:00
Eli Schwartz d6b81307f6
pylint 2.16: remove pointless parens around equality assignments
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-01 17:01:30 -05:00
Eli Schwartz c9ac73a4da
simplify instantiation of builtin type using builtins instead of functions 2023-02-01 17:01:30 -05:00
Eli Schwartz 680b5ff819
treewide: add future annotations import 2023-02-01 17:01:30 -05:00
Benjamin Gilbert 35e230e48c depfixer: silence fix_jar() and make it do something
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-14 15:37:59 -05:00
Benjamin Gilbert 51c889ddbc depfixer: don't extract MANIFEST.MF verbosely
Avoids non-actionable output when installing a jar:

    inflated: META-INF/MANIFEST.MF

Fixes: c70a051e93 ("java: remove manifest classpath from installed jar")
2022-12-13 21:41:50 -05:00
Eli Schwartz ce120ff164 on newer versions of clang-format, use builtin --check handling
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-12-05 12:33:17 -08:00
Dylan Baker 2d349eae8c
pylint: enable the set_membership plugin
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-30 16:23:29 -05:00
Dylan Baker 67da2ad0fb
pylint: enable simplifiable-if-statement 2022-11-30 07:01:22 -05:00
Jussi Pakkanen fd43842041 Fix writing single strings in env2mfile. 2022-11-22 02:19:59 +02:00
Jussi Pakkanen 611bd4e6db Add CMake to cross file.
Original patch by Helmut Grohne.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1023744
2022-11-12 14:21:47 +02:00
Jussi Pakkanen 318579b367 Fix ppc64 detection in Debian.
Original patch by Helmut Grohne.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1023744
2022-11-12 14:21:47 +02:00
Eli Schwartz 97ec20e901
depfixer: handle darwin dependencies with non-ASCII paths
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-11-03 17:51:35 -04:00
Xavier Claessens d29ef2b128 Add yasm as fallback for nasm language 2022-10-24 11:06:57 +02:00
Dylan Baker 8c819ab805
pylint: enable unspecified-encoding 2022-10-03 00:02:02 -04:00
Xavier Claessens 2dfd952eb9 Move classes used by scripts to their own module
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-28 19:36:13 -04:00
Dylan Baker f5283dd63f pylint: enable global-statement
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-22 18:17:43 -04:00
Dylan Baker 3ef332e89a pylint: enable global-variable-not-assigned
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-22 18:17:43 -04:00