Commit Graph

554 Commits

Author SHA1 Message Date
Jussi Pakkanen bd509d11a5
Merge pull request #9531 from dcbaker/submit/interpreter-more-typing
More use of typed_* in the interpreter module
2021-11-27 21:44:41 +02:00
Mike Gilbert 91a099f3a7 Remove premature return in BuildTarget.check_module_linking()
We want to loop over all link_targets to update
backwards_compat_want_soname if necessary.

Fixes: ec9bdc6edb17d1d9da5df2d6525025242c119f3a
2021-11-27 20:16:34 +02:00
Nirbheek Chauhan af5993fffd shared_module: Add soname when used as a link target
Emit a detailed deprecation warning that explains what to do instead.
Also add a unittest.

```
DEPRECATION: target prog links against shared module mymod, which is incorrect.
             This will be an error in the future, so please use shared_library() for mymod instead.
             If shared_module() was used for mymod because it has references to undefined symbols,
             use shared_libary() with `override_options: ['b_lundef=false']` instead.
```

Fixes https://github.com/mesonbuild/meson/issues/9492
2021-11-24 23:18:53 +05:30
Dylan Baker f29b54dfe4 build|backend: Fix some type annotations
These currently say the take `Target`, but the really take
`BuildTarget | CustomTarget | CustomTargetIndex`.
2021-11-24 02:23:57 +05:30
Dylan Baker 75d163f56d build: TestSetup.exe_wrapper doesn't need to be optional
It works fine as-is with an empty list, and since that's easier to get
using our typed_kwargs, and thus is what we're passing, go ahead and
simplify the class to only take a list of strings.
2021-11-22 11:28:43 -08:00
Eli Schwartz dbb109703e
convert more mlog.deprecation into FeatureDeprecated 2021-11-20 20:48:29 -05:00
Eli Schwartz 1104b82137 fix custom_target with install: true and no install_dir, crashing
It's supposed to emit an error message, but instead it did a traceback.
It used to be, if no install_dir was specified then it was simply not in
kwargs, but due to typed_kwargs it will now be there, but not have
viable contents, so the dict membership check got skipped.

Fixes #9522
2021-11-02 19:56:10 -07:00
Dylan Baker 526b6b763a build: Add type annotations to BuildTarget.get_all_link_deps 2021-11-01 12:24:25 -07:00
Dylan Baker ac02521954 build: Add annotations to CustomTarget.extra_depends 2021-11-01 12:24:25 -07:00
Dylan Baker b572a7980e build: Add a get_command method to Executable
Since Executable can be used in places where ExternalProgram is, simply
having a wrapper that gives them the same API is pretty useful.
2021-11-01 12:24:25 -07:00
Dylan Baker 68c1669ae6 build: IncludeDirs extend `to_string_list` method to handle builddir 2021-11-01 12:24:25 -07:00
Dylan Baker 6472f013a1 build: Add type annotations for BuildTarget.include_dirs
The gnome module uses these, so to be able to fully type that we need
this.
2021-11-01 12:24:25 -07:00
Jussi Pakkanen c1b686e395 Make environment objects hash deterministically. 2021-10-29 22:47:06 +03:00
Jussi Pakkanen af85738daf
Merge pull request #9375 from dcbaker/submit/windows-module-typing
Typing for the Windows module
2021-10-29 22:45:04 +03:00
Eli Schwartz 8947352889 fix various flake8 whitespace errors 2021-10-27 09:51:52 -04:00
Xavier Claessens 928078982c Add --vsenv command line option and active VS only when needed 2021-10-10 23:15:18 +03:00
Christian Clauss a5020857f3 Fix typos discovered by codespell 2021-10-10 16:12:25 -04:00
Dylan Baker 0d52a6161a build: Add missing type annotation 2021-10-09 21:34:54 -07:00
Xavier Claessens 2628ce576c Add support for module options 2021-10-08 17:47:35 -04:00
Eli Schwartz 108bd996ee
add install_emptydir function
This replaces the absolute hack of using

```
install_subdir('nonexisting', install_dir: 'share')
```

which requires you to make sure you don't accidentally or deliberately
have a completely different directory with the same name in your source
tree that is full of files you don't want installed. It also avoids
splitting the name in two and listing them in the wrong order.

You can also set the install mode of each directory component by listing
them one at a time in order, and in fact create nested structures at
all.

