Commit Graph

444 Commits

Author SHA1 Message Date
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
Xavier Claessens bb4c8c07f8 Fix cmd_or_ps.ps1 script with pwsh7
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-21 18:32:51 -04:00
Dylan Baker 188c552dcf pylint: enable use-maxsplit-arg
This finds a bunch of places where we can do more efficient string
splitting.
2022-09-19 20:57:52 -04:00
Eli Schwartz 388cb0f805 env2mfile: reuse logical lists of interesting facts from meson itself
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-09-01 01:05:48 +03:00
Alf Henrik Sauge 06bf9a5cda Fix purely white space issues reported by flake8 2022-08-26 17:12:40 -04:00
Eli Schwartz 5b2f921d52
ninja depscanner: handle C++ sources named capital C
In commit 4ca9a16288 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-25 16:59:41 -04:00
Jussi Pakkanen c44ae35356 Ignore encoding errors when scanning. Closes #10571.
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-07-16 00:29:10 +03:00
Akihiko Odaki c2c9359d46 Fix destdir_join
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-26 17:18:26 -04:00
Staz M 7409f12a82 always run external projects multi-threaded if possible
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-17 18:56:38 -04:00
Staz M 7da495f616 always set DESTDIR via the environment for external projects
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.
2022-06-17 18:56:38 -04:00
Xavier Claessens 57909b53d6 Improve WINEPATH reduction
- Remove duplicated code in mdevenv.py
- Change the limit to 1024 instead of 2048 which is what has been
  tested.
- Skip shortening if it is already short enough.
- Skip shortening with wine >= 6.4 which does not seems to have that
  limitation any more.
- Downgrade exception to warning in the case WINEPATH cannot be
  shortened under 1024 chars, it is possible that it will still work.
2022-06-17 11:53:38 -04:00
Seungha Yang ee7a7fec10 devenv: Add support for PowerShell 7 on Windows
Checks "pwsh.exe" in addition to "powershell.exe" and "cmd.exe"
to support PowerShell 7 on Windows. The Powershell 7 support was added
in GStreamer (which is the origin of this script) already via
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2545
2022-06-14 19:09:25 -04:00
Eli Schwartz 462b35e4b1 flake8: fix various whitespace nits 2022-06-13 13:34:39 +03:00
Eli Schwartz a49cd00d64 treewide: various cleanups to move imports for mypy into typechecking blocks
Along the way, add __future__ annotations where lacking.
2022-06-10 09:15:48 -04:00
Eli Schwartz 34da721ec2
gettext: explicitly pass source root / subdir as cli args
Because this is a wrapper script and we could/should do this, we even
have half the infra for it.
2022-05-29 18:23:03 -04:00
Eli Schwartz 1e4d4fce22 coverage: be clever and detect config files for gcovr/lcov
gcovr will read this file anyway, but if it exists we don't need to
assume that the project wishes to exclude subprojects/ -- they can
determine that themselves.

Fixes #3287
Closes #9761

lcov doesn't read the config file by default, but we can do the smart
thing here.

Fixes #4628
2022-05-06 22:55:37 +03:00
Jussi Pakkanen b78d33f0b5 Fix typo that breaks g++ cross detection on Debian. 2022-04-23 23:57:15 +03:00
Chun-wei Fan 9528e7deb0 gtkdochelper.py: Use os.pathsep for --path argument
This way, we can ensure that gtk-doc parses the --path argument
correctly when passed in from the cmd.exe console, since ':' is normally
used to denote that a drive is being used on local paths.
2022-04-21 12:13:51 -04:00
Thomas Klausner 1c23281653 Add NetBSD support in symbolextractor.
Choose FreeBSD backend (OpenBSD backend would also work).
2022-04-20 17:52:44 -04:00
Eli Schwartz 6a287fae5d
simplify destdir_join for readability
We can immediately short-circuit if there is no destdir, as we simply
return the prefix unchanged.

If there is some kind of destdir and the prefix contains a drive letter,
then no matter what we need to remove the drive letter before joining.
Technically, if the destdir is a relative path e.g. `destdir\` and
`C:\prefix`, we should still install to `destdir\prefix` without the
drive letter.

But... we also guarantee that destdir is an absolute path (or empty)
anyway. And even if we didn't, non-absolute destdir is a broken concept
for a variety of complicated reasons. So none of this matters in
practice.

One way or another, we don't need to actually check whether destdir is
an absolute path before cutting off the prefix drive letter.
2022-04-14 18:37:04 -04:00
Eli Schwartz bb171c2dff
pyupgrade --py37-plus
Some more old style code crept in again.

Additionally, pyupgrade learned to catch more if/elsed code based on the
python version, and delete it.
2022-04-14 18:37:03 -04:00
Eli Schwartz c9938f8f60
move a bunch of imports into TYPE_CHECKING blocks
These are only used for type checking, so don't bother importing them at
runtime.

Generally add future annotations at the same time, to make sure that
existing uses of these imports don't need to be quoted.
2022-03-29 16:44:54 -04:00
Jussi Pakkanen 69ade4f4cf
Merge pull request #9339 from dcbaker/submit/structured_sources
Structured Sources
2022-03-13 01:01:55 +02:00
Jussi Pakkanen 04ef7ec45d Add new env2mfile command. 2022-03-09 18:02:04 -05:00