Commit Graph

42 Commits

Author SHA1 Message Date
Simon McVittie 61554ad37b tests: Assert that mips64 kernel is detected as mips64 with no compilers
Reproduces: https://github.com/mesonbuild/meson/issues/12017
Signed-off-by: Simon McVittie <smcv@debian.org>
2023-08-06 02:32:25 -04:00
Simon McVittie 432317bc6b tests: Pass a mock C compiler to detect_cpu(), detect_cpu_family()
In some cases the desired result can be different if there are no
compilers at all. The expectations here are based on there being at
least one compiler, so reflect that by providing one; a later test
enhancement can cover the case where there are no compilers provided.

As a result of the mock any_compiler_has_define(), all that matters
will be the distinction between an empty or non-empty dict: the compiler
object itself is unused.

Signed-off-by: Simon McVittie <smcv@debian.org>
2023-08-06 02:32:25 -04:00
Xavier Claessens 183e4b8e90 PkgConfigDependency: Move CLI handling into its own abstraction
This makes the code cleaner and will allow to have other implementations
in the future.
2023-08-03 16:27:52 -04:00
Tristan Partin 3784f72973 Silence some encoding warnings
By specifiying explicit encodings, we can silence warnings like:

 /__w/meson/meson/test cases/common/100 postconf with args/postconf.py:15: EncodingWarning: 'encoding' argument not specified
  with open(input_file) as f:

in CI.
2023-07-13 09:55:10 -07:00
Eli Schwartz a1ef957e34
linkers: delay implementations import until detect is run
This saves on a 1500-line import at startup and may be skipped entirely
if no compiled languages are used. In exchange, we move the
implementation to a new file that is imported instead.

Followup to commit ab20eb5bbc.
2023-06-26 13:10:33 -04:00
Eli Schwartz b1ddfabf8f
dependencies: defer importing a custom dependency until it is used
This lessens the amount of code imported at Meson startup by mapping
each dependency to a dictionary entry and using a programmable import to
dynamically return it.

Minus 16 files and 6399 lines of code imported at startup.
2023-06-26 13:10:33 -04:00
Dylan Baker ada2a976f0
mlog: use a hidden class for state
This is a pretty common pattern in python (the standard library uses it
a ton): A class is created, with a single private instance in the
module, and then it's methods are exposed as public API. This removes
the need for the global statement, and is generally a little easier to
reason about thanks to encapsulation.
2023-05-31 17:20:44 -04:00
Cyan 6def03c787 detect_cpu: Fix mips32 detection on mips64
MIPS64 can run MIPS32 code natively, so there is a chance that a mixture
of MIPS64 kernel and MIPS32 userland exists. Before this Meson just
treats such mixture as mips64, because uname -m returns mips64.

So in this case we have to check compiler builtin defines for actual
architecture and CPU in use.

- Also fixes mips64 related detection tests in internaltests:
  Normalize mips64 as mips first, then if __mips64 is defined, return
  mips64 for mips64* machines.

  This is a bit confiusing because normally one would detect if a flag
  of 32-bit target is defined while running on a 64-bit machine. For
  mips64 it is almost just the other way around - we need to detect if
  __mips64 is set to make sure it is a mips64 environment.

Co-Authored-By: Jue Wang <maliya355@outlook.com>
2023-04-28 00:20:42 -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
Charles Brunet a5a7b29a66 prevent lib prefix warning from pkg-config 2023-03-16 08:27:06 -04:00
Xavier Claessens 0f67913dee typed_kwargs: Extend since_values and deprecated_values for types 2023-03-04 14:19:27 -05:00
Dylan Baker d0f81fd024 internaltests: Fix tests for /utf-8 removal
Now that we don't insert /utf-8 into the always args for MSVC < 19.00
we need to use a version > 19.00 for testing. This also means that
/Zc:__cplusplus will be added to the always args.
2023-02-08 15:31:58 +05:30
Charles Brunet 3729b6bcd4 remove /utf-8 option when /validate-charset- is present 2023-02-01 11:33:17 -05:00
Xavier Claessens 2961adb8c8 Compilers: Keep ccache and exelist separated
Only combine them in the Compiler base class, this will make easier to
run compiler without ccache.
2022-10-25 17:24:56 -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
Eli Schwartz d3dac3cfb2
compilers: don't export every compiler as a top-level property
This is wasteful and generally unneeded, since code can just use the
compiler they detected instead of manually poking at the internals of
this subpackage.

It also avoids importing an absolute ton of code the instant one runs
`from . import compilers`
2022-09-19 15:19:00 -04:00
Dylan Baker f10967e3f4 unittests: Add additional tests for KwargInfo::since values
The first test is checking the added support for keys as either `dict`
or `list`.

The second checks that a default value which would otherwise trigger a
value_since check doesn't, and that passing the default value explicitly
does.
2022-08-18 21:57:36 -04:00
Zbigniew Jędrzejewski-Szmek 8afdecb039 Reword message in warning
"targetting" is verb-derived adjective, which sort-of-works here, but
makes the whole sentence awkward, because there's no verb. Let's just
use present simple.
2022-05-19 07:18:43 -04:00
Dylan Baker f5d961f127 add message option to since_values and deprecated_values
This allows these two arguments to take a tuple of (version, message),
where the message will be passed to Feature*'s message parameter
2021-12-06 20:06:14 -05:00
Dylan Baker 51845a3a45 unittests/internal: use more subTest 2021-12-06 20:06:14 -05:00
Dylan Baker 930cbdb86d Add deprecated_message and since_message to KwargInfo
For passing an extra message to Feature*

