Commit Graph

11001 Commits

Author SHA1 Message Date
Dylan Baker a7357887c7 docs: fix issues with the cython docs 2021-06-08 20:21:48 -07:00
Eli Schwartz ed19eb2443
document the enhancement to the Fs module permitting File arguments
Add a release notes snippet too!
2021-06-08 16:52:48 -04:00
Xavier Claessens f2b678ef68
doc: Fix link to Commands.md 2021-06-08 11:02:56 -04: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
Dylan Baker 98efec5c2b interpreter: make helper methods protected
They really aren't meant to be called outside of the interpreter itself,
so don't expose them as public
2021-06-08 11:00:55 +02:00
Dylan Baker bf656ce0ec interpreter: Add type annotations for the add_*_arguments helpers
internally these all used a set of shared heleprs, add type annotations
for those as well
2021-06-08 11:00:55 +02:00
Dylan Baker 6eff0c3f8c build: fix type annotations fo project_*_args
These are Dict[str, Dict[str, List[str]]], unlike global arguments
because they must store the information per subproject
2021-06-08 11:00:55 +02:00
Dylan Baker 3f9a81e7f1 interpreter: use typed_kwargs for the add_*_arguments family
This makes use of the new convertor and validator arguments, so that we
can check that the languages passed are in fact vaild, and then convert
the native boolean into a MachineChoice internally.
2021-06-08 11:00:55 +02:00
Dylan Baker 3e998527a3 interpreter: use typed_pos_args for add_*_args
This just replaces stringArgs with the typed_pos_args, and it's better
error message.
2021-06-08 11:00:55 +02:00
Dylan Baker 6ab78b5979 intperperterbase: Add a convertor keyword argument
This is meant to allow simple type conversions to happen before the
interpreter function is called. This should simplify some cases like the
"native" keyword arugment that are booleans in the Meson DSL, but an
Enum in the implementation
2021-06-08 11:00:55 +02:00
Dylan Baker fb385728df interpreterbase: Add validator keyword argument to typed_kwargs
This attribute is a callable that returns a string if the value is
invalid, otherwise None. This intended for cases like the `install_*`
function's `install_mode` paramater, which is either an int or the
string "preserve", which allows us to do nice things like:

```python

class Kwargs(TypedDict):

    install_mode: T.Union[int, T.Literal['preserve']]

@typed_kwargs(
  'foo', KwargInfo('install_mode', ...,
  validator=lambda x: None if isinstance(x, int) or x == 'preserve' else 'must be the literal "preserve"),
)
def install_data(self, node, args, kwargs: 'Kwargs'):
  ...
```

In this case mypy *knows* that the string is preserve, as do we, and we
can simply do tests like:
```python
if kwargs['install_mode'] == 'preserve':
   ...
else:
   # this is an int
```
2021-06-08 11:00:55 +02:00
Dylan Baker 5d81392c67 make all arguments to KwargInfo except name and type keyword only
To make them easier to understand in practice
2021-06-08 11:00:55 +02:00
Dylan Baker 4dc3f2af63 run_unittests.py: Use mock for monkey patching
it's what mock is for afterall
2021-06-08 11:00:55 +02:00
Paolo Bonzini 6497e52035 run_unittests.sh: fix Python DeprecationWarning
Fix the following Python error:

  D:\a\1\s\run_unittests.py:6654: DeprecationWarning: invalid escape sequence \
    self.assertEqual(libhello_nolib.get_pkgconfig_variable(escaped_var, {}), hello world)

