Commit Graph

24 Commits

Author SHA1 Message Date
Paolo Bonzini 7c20890a05 sourceset: reorder fields in SourceSetRule
Keep conditions first, then "if true" fields, and the if_false sources last.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-03-14 10:27:38 -07:00
Paolo Bonzini 94be5b8b48 sourceset: document fields of SourceSetRule
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-03-14 10:27:38 -07:00
Paolo Bonzini 6dd04ce57c sourceset: improve typing of SourceSetRule
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-03-14 10:27:38 -07:00
Paolo Bonzini 9d42e58ea2 sourceset: reinstate extra_deps
Dependencies in the "if_true" keyword argument do not prevent the
sources from being used; in other words, they work just like dependencies
with "disabler: false".

However, this was broken in commit ab0ffc6a2 ("modules/sourceset: Fix
remaining typing issues", 2022-02-23) which changed logic instead of
just fixing typing issues.  This was likely an attempt to avoid using
"dependencies.Dependency" after the "dependencies" field was declared,
but it also broke QEMU.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-03-14 10:27:38 -07:00
Paolo Bonzini 076855c22f sourceset: rename "dependencies" fields to deps
The dependencies field clashes with the dependencies module, so that
mypy interprets "dependencies.Dependency" as a "Dependency" attribute
of the "dependencies" field.

Rename the field to something else, so that it does not clash.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-03-14 10:27:38 -07:00
Eli Schwartz 880d5000b2
sourceset module: fix minor regression in making sourcesets immutable
In commit c0be7e05b0 the setting of merged
sourcesets as immutable in a loop accidentally got dedented, and only
applied to the last loop iteration.
2022-02-27 15:20:34 -05:00
Dylan Baker 57c8e1a780 run_mypy: add sourceset module 2022-02-23 10:18:34 -08:00
Dylan Baker ab0ffc6a22 modules/sourceset: Fix remaining typing issues 2022-02-23 10:18:34 -08:00
Dylan Baker c0be7e05b0 modules/sourceset: use typed_kwargs for all functions
removing permittedKwargs usage
2022-02-23 10:18:34 -08:00
Dylan Baker 5dc355105a modules/sourceset: Use typed_pos_args 2022-02-23 10:18:34 -08:00
Dylan Baker d39bb133f0 modules/sourceset: add a few super easy type annotations 2022-02-23 10:18:34 -08:00
Dylan Baker 8712afd35e modules/sourceset: sort imports 2022-02-23 10:18:34 -08:00
Dylan Baker 5074e2d3b5 interpreter: replace ConfigurationDataObject with ConfigurationDataHolder
This is much cleaner, and more in line with the way we handle
interpreter objects in modern meson practice
2022-01-18 17:53:29 -05: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
Xavier Claessens 2e02ef6592 modules: Add methods dict everywhere
This fix calling random internal methods from meson.build as long as
they were not prefixed by underscore.
2021-05-28 15:17:10 -04:00
Xavier Claessens 3340284805 modules: Stop using InterpreterObject
Custom objects returned by modules must be subclass of ModuleObject and
have the state argument in its methods.

Add MutableModuleObject base class for objects that needs to be deep
copied on assignation.
2021-05-28 15:17:10 -04:00
Xavier Claessens 723c5227a4 modules: Remove snippet methods
The only advantage they have is they have the interpreter in arguments,
but it's already available as self.interpreter. We should discourage
usage of the interpreter API and rely on ModuleState object instead in
the future.

This also lift the restriction that a module method cannot add build
targets, but that was not enforced for snippet methods anyway (and some
modules were doing it) and it's really loose restriction as it should
check for many other things if we wanted to make it consistent.
2021-05-28 15:17:10 -04:00
Eli Schwartz 6a0fabc647
mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04 17:16:11 -05:00
Paolo Bonzini fc9b0cbb7f stabilize sets that are converted to lists
The order of elements in sets cannot be relied upon, because the hash
values are randomized by Python.  Whenever sets are converted to lists
we need to keep their order stable, or random changes in the command line
cause ninja to rebuild a lot of files unnecessarily.  To stabilize them,
use either sort or OrderedSet.  Sorting is not always applicable, but it
can be faster because it's done in C and it can produce slightly nicer
output.
2020-11-15 14:21:31 +01:00
Michael c53b637959 switch python2 %s for python3 .format 2020-04-21 00:16:21 +03:00
Marc-André Lureau 8ba1405742 sourceset: add all_dependencies() method
'if_true' sources should be built with their dependencies, as
illustrated by test case change.

Ideally, I think we would want only the files with the dependencies to
be built with the flags, but that would probably change the way
sourceset are used.
2019-08-04 21:44:52 +03:00
Marc-André Lureau 940ebd658b sourceset: fix using FeatureCheck decorators
The feature check facilities need to have access to subproject.
2019-08-04 21:44:52 +03:00
Paolo Bonzini d894c48660 new module "sourceset" to match source file lists against configuration data
In QEMU a single set of source files is built against many different
configurations in order to generate many executable.  Each executable
includes a different but overlapping subset of the source files; some
of the files are compiled separately for each output, others are
compiled just once.

Using Makefiles, this is achieved with a complicated mechanism involving
a combination of non-recursive and recursive make; Meson can do better,
but because there are hundreds of such conditional rules, it's important
to keep meson.build files brief and easy to follow.  Therefore, this
commit adds a new module to satisfy this use case while preserving
Meson's declarative nature.

Configurations are mapped to a configuration_data object, and a new
"source set" object is used to store all the rules, and then retrieve
the desired set of sources together with their dependencies.

The test case shows how extract_objects can be used to satisfy both
cases, i.e. when the object files are shared across targets and when
they have to be separate.  In the real-world case, a project would use
two source set objects for the two cases and then do
"executable(..., sources: ... , objects: ...)".  The next commit
adds such an example.
2019-05-22 12:09:09 +02:00