This allows providing a more detailed message.
2021-12-06 20:06:14 -05:00
Dylan Baker b8ba493044 unittests/internal: use mock and subTest
This just makes things a little cleaner, and allows more accurate error
reporting.
2021-12-06 20:06:14 -05:00
Dylan Baker 82136da933 interpreterbase/decorators: Fix types of deprecated_values and since_values
Which shouldn't be Dict[str, str], they should be Dict[_T, str], as nay
value that can be passed to types is valid here.
2021-12-06 20:06:14 -05:00
Jussi Pakkanen 11e26a0fa9
Merge pull request #9599 from dcbaker/submit/typed_kwargs-message-improvements
Improve error messages for typed_kwarg type mismatches in containers
2021-11-27 22:33:15 +02:00
Dylan Baker bfa0c61877 tests: add a test for OptionKey.from_string 2021-11-25 18:14:06 +02:00
Dylan Baker d412f0aff5 unittests: cover cases here two of the same wrong type are provided
We don't want to get something like "expected array[str], but got
array[int | int]", we really want `arrayp[int]`.
2021-11-22 12:27:17 -08:00
Dylan Baker 762c504612 typed_kwargs: use | for type unions, not ,
Python uses this syntax now, as does typescript and other languages
2021-11-22 12:24:33 -08:00
Dylan Baker ecc47d67a9 typed_kwargs: provide better error messages for wrong container types
Currently, if you pass a `[]string`, but the argument expects
`[]number`, then you get a message like `expected list[str] but got
list`. That isn't helpful. With this patch arrays and dictionaries will
both print messages with the types provided.
2021-11-22 12:24:14 -08:00
Christian Clauss a5020857f3 Fix typos discovered by codespell 2021-10-10 16:12:25 -04:00
Xavier Claessens 709d151eb9 typed_kwargs: Fix when ContainerTypeInfo is used in a tuple
info.types could be a tuple like (str, ContainerTypeInfo()). That means
we have to check types one by one and only print error if none of them
matched.

Also fix the case when default value is None for a container type, it
should leave the value to None to be able to distinguish between unset
and empty list.
2021-10-09 18:13:34 -04:00
Eli Schwartz e8a85fa8a2
various python neatness cleanups
All changes were created by running

"pyupgrade --py3-only"

and committing the results. Although this has been performed in the
past, newer versions of pyupgrade can automatically catch more
opportunities, notably list comprehensions can use generators instead,
in the following cases:
- unpacking into function arguments as function(*generator)
- unpacking into assignments of the form x, y = generator
- as the argument to some builtin functions such as min/max/sorted

Also catch a few creeping cases of new code added using older styles.
2021-10-04 16:29:30 -04:00
Xavier Claessens ca866bcfc7 coredata: 0.59.1 -> 0.59.99 is a major version difference
Remove test_minor_version_does_not_reconfigure_wipe() because when run
during dev cycle that test reconfigure with .99 -> .100 which is
considered a major version change now. It is covered by a more efficient
internal test now anyway.

While at it, remove no-op `with Path(self.builddir):` statement, the
intention was clearly to set workdir.

Fixes: #9260
2021-09-21 18:09:12 +02:00
Dylan Baker bd691b847c interpreter: use python dunders instead of lock for unpicklability
This simplifies things for us, as we don't have to have threading
imported for no other reason, and we can remove the
`an_unpicklable_object` from the Interpreter and mesonlib, since there
was only one user of this.
2021-08-31 16:59:37 -07:00
Dylan Baker 042016a555 unittests: add a test to Interpreter is unpicklable
We want this, so let's test it.
2021-08-31 16:59:37 -07:00
Dylan Baker f073c3cfe1 environment: correctly handle cpu value aarch64_be
Fixes #9191
2021-08-30 10:41:12 -07:00
Dylan Baker 78f8a286d0 environment: add ppc -> ppc64 for aix to detect_cpu
This seems like an oversight, that we'd replace ppc with ppc64 on AIX
for the cpu_family, but not for the specific cpu.
2021-08-30 10:38:47 -07:00
Dylan Baker b8cdae7003 unittests: add tests for detect_cpu
Same thing, but for the more specific cases
2021-08-30 10:37:41 -07:00
Dylan Baker 84fff3521a unittests: Add a test case for detect_cpu_family
This should help prevent regressions.
2021-08-30 10:33:28 -07:00
Dylan Baker 11fbaf29d8 interpreter: fix cases of `KwargInfo(..., T, default=None)`
The correct way to mark these is `KwargInfo(..., (T, type(None)))`.
There's also a few cases of `(T, None)` which is invalid, as `None`
isn't a type
2021-08-27 14:54:29 -07:00
Dylan Baker aa895b383c interpreter: Add a helper for checking constrained inputs
This is quite valuable for enum-like inputs, where only a certain set
of values is allowed.
2021-08-27 14:49:23 -07:00
Dylan Baker a450f8c6bc interenaltests: Add some version strings with ansi escapes in them
AS we've run into a few programs using ansi escapes in their version
outputs, we'd like to test them as well.
2021-07-30 10:19:28 -07:00
Xavier Claessens 7eb4c23156 Split run_unittests.py file 2021-07-26 15:19:13 -04:00