Commit Graph

525 Commits

Author SHA1 Message Date
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
Dylan Baker c9e827a6a1 build: Add a `name` property to CustomTargetIndex
This is needed to make CustomTargetIndex polymorphic with Target derived
classes, and is used in the build module.
2021-08-20 18:57:19 +02:00
Dylan Baker d754ee1a7f build: Fix CustomTarget initializer annotation
the `output` parameter is a string, not an int.
2021-08-20 18:57:19 +02:00
Dylan Baker e08f896802 build: Add a couple of annotations to RunTarget 2021-08-20 18:57:19 +02:00
Dylan Baker cd7d602f33 build: Add type annotations for CustomTarget
Again, this is not complete and is just enough for backend.py. Again,
typing these is complicated massively by the layering violations in the
Target classes and the interpreter.
2021-08-20 18:57:19 +02:00
Dylan Baker b7d5ecc298 build: type get_import_filenames 2021-08-20 18:57:19 +02:00
Dylan Baker f21c50223b build: Add some type annotations to BuildTarget
This is not complete, it's just enough for backend/backend.py. A more
completely typing would be more difficult, especially whithout
untangling the layering violation between the build targets and the
interpreter.
2021-08-20 18:57:19 +02:00
Dylan Baker 225022abf6 build: Add type annotations for ExtractedObjects 2021-08-20 18:57:19 +02:00
Dylan Baker 65d5d9e20c build: Add missing annotations for Build.get_* methods
The underlying attributes are typed properly, but the getters are not
2021-08-20 18:57:19 +02:00
Dylan Baker 3467cf956c build: fix annotation for Build.targets
This really does need to be an OrderedDict, not a MutableMapping, as
there are consumers in the backend that need dictionary only methods.
2021-08-20 18:57:19 +02:00
Dylan Baker e3b2d4ac8b build: add annotation for build.postconf_scripts 2021-08-20 18:57:19 +02:00
Xavier Claessens 8c5aa031b5 Add install tags
Fixes: #7007.
2021-08-17 15:19:18 -04:00
Dylan Baker 6a83f8b9cb build: store global and project args per-machine even when not cross compiling
The problem is what happens in this case:
```meson
add_project_arguments('-DHOST', language : 'c', native : false)
add_project_arguments('-DBUILD', langauge : 'c', native : true)
```

The original meson behavior was that in an host == build configuration
only the `native : false` would be applied. This doesn't really make
sense as in that case the build machine is the host machine, so it is
both the native and non-native machine at once. We changed this so that
the both would be applied in a host == build configuration, but this is
a behavioral change, and needs to be reverted.

Fixes: #9037
2021-08-09 19:44:49 -04:00
Dylan Baker 8a7451e051 build: add a few annotations
I was debugging this code, these were trivial, so I added them.
2021-08-09 19:44:49 -04:00
Dylan Baker bc31c23074 build: Add annotation to CustomTargetIndex.get_subdir 2021-08-03 14:03:33 -07:00
Dylan Baker daf63fc377 build: Add get_subdir() to GeneratedList
It needs this to match the behavior of CustomTarget and
CustomTargetIndex, the later of which doesn't have a subdir attribute,
just `get_subdir()`
2021-08-03 14:03:33 -07:00
Marc-André Lureau 23ea9feee3 build: learn to take CustomTargetIndex as custom_target command
Fix ERROR: Argument <CustomTargetIndex:...>[0]> in "command" is invalid.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-07-27 11:26:05 -07:00
Simon Ser 1f3adc4dbe Add feed arg to custom_target() 2021-06-29 20:54:13 +03:00
Daniel Mensinger 8f7343831b refactor: Refactor BothLibraries logic
This commit introduces a new type of `HoldableObject`: The
`SecondLevelHolder`. The primary purpose of this class is
to handle cases where two (or more) `HoldableObject`s are
stored at the same time (with one default object). The
best (and currently only) example here is the `BothLibraries`
class.
2021-06-26 12:49:35 +02:00
Daniel Mensinger 3f889606c7 Split compiler detection from Environment
This moves all the compiler detection logic into the new
compilers.detect module. This dramatically reduces the size
and complexity of Environment.
2021-06-25 19:34:48 +02:00
Jussi Pakkanen 6e0a0fd1da
Merge pull request #8884 from dcbaker/submit/type-and-annotate-install-functions
Add annotations for the various install_* functions
2021-06-23 01:00:59 +03:00
Daniel Mensinger 0c4dd81c4d
fix: Handling BothLibraries objects (fixes #8907) 2021-06-22 21:09:19 +02:00
Jussi Pakkanen 7588dbc587
Merge pull request #8900 from bonzini/extract-objects-docs
extract_objects: fixes, tests and documentation for using the result in a custom_target
2021-06-22 20:39:58 +03:00
Dylan Baker d636b92c1a install_*: FileMode doesn't need to be None
There's no reason to allow None into the backend, it already has code to
check that all of the values of the FileMode object are None, so let's
use that, which is much simpler all the way down.
2021-06-22 09:13:41 -07:00
Dylan Baker f2ad5e377e backend: Headers.install_subdir is allowed to be None
But we don't properly handle that.
2021-06-22 09:12:54 -07:00
Paolo Bonzini bd75e0398f extract_objects: skip headers when building custom_target command line
As seen in the testcase, passing objects to custom_target does not work
if headers are passed extract_objects(), or if extract_all_objects() is used
and the sources include any header files.  To fix this, use the code that
already exists for unity build to filter out the nonexistent ".h.o" files.
This already gives for free the handling of genlist, which was mentioned
in a TODO comment.
2021-06-22 15:56:46 +02:00
Daniel Mensinger 7c757dff71 holders: Fix the remaining code to respect the holder changes 2021-06-18 23:48:33 +02:00
Daniel Mensinger 34c28dc92c holders: remove unholder 2021-06-18 23:48:33 +02:00
Daniel Mensinger 84a3e459a8 holders: Introduce BothLibraries 2021-06-18 23:48:33 +02:00
Daniel Mensinger 66b32a4591 holders: Introduce HoldableObject 2021-06-18 23:48:33 +02:00