Commit Graph

176 Commits

Author SHA1 Message Date
d2fa6d5080 Make custom_target() name argument optional 2021-09-30 12:26:19 -04:00
fa47d8dab0 Merge pull request #9014 from bonzini/mixed-language-link
Use appropriate compiler for the source file for "links" tests with file argument
2021-09-28 17:32:44 +03:00
941b8a6dbc fix message function accepting bools and casting to string
This was allowed by accident despite what meson said would work, because
in python a bool counts as a subclass of int.
2021-09-26 23:23:07 -04:00
c0efa7ab22 interpreter: Add FeatureNew check 2021-09-25 12:44:11 +02:00
6b00c7dc81 Remove helpers.check_stringlist() 2021-09-25 12:44:11 +02:00
d93d01b6c5 interpreter: Introduce StringHolder
Another commit in my quest to rid InterpreterBase from all higher
level object processing logic.

Additionally, there is a a logic change here, since `str.join` now
uses varargs and can now accept more than one argument (and supports
list flattening).
2021-09-25 12:44:11 +02:00
fee5cb697c Merge pull request #9167 from dcbaker/submit/meson-main-type-checking
Add type annotations and type checking to meson main
2021-09-24 23:40:52 +03:00
68c23a6120 Add option to to transpile Cython to C++
This patch adds a new meson built-in option for cython, allowing it to
target C++ instead of C as the intermediate language. This can, of
course, be done on a per-target basis using the `override_options`
keyword argument, or for the entire project in the project function.

There are some things in this patch that are less than ideal. One of
them is that we have to add compilers in the build layer, but there
isn't a better place to do it because of per target override_options.
There's also some design differences between Meson and setuptools, in
that Meson only allows options on a per-target rather than a per-file
granularity.

Fixes #9015
2021-09-24 22:56:46 +03:00
5a69dbe0cb interpreter/mesonmain: remove unreachable code
Now that we have type checking, we can be sure that this code is
unreachable, and remove it.
2021-09-24 10:36:05 -07:00
92b21a0045 interpreter/mesonmain: Fix remaining typing problems and add to run_mypy 2021-09-24 10:36:05 -07:00
d661a0cd96 build: use an object rather than a dict for the dep_manifest
This really is more of a struct than a dict, as the types are disjoint
and they are internally handled, (ie, not from user input). This cleans
some things up, in addition I spotted a bug in the ModuleState where the
dict with the version and license is passed to a field that expects just
the version string.
2021-09-24 10:36:05 -07:00
6c5bfd4c24 interpreter/mesonmain: Add full set of typed_argument guards 2021-09-24 09:48:47 -07:00
27fd7b14e7 interpreter/mesonmain: fix type annotations
Taht should have been converted to build/program module objects, not
interpterter objects
2021-09-24 09:47:38 -07:00
88e5ff0575 interpreter: Add a few missing type annotations
Just enough to make interpreter/mesonmain happy
2021-09-24 09:47:36 -07:00
68eca11cc6 Use -Oz when optimization=s in Clang
-Oz is the appropriate flag to use when you want to produce the smallest
possible binary, and is one would expect when setting optimization to s
or using the minsize build type.
2021-09-21 09:58:48 -07:00
30f24bfa32 dependency: If cached version is outdated, look on system again
Fixes: #9271
2021-09-20 16:42:11 -04:00
e9386e80ae dependencyfallbacks: Use default_options for implicit fallbacks
This removes the warning when using default_options without fallback
kwarg completely because a subproject does not know if the main project
has an implicit fallback or not, so it could set default_options even if
not fallback is available at all.

Fixes: #9278
2021-09-20 13:42:07 -04:00
8596b3bcd1 interpreter: detect and pass compiler to be used for linker tests
Allow using the links method to test that the C++ driver (e.g. g++) can be used to
link C objects.  One usecase is that the C compiler's libsanitizer might not be
compatible with the one included by the C++ driver.

