Commit Graph

13986 Commits

Author SHA1 Message Date
David Seifert 10e8995fc8 Use `cudart_static` by default in dependency('cuda')
* Without this, using nvcc as the sole driver vs dependency('cuda') and
  host compiler driver yields differently linked binaries.
2023-08-23 18:39:30 -04:00
David Seifert 078dc2ca10 Fix completely broken support for `static: true` with dependency('cuda') 2023-08-23 18:39:30 -04:00
Xavier Claessens 18b96cd069 machine file: Add @GLOBAL_SOURCE_ROOT@ and @DIRNAME@ 2023-08-23 11:33:39 -04:00
Benoit Pierre bde690b06e compilers: fix checks handling of internal dependencies
The include directories were not passed to the compiler.
2023-08-22 09:40:30 -04:00
Eli Schwartz 253df6f9f8
CI: make linters emit colored output
Github Actions supports this fine, but is misdetected by flake8/mypy.
Even though pylint defaults to text instead of colorized, we might as
well do the right thing here though.
2023-08-18 15:38:13 -04:00
Eli Schwartz 1ed619d196
run_mypy: add option to run once for each supported version of python
This allows verifying that meson is type-safe under older versions of
Python, which it currently is. Different versions of Python sometimes
have different supported types for an API.

Verify this in CI.

(We flush output to ensure CI prints lines in the right order.)
2023-08-18 15:38:13 -04:00
Eli Schwartz 3ebd570bd5
consistently use Literal annotation from typing_extensions
This is our standard annotation policy, and makes mypy safe under python
3.7
2023-08-18 15:37:52 -04:00
Eli Schwartz 184277bb4a
docs: use future annotations for genrefman types in typing_extensions
And in fact *use* typing_extensions, which is sometimes the only way to
get access to TypedDict.

Mostly, reindent almost but not quite an entire file to only define
annotation classes under TYPE_CHECKING.
2023-08-18 11:16:15 -04:00
Eli Schwartz 2edcbb452e
CI: trigger website job when testing modifications to the website job 2023-08-18 11:16:15 -04:00
Eli Schwartz 9153b82cc2
CI: add pip caching to website job
On average, saves 20 seconds for a job that may take 1.5 or 2 minutes.
Mostly due to recompiling the same 3 wheels again and again, so that
avoids pointless CPU waste.
2023-08-18 11:16:15 -04:00
Eli Schwartz 5a827616b5 ninja backend: fix the automatic restat of outputs when reconfiguring
The most notable problem this causes is that when running `meson setup
--reconfigure` the build.ninja file is erroneously seen as out of date,
so ninja immediately tries to regenerate it again as it didn't see the
file get updated.

There are two problems.

The first problem is that we looked for the wrong file. Ninja creates a
few internal files, and one of them is the one we care about:
`.ninja_log`, which contains stat'ed timestamps for build outputs to aid
in checking when things are out of date. But the thing we actually
checked for is `.ninja_deps`, a file that contains a compressed database
of depfile outputs. If the latter exists, then the former surely exists
too.

Checking for the wrong file meant that we would restat outputs, but only
when some build edges were previously built that had depfile outputs.

The second problem is that we checked for this in os.getcwd() instead of
the configured build directory. This very easily fails to be correct,
except when reconfigure is triggered directly by ninja itself, in which
case we didn't need the restat to begin with.
2023-08-18 07:57:32 -04:00
Tristan Partin 946a3561c2 Revert "Revert "Add fs.relative_to()""
This reverts commit 84c8905d52.

Fixed the cygwin failure...
2023-08-18 07:46:08 -04:00
M Henning 22f90fd469
Suggest fix in MesonVersionMismatchException
Every time I update meson, I spend about 20 minutes on frustrated googling
to figure out how to update my build directory to work with the new version.
I'm forgetful, okay? Ease this pain point by suggesting a potential fix in
the error message.
2023-08-18 00:41:56 -04:00
Benoit Pierre 268276f7ac tests: fix assertion rewriting when pytest is used 2023-08-18 00:37:40 -04:00
Charles Brunet 7cbe37ebd9 Add more descriptive description to CustomTarget
Allow modules using CustomTarget to modify the command description used by ninja backend. This result in more precise logs when building a project.
2023-08-18 00:36:49 -04:00
Jan Janssen 88747b4f8d docs: Provide example for feature.disable_auto_if 2023-08-18 00:36:32 -04:00
Eli Schwartz 84c8905d52
Revert "Add fs.relative_to()"
This reverts commit f52bcaa27f.

It did not pass CI, and was merged anyway because there were two CI
errors in the same cygwin job. The other error was not the fault of this
commit, and since cygwin errors were glossed over because they were
"expected", the presence of a new error *added* by this commit was
overlooked.