Fixes #1604
Properly fixes #2904
2021-10-08 14:35:00 -04:00
Andres Freund 6b8f10cf6b backend/vs: Generate dependencies for CustomTargetIndex for a CustomTarget.
Test & fix.
2021-10-04 22:42:27 -04:00
Andres Freund a1542720f4 Record build in BuildTarget.link_depends, not just output of targets.
To be able to handle link_depends in backends that do not just operate on a
file basis like ninja, information about the targets, not just their output is
required.
2021-10-04 22:34:57 -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
Dylan Baker c3c30d4b06 interpreter: Use typed_kwargs for func_custom_target
This does not convert the build side, or remove any of the checking it
does. We still need that for other callers of custom target. What we'll
do for those is add an internal interface that defaults things, then
we'll be able to have those callers do their own validation, and the
CustomTarget validation machinary can be removed.

Fixes #9096
2021-09-30 21:01:38 +02:00
Dylan Baker bb706231bd build: Prepare CustomTarget.process_kwargs to co-exist
We still need this to co-exist as long as there are interfaces for
CustomTarget other than `func_custom_target`, this gets us there.
2021-09-30 21:01:38 +02:00
Dylan Baker 7e417ac0fa build: Allow `Dict[OptionKey, str` in parse_overrides
We really want to move all of this option handling into the interpreter
through the typed_kwargs, this is the first step to that
2021-09-30 21:01:38 +02:00
Dylan Baker d25349e8cf build: Use isinstance(other, Target) instead of hasattr
In the comparison methods of Target. There are several problems with the
old implementation:
1. It's not idiomatic
2. It can match on things that It shouldn't (like a Compiler, which has
   a `get_id() -> str` method, but not one that we should compare with
   Targets
3. It confuses mypy, which doesn't handle hasattr
2021-09-30 21:01:38 +02:00
Dylan Baker d7bb0acbe3 build: Add type annotations to AliasTarget
It's just a RunTarget with one default value overriden
2021-09-30 21:01:38 +02:00
Dylan Baker 377c23388f build: drop unnecissary method from RunTarget 2021-09-30 21:01:38 +02:00
Dylan Baker 0a6fdd4900 build: Fully annotate RunTarget 2021-09-30 21:01:38 +02:00
Dylan Baker f9b14dc570 build: Add full type annotations to CommandBase 2021-09-30 21:01:38 +02:00
Dylan Baker c11eb86995 build: add forward delcarations to CommandBase class
It would probably be better if CommandBase had an initializer so it
could set the depend_files and dependencies attributes itself, but this
will make mypy happier.
2021-09-30 21:01:38 +02:00
Dylan Baker d80cfa27c9 build: Add a couple of obvious annotations to RunTarget 2021-09-30 21:01:38 +02:00
Xavier Claessens d2fa6d5080 Make custom_target() name argument optional 2021-09-30 12:26:19 -04:00
Daniel Mensinger 6b00c7dc81 Remove helpers.check_stringlist() 2021-09-25 12:44:11 +02:00
Dylan Baker 64c267c49c compilers: Add default search path stdlib_only_link_flags
This should be done in all cases of language_stdlib_only_link_flags, but
I don't have access to all of the compilers to test it.

This is required in cases where object files created by gfortran are
linked using another compiler with a differen default search path, such
as gfortran and clang together.
2021-09-25 00:18:22 +03:00
Jussi Pakkanen 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
Dylan Baker 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
Dylan Baker 9795323b86 pylint: check for duplicate imports
I ran into one of these from LGTM, and it would be nice if pylint could
warn me as part of my local development process instead of waiting for
the CI to tell me.
2021-09-24 10:36:05 -07:00
Dylan Baker 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
Dylan Baker c8d85575c0 build: Add annotation to dist_Scripts and install_scripts 2021-09-24 09:44:40 -07:00
Dylan Baker 343b40f67a build: add some missing type annotations
So that we can get interpreter/mesonmain.py type safe.
2021-09-24 09:44:40 -07:00
Filipe Laíns af8b55d49b mintro: add installed_plan
Signed-off-by: Filipe Laíns <lains@riseup.net>
2021-09-06 18:10:55 +02:00
Eli Schwartz 10cfc321f8
fix repr for alias_target
It has no command, so you cannot try printing it or it explodes with

IndexError: list index out of range
2021-09-01 15:42:39 -04:00
Dylan Baker 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
Dylan Baker 8c90140f2b build: add ability to set initial value of EnvironmentVariables
Which is useful as we move the validation out of the the
EnvironmentVariablesObject
2021-08-30 18:02:56 -07:00
Dylan Baker aee2325335 build: Fully annotate EnvironmentVariables 2021-08-30 18:02:56 -07:00
Dylan Baker b791b47c3b build: add annotations for DependencyOverride 2021-08-27 14:49:23 -07:00
Dylan Baker 3a45c5a7ce build: Add type annotations to Target.get_debug_filename 2021-08-20 18:57:19 +02:00
Dylan Baker e938ffb763 build: Add annotations to the CustomTargetIndex class
These are not complete, and are just enough for backends/backends.py
2021-08-20 18:57:19 +02:00