This is theoretically backwards-incompatible, but it should be treated as a
bugfix in my opinion. There is no way in Meson to compile a .c file with the
C++ driver as part of a build target, therefore there would be no reason to
do something like meson.get_compiler(meson.get_compiler('cpp').links(files('main.c')).

Fixes: #7703
2021-09-07 14:18:33 +02:00
af8b55d49b mintro: add installed_plan
Signed-off-by: Filipe Laíns <lains@riseup.net>
2021-09-06 18:10:55 +02:00
5e55a0bb2b interpreter: Add summary of all user defined options
It is a commonly needed information to help debugging build issues. We
already were printing options with non-default value at the end of the
configure but outside of the summary.

Keeping the list of user defined options in the interpreter will also in
the future be useful to use new default value on reconfigure.
2021-09-02 19:38:29 -04:00
d67850b45e dependency: fallback and allow_fallback are mutually exclusive
That used to abort in previous Meson versions but 0.59 stopped
forbidding that by mistake.
2021-09-01 22:29:48 +03:00
43302d3296 interpreter: Introduce BooleanHolder for the bool primitive 2021-09-01 19:17:01 +02:00
43a6b5bd5e interpreter: Remove permissive from _unholder 2021-09-01 19:17:01 +02:00
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
8d92e6d865 interpreter: Add IntegerHolder 2021-08-31 23:01:21 +02:00
4d7031437c pylint: turn on superflous-parens
We have a lot of these. Some of them are harmless, if unidiomatic, such
as `if (condition)`, others are potentially dangerous `assert(...)`, as
`assert(condtion)` works as expected, but `assert(condition, message)`
will result in an assertion that never triggers, as what you're actually
asserting is `bool(tuple[2])`, which will always be true.
2021-08-31 16:28:54 -04:00
1fc3d8608d pylint: enable unnecessary-not check
This finds things like
```python
if not x == 1:
```
which should be
```python
if x != 1:
```
2021-08-31 16:28:54 -04:00
81f5cee218 interpreter: rename EnvironmentVariablesObject -> EnvironmentVariablesHolder
This is more consistent with other Holder classes
2021-08-30 18:05:02 -07:00
43f942be34 interpreterobjects: Use typed_kwargs for EnvironmentVariablesObject 2021-08-30 18:05:02 -07:00
3731e1d8f3 make EnvironmentVariablesObject a proper holder
Currently, EnvironmentVariablesObject is a strange
holder-that's-not-a-holder. This has implicaitons for things that expect
to get an EnvironmentVariables object, as we can't automatically
unholder it, and instead have to to manually do so. Now we can
automatically unholder it, which makes everything much nicer.
2021-08-30 18:05:02 -07:00
d6a1f85248 Allow EnvironmentVariablesObject to be passed an EnvironmentVariables instance 2021-08-30 18:05:02 -07:00
940fc372db interperter/kwargs: narrow type checking
Since the convertor has been added env, we are now only going to be an
EnvironmentVariables object, nothing else.
2021-08-30 18:05:02 -07:00
d87b3c7b3f interpreter/type_checking: Add convertor to env keyword argument
This does the conversion to an EnvironmentVariables, so that the
receiver always gets a EnvironmentVariables object and not a list, dict,
or string
2021-08-30 18:05:01 -07:00
75d2ec9a40 interpreter/type_checking: add a validator to env
Let's start moving the validation out of the interpreter object
2021-08-30 18:04:13 -07:00
ec59cbdf61 interpreter: move 'env' to type_checking 2021-08-30 18:02:56 -07:00
ab773ff9e8 Simplify condition in can_run_host_binaries() 2021-08-30 14:00:54 -04:00
b4bc8464e6 Try to fix NoneType
Because mypy doesn't like the type alias.
2021-08-28 10:38:39 -07:00
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
3f5d80b8bb interpreter: fix name of typed_kwargs for test()
There was a copy-n-paste error here, and it was benchmark instead.
2021-08-27 14:49:52 -07:00
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
4523e9d288 interpreter: fix IndexError when specifying dependency 'include_type'
Exception is thrown when dependency name is empty and when its
'include_type' differs from the default one.

Regression from b6d754a40c.
2021-08-27 19:51:48 +02:00
959e1bb2e3 Add typed_kwargs to add_languages() 2021-08-26 09:51:33 -07:00
e646130ef1 interpreter: Fix dependency(..., static: true) fallback
It should build the fallback subprject with default_library=static and
override the dependency for both static=True and static kwarg not given.

Fixes: #8050.
2021-08-23 10:52:18 -04:00
db04a3f5f2 Fix incomplete guidance on solving sandbox violations
We recommend people use declare_dependency and access it via
dependency() in a parent project. But this requires a wrap file (or to
use override_dependency and an explicit subproject call).

Let's actually mention that.

Fixes #9146
2021-08-22 12:46:57 +03:00
abababfb93 interpreterobjects: fix Test annotations 2021-08-20 18:57:19 +02:00
e2f4126e41 Merge pull request #9126 from dcbaker/submit/rust-use-full-typing
Fully type check rust.bindgen
2021-08-19 18:07:43 +03:00
8c5aa031b5 Add install tags
Fixes: #7007.
2021-08-17 15:19:18 -04:00
272674e792 interpreter/compiler: make helper methods protected 2021-08-16 16:21:51 -07:00
b30dddd4e5 interpreter/compiler: Add type checking for the Compiler object
This adds a full set of `typed_pos_args` and `typed_kwarg` decorations,
as well as fixing all of the typing errors reported by mypy.
2021-08-16 16:21:51 -07:00
bcb5400e34 interpreter/compiler: Add type annotations to TryRunResultHolder 2021-08-16 16:21:51 -07:00