Per the meson development policy, PRs which result in CI errors
can/should be reverted at will, no questions asked.
2023-08-17 23:56:51 -04:00
Eli Schwartz 1fd70a2a00
tests: consolidate MESON_SKIP_TEST reporting and use it in unittests
Previously, we only reported the skip reason when running project tests.
2023-08-17 21:30:32 -04:00
Eli Schwartz 98232eb036
skip test on pkgconf 2.0.1 that is broken there due to a reported bug 2023-08-17 20:43:14 -04:00
Eli Schwartz e313f78465
fix style errors in fs.relative_to implementation
In commit f52bcaa27f 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-17 18:01:41 -04:00
Tristan Partin 7a2b673d40 Remove hacky setup for CustomTargetIndex tests in fs.relative_to() 2023-08-17 17:32:04 -04:00
Tristan Partin 543e9ca0cf Remove XML filter from testlog.{json,txt} and std streams
This was an unintended consequence of the original patch in #11977.

Co-authored-by: Benoit Pierre <benoit.pierre@gmail.com>
2023-08-17 17:31:30 -04:00
Tristan Partin f52bcaa27f Add fs.relative_to()
Returns a relative path from arg 2 to arg 1 similar to
os.path.relpath().
2023-08-17 17:05:49 -04:00
Charlie Ringström cbf8e67f19 Replace deprecated GTK flag 2023-08-17 15:33:35 -04:00
Xavier Claessens 229757fe91 README: Document python requirement history
This documents useful to target Meson versions for projects that want to
support older Python versions.
2023-08-17 11:17:47 -04:00
Tristan Partin 14892eb849
Fix some random capitalization in feature.yaml 2023-08-16 21:56:31 -04:00
Xavier Claessens f88a9cd6b3 fs.read(): Catch FileNotFoundError 2023-08-16 14:48:09 -07:00
Xavier Claessens 8a7fdd9159 wasm: make generic cross file 2023-08-16 15:04:58 -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
Dylan Baker 9d32302032 interpreter: use typed_kwargs for shared_library(darwin_versions) 2023-08-14 09:55:18 -07:00
Dylan Baker 09bc028c71 interpreter: use typed_kwargs for shared_library(soversion) 2023-08-14 09:55:18 -07:00
Dylan Baker cd676e229b interpreter: use typed_kwargs for shared_library(version) 2023-08-14 09:55:18 -07: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 de1cc0b02b
rewrite a couple comment-style type annotations for oddly indented dicts
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-11 13:39:07 -04:00
Eli Schwartz a01418db0a
remove useless type annotations
These annotations all had a default initializer of the correct type, or
a parent class annotation.
2023-08-11 13:37:17 -04:00
Jan Janssen 03a2a3a677 docs: Add more feature truth tables
These are much easier to understand at a glance than free-form text.
2023-08-11 08:33:00 -04:00
Eli Schwartz 32e7ebc821
hotdoc module: add a bunch more type annotations 2023-08-10 13:56:39 -04:00
Eli Schwartz bf0494fcc0
hotdoc module: avoid monkeypatch crime by properly subclassing ExternalProgram 2023-08-10 13:56:39 -04:00
Eli Schwartz 169cd7e619
python module: add a few more type annotations 2023-08-10 13:56:39 -04:00
Eli Schwartz 277151450a
allow some ObjectHolder subclasses to continue to be generic
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-10 13:56:39 -04:00
Xavier Claessens 13b626b67b Popen_safe_logged: Also log exceptions
Popen can raise OSError when program is not found, or PermissionError if
not executable, etc.
2023-08-10 10:36:35 -04:00
Charles Brunet 711e4e3b06 Optimize CLikeCompiler._get_file_from_list()
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-09 09:44:15 -04:00
Jan200101 b91244c3b7 correct cmakedefine behavior
- 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-08 14:53:43 -07:00
kiwixz 3de0f6d4e9 clang: use gcc syntax to enable diagnostics color
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-08 16:46:03 -04:00
Christoph Reiter 6671b7359f tests: fix "4 custom target depends extmodule" with Python 3.8+ on Windows
Since CPython 3.8 .pyd files no longer look in PATH for loading libraries,
but require the DLL directory to be explicitely added via os.add_dll_directory().
This resulted in those tests failing with 3.8+ on Windows.

Add the DLL build directory with os.add_dll_directory() to fix them.

This was never noticed in CI because it only uses Python 3.7 and the
MSYS2 CPython still used the old behaviour until now.
2023-08-08 16:32:39 -04:00
Christoph Reiter ec10816665 tests: fix test_vsenv_option with Python 3.11+ on Windows
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-08 16:32:39 -04:00
Dylan Baker 94a97b2f8d interpreter|dependencies: Fix issues spotted by mypy
Which is mostly that other annotations are wrong.
2023-08-08 10:06:47 -07:00
Dylan Baker bf036f37cd interpreter: delete dead code in func_declare_dependency 2023-08-08 10:06:47 -07:00
Dylan Baker 7abd4d39c1 interpreter: add type annotations to func_declare_dependency 2023-08-08 10:06:47 -07:00
Lucas Alber a151b10988
Detect version for Vulkan system dependency 2023-08-08 08:25:04 -04:00