Commit Graph

83 Commits

Author SHA1 Message Date
Eli Schwartz dd31891c1f more f-strings too complex to be caught by pyupgrade 2021-07-05 17:55:04 +03:00
Eli Schwartz c4f5f6364e pyupgrade 2021-07-05 17:55:04 +03:00
Tristan Partin 6f3f43bb2d Flatten test suite value
This behavior is more inline with the rest of Meson
2021-07-02 21:58:22 +03:00
Daniel Mensinger 971a0b1775 fix: get_variable default variables are not ObjectHolders (fixes #8936) 2021-07-02 17:14:44 +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 0c4dd81c4d
fix: Handling BothLibraries objects (fixes #8907) 2021-06-22 21:09:19 +02:00
Daniel Mensinger 5cd9f88d6c fix: Ensure that build targets have all methods from ExternalProgram
As a side-effect from #8885 `find_program()` returns now `Executable`
objects when `meson.override_find_program` is called with an
executable target. To resolve this conflict the missing methods
from `ExternalProgram` are added to `BuildTarget`.
2021-06-21 20:19:06 +03:00
Daniel Mensinger 7c757dff71 holders: Fix the remaining code to respect the holder changes 2021-06-18 23:48:33 +02:00
Daniel Mensinger 84a3e459a8 holders: Introduce BothLibraries 2021-06-18 23:48:33 +02:00
Daniel Mensinger c2c7f7c9d7 holders: Ensure that InterpreterBase is the sole instance for (un)holderifying 2021-06-18 23:48:33 +02:00
Daniel Mensinger 6879e84c48 holders: Move get_version from directly to ExternalProgram 2021-06-18 23:48:33 +02:00
Daniel Mensinger 66b32a4591 holders: Introduce HoldableObject 2021-06-18 23:48:33 +02:00
Daniel Mensinger d601227cb2 interpreter: Add FileHolder and remove specical case for File 2021-06-18 23:48:33 +02:00
Daniel Mensinger 63ade7d937 interpreter: Add a new MesonInterpreterObject for non-elementary objects 2021-06-18 23:48:33 +02:00
Daniel Mensinger 2b09af834a interpreter: Refactor ObjectHolder to extend InterpreterObject 2021-06-18 23:48:33 +02:00
Daniel Mensinger 2c08e55f85 typing: Import missing classes in interpreterobjects.py 2021-06-18 23:48:33 +02:00
Dylan Baker ec48dbd2d6 interpreterobjects: Clean up GeneratedListHolder
Remove an unused method (that didn't work before this series), and
remove the ability to pass a Generator to the GeneratedListHolder, it's
never used and it's weird and not the way Meson generally works now.
While we're here, finish the type annotations.
2021-06-15 12:48:53 -07:00
Dylan Baker c422621317 interpreterobjects|build: use typed_kwargs for generator.process 2021-06-15 12:48:53 -07:00
Dylan Baker 5952dc9818 interpreter|build: use typed_pos_args and unholder in the interpreter
For generator.process_files. Just cleaner and nicer
2021-06-15 12:48:53 -07:00
Dylan Baker 491c756dc9 interpreter: use typed_kwargs for func_generator
Do the type checking in a nice tidy way
2021-06-15 12:48:53 -07:00
Dylan Baker 2ac9b32391 interpreter: Do not create Generator in GeneratorHolder
This is an odd pattern, not the way most Holders work, and would be
problematic if a method wanted to return a Generator.
2021-06-15 12:48:53 -07:00
Dylan Baker 2bc7a1b3da modules/qt: fully annotate and check qt.has_tools 2021-06-15 12:36:05 -07:00
Jussi Pakkanen a4a61b6bf8
Merge pull request #8512 from bonzini/feature-methods
Utility methods for feature objects
2021-06-08 12:37:25 +03:00
Paolo Bonzini a87e32d181 interpreter: add feature.disable_auto_if()
Add a method to downgrade an option to disabled if it is not used.
This is useful to avoid unnecessary search for dependencies;
for example

    dep = dependency('dep', required: get_option('feature').disable_auto_if(not foo))

can be used instead of the more verbose and complex

    if get_option('feature').auto() and not foo then
      dep = dependency('', required: false)
    else
      dep = dependency('dep', required: get_option('feature'))
    endif

or to avoid unnecessary dependency searches:

  dep1 = dependency('dep1', required: get_option('foo'))
  # dep2 is only used together with dep1
  dep2 = dependency('dep2', required: get_option('foo').disable_auto_if(not dep1.found()))
 ```

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-06-08 10:18:12 +02:00
Paolo Bonzini 2f2d99e1d8 interpreter: add feature.require()
Add a method to perform a logical AND on a feature object.  The method
also takes care of raising an error if 'enabled' is ANDed with false.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-06-08 10:18:12 +02:00
Dylan Baker 6f562ed734 interpreterobjects: Fix type annotation for CustomTargetHolder 2021-06-04 20:10:05 -07:00
Paolo Bonzini 5298d8eaf1 interpreter: wrap access to Feature value
This will allow adding "forced-off" Feature objects in the next patch.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-05-31 16:01:57 +02:00
Paolo Bonzini 08a8043f19 interpreter: add feature.allowed()
This method simplifies the conversion of Feature objects to booleans.
Often, one has to use the "not" operator in order to treat "auto"
and "enabled" the same way.

"allowed()" also works well in conjunction with the require method that
is introduced in the next patch.  For example,

  if get_option('foo').require(host_machine.system() == 'windows').allowed() then
    src += ['foo.c']
    config.set10('HAVE_FOO', 1)
  endif

can be used instead of

  if host_machine.system() != 'windows'
    if get_option('foo').enabled()
      error('...')
    endif
  endif
  if not get_option('foo').disabled() then
    src += ['foo.c']
    config.set10('HAVE_FOO', 1)
  endif

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-05-31 16:01:57 +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
Xavier Claessens 501d7cf01c interpreter: flatten environment() initial values
Turns out listify() flattens by default, but stringlistify() cannot
flatten... How do I realize this only now?

Fixes: #8727
2021-05-13 10:38:17 +03:00
Xavier Claessens 558a7bc6ff interpreter: Move to its own folder and split it 2021-04-01 14:26:33 -04:00