Use a raw string literal.
2021-06-08 10:18:12 +02: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
Eli Schwartz 48ebfa9a99
another pyupgrade pass 2021-06-07 16:51:47 -04:00
Eli Schwartz 998076a192
upgrade percent formatted strings pyupgrade did not catch 2021-06-07 16:51:47 -04:00
Eli Schwartz 3eb1da1fa2
condense lines 2021-06-07 16:51:47 -04:00
Eli Schwartz 2c71b63e77
more f-strings everywhere
pyupgrade didn't catch many .format() methods which were too complex
(e.g. multiline or applied to templates rather than string literals)
2021-06-07 16:51:47 -04:00
Jussi Pakkanen 40e8a67a83
Merge pull request #8706 from dcbaker/wip/2021-04/cython-language
1st class Cython language support
2021-06-07 23:29:30 +03:00
Jussi Pakkanen d53ea7da2d Fix macpkg generator import path. [skip ci] 2021-06-07 21:29:01 +03:00
Dylan Baker 0bc18f26a2 cython: Add an option for selecting python 3 vs python 2 output 2021-06-07 09:25:32 -07:00
Dylan Baker 0cb05004ca docs: Add cython docs 2021-06-07 09:25:32 -07:00
Dylan Baker a2fc2e2165 cython: Add a test for generated files 2021-06-07 09:17:40 -07:00
Dylan Baker 74ed27f776 cython: add 1 basic test 2021-06-07 09:17:40 -07:00
Dylan Baker b9f33c2380 Add C compiler when using Cython
Since cython transpiles to C.
2021-06-07 09:17:39 -07:00
Dylan Baker ec4d8143df ninjabackend: generate cython compilation rules 2021-06-07 09:16:19 -07:00
Dylan Baker 80cdbe41bd ninjabackend: cython doesn't use a linker 2021-06-07 09:16:19 -07:00
Dylan Baker 4d1cbd1b8a compilers: Add cython file suffixes 2021-06-07 09:16:19 -07:00
Dylan Baker cf17ef3867 environment: Add detection logic for cython 2021-06-07 09:16:19 -07:00
Dylan Baker edf1a21722 compilers: Expose Cython compiler 2021-06-07 09:16:18 -07:00
Dylan Baker e9681b463d hack: compilers/cython: hardcode python 3 not 2 2021-06-07 09:15:13 -07:00
Dylan Baker 79e50caa7f compilers: Add a cython Compiler 2021-06-07 09:15:13 -07:00
Dylan Baker b6eb5c231c build: Add type annotations for Generator
They're not 100% complete, but it's mostly there.
2021-06-07 09:15:09 -07:00
Daniel Mensinger 30e329aac9 typing: Fully annotate dependencies.framework 2021-06-06 21:30:02 +03:00
Daniel Mensinger 25875ae0d3 typing: Fully annotate dependencies.{detect,factory} + some other fixes 2021-06-06 20:30:24 +03:00
Daniel Mensinger 71906c4bf8 typing: Fully annotate dependencies.cmake 2021-06-06 20:02:48 +03:00
Daniel Mensinger 125566b329 typing: Fully annotate dependencies.platform 2021-06-06 19:40:35 +03:00
Daniel Mensinger 96473085e0 typing: Fully annotate dependencies.dub 2021-06-06 19:40:35 +03:00
Daniel Mensinger 6798bc8146 typing: Fully annotate dependencies.pkgconfig 2021-06-06 01:34:49 +03:00
Jussi Pakkanen d13999f5b4
Merge pull request #8796 from xclaesse/wrapdbv2
wrap: Port to v2 protocol
2021-06-06 01:31:11 +03:00
Xavier Claessens 769fd50373 docs: Generate a table of all wrapdb releases
wrapdb CI will trigger Meson's CI to regenerate the list when
releases.json is updated.
2021-06-05 17:01:34 -04:00
Daniel Mensinger 240434b167 typing: Fully annotate dependencies.cuda 2021-06-05 12:35:48 +02:00
Daniel Mensinger 27bb5f536a typing: mlog use StringProtocol 2021-06-05 12:35:48 +02:00
Daniel Mensinger 969ee9d85b typing: Fully annotate dependencies.configtool 2021-06-05 11:57:01 +02:00
Daniel Mensinger 1d0bd562f1 typing: Fully annotate dependencies.coarrays 2021-06-05 11:57:01 +02:00
Dylan Baker e0f62d1812 dependencies/detect: Add type annotations to find_external_dependency 2021-06-04 20:10:05 -07:00
Dylan Baker 6f562ed734 interpreterobjects: Fix type annotation for CustomTargetHolder 2021-06-04 20:10:05 -07:00
Dylan Baker ff0fd7d44c build: Add a type annotation to CustomTarget 2021-06-04 20:10:05 -07:00