Commit Graph

474 Commits

Author SHA1 Message Date
Dylan Baker 11f9638035 build: replace kwargs in CustomTarget initializer
Because we don't want to pass the Interpreter kwargs into the build
layer. This turned out to be a mega commit, as there's really on elegant
way to make this change in an incremental way. On the nice side, mypy
made this change super easy, as nearly all of the calls to
`CustomTarget` are fully type checked!

It also turns out that we're not handling install_tags in custom_target
correctly, since we're not converting the boolean values into Optional
values!
2022-01-28 15:53:20 -05:00
Dylan Baker 5d31735c1e modules/gnome: Allow gdbus_annotations to take an empty list again
This was allows up to 0.61.0 (including with the initial type
annotations), but was accidentally broken by fixes for other bugs in
0.61.1.

Fixes: #9883
2022-01-27 17:22:41 -05:00
Bilal Elmoussaoui dd4e712024 gnome: Fix gtk4 pkgconfig name 2022-01-26 21:31:20 -05:00
Dylan Baker acef5a9762 modules/gnome: make some methods static
Since they don't use the instance or class state, they should be static
methods.
2022-01-18 21:58:24 -05:00
Dylan Baker d96bc73b99 modules/gnome: fix remaining typing errors
Which is one incorrect type annotation, and a couple of instances of
concatenating lists of unlike types. List being invariant is super
annoying.
2022-01-18 21:58:24 -05:00
Dylan Baker 99c835b2b9 modules/gnome: fix annotation to type that isn't defined 2022-01-18 21:58:24 -05:00
Dylan Baker 26722f8e44 modules/gnome: fix _get_build_args type annotations 2022-01-18 21:58:24 -05:00
Dylan Baker 0dd720a014 modules/gnome: fix _make_typelib_target types 2022-01-18 21:58:24 -05:00
Dylan Baker 68e684d51f modules/gnome: Fix typing with _get_dependencies_flags and
_get_gir_target_deps

The typing issues with these are tightly intertwined, so it didn't
really make sense to solve them independently
2022-01-18 21:58:24 -05:00
Dylan Baker a848dd3cce modules/gnome: fix issues with _make_gir_target 2022-01-18 21:58:24 -05:00
Dylan Baker fcf78ceb7b modules/gnome: fix declared type of list 2022-01-18 21:58:24 -05:00
Dylan Baker f85629e374 modules/gnome: use T.Sequence instead of T.List
Which is pretty much necessary to make anything involving unions of
lists work
2022-01-18 21:58:24 -05:00
Dylan Baker cd6e2c85a7 modules/gnome: use itertools.chain instead of list concatenation
This is better as it avoids building unnecessary lists, and two fixes
the typing issue from concatenating lists of different types.
2022-01-18 21:58:24 -05:00
Dylan Baker 41fe51b36e modules/gnome: ignore the return type of _get_dep
This is hard to fix, and it's really doing something bad anyway. But we
know it's right, so just tell mypy to not worry about it.
2022-01-18 21:58:24 -05:00
Dylan Baker 4048c71d6d modules/gnome: fix type annotations and issues with _gather_typelib_includes_and_update_depends
There is the problem of the annotations themselves, then there is
the problem with depends being mutated. The mutation side effect is a
problem in itself, but there's also the problem that we really want to
use Sequence, which isn't mutable.
2022-01-18 21:58:24 -05:00
Dylan Baker dacba7a83d modules/gnome: define and annotate all instance variables in the initializer 2022-01-18 21:58:24 -05:00
Dylan Baker 6b272973e0 dependencies: don't pass kwargs from get_pkgconfig_variable
This is a layering violation, we're relying on the way the interpreter
handles keyword arguments. Instead, pass them as free variables,
destructuring in the interpreter
2022-01-18 17:53:29 -05:00
Eli Schwartz 96d0005744 gnome.genmarshal: restore the ability to pass sources as Files objects
It used to support:
- a single string
- an array of anything

And as long as CustomTarget supported it too, everything worked fine.
So, a `files('foo')` worked but a `files('foo')[0]` did not, which is
silly... and it's not exactly terrible to use files() here, the input is
literally a list of source files.

Fixes building gnome-terminal
Fixes #9827

Test updated by Nirbheek Chauhan <nirbheek@centricular.com>
2022-01-15 23:50:14 +05:30
Eli Schwartz bda11fe25d gome.gdbus_codegen: fix annotations argument for multiple annotations, harder
The original attempted fix only allowed configuration to succeed, but
not building. It was modeled based on the gdbus-codegen documentation,
which states:

  --annotate WHAT KEY VALUE WHAT KEY VALUE WHAT KEY VALUE
                        Add annotation (may be used several times)

which clearly indicates that gdbus-codegen accepts an --annotate flag
that is followed by a multiple of 3 values, despite this not actually
working.

The manpage actually contradicts the --help text:

   --annotate ELEMENT KEY VALUE
       Used to inject D-Bus annotations into the given XML files. []

... and gives examples that use multiple --annotate flags each with 3
arguments.

To better understand what meson is supposed to do here, we should look
at ef52e60936, which ported to
typed_kwargs. There is actually a big chunk of code to handle
annotations that got completely dropped, leading with a comment (that
did not get dropped): "they are a list of lists of strings..."

Reimplement this logic inside a validator/converter for the annotations
kwarg container:

- do not listify, we don't accept `annotations: ''` and listify is
  supposed to be for when either x or list[x] is valid

- go back to checking for a list of exactly 3 values

- allow a list of the aforementioned, in the traditionally expected
  form:

  [
    ['foo1', 'foo2', 'foo3'],
    ['bar1', 'bar2', 'bar3'],
  ]

- pass one --annotate flag per 3-value-list

And add some better error reporting for the cause of errors when
processing lists of lists.
2022-01-12 18:55:25 -08:00
Eli Schwartz 71540d1841 fix typo in error message 2022-01-11 22:28:00 -08:00
Eli Schwartz 63593a5528 gnome.gdbus_codegen: allow File objects as XML file
As soon as we check for args[1] we declare it is of type FileOrString,
and the additional ones specified in the `sources` kwarg explicitly
allow this. It makes no sense to not accept it as the posarg too.

Fixes building tracker-miners.
2022-01-11 22:28:00 -08:00
Eli Schwartz bcfb4d0f46 gnome.gtkdoc: fix passing file arguments as a configured file
Fixes gtk3 build, which uses typesfile.

All these arguments are processed by a function that explicitly handles
both str and File, and converts them to absolute paths. They clearly
need to handle File objects.
2022-01-11 22:28:00 -08:00
Eli Schwartz 704e9802c9 gome.gdbus_codegen: fix annotations argument for multiple annotations
Per the gdbus-codegen documentation, this "may be used several times",
and it is:
- a valid use case
- used that way in the wild

Fixes building at least geoclue2, gdm.
2022-01-11 22:28:00 -08:00
Michal Vasilek 9952446a2a gnome: fix typo in vapigen option metadatadir
This typo was introduced in 9ef36fa80b and
can cause a build failure, because --metadatdir is not a valid vapigen
option.
2022-01-10 15:30:53 -08:00
Pablo Correa Gómez 26c1869a14
modules/gnome: replace yelphelper with run and custom targets
This is basically a rewrite of the gnome.yelp target to remove the
ad-hoc script, which generates multiple issues, including meson
not knowing which files were installed.

Closes #7653
Closes #9539
Closes #6916
Closes #2775
Closes #7034
Closes #1052

Related #9105
Related #1601
2022-01-02 00:34:53 -05:00
Dylan Baker 3656b8c6d4 modules/gnome: use T.Sequence instead of T.List
because List is invariant, and that's not what we want.
2021-12-20 16:03:19 -05:00
Dylan Baker 1410d2e9c5 modules/gnome: use typed_kwargs for mkenum
This is the last function that doesn't use typed_kwargs. This now uses
the same shared path as the mkenums_simple
2021-12-20 16:03:19 -05:00
Dylan Baker 7e833d1484 modules/gnome: don't call through mkenums for mkenums_simple
It's just a bad idea, but especially once we start adding type
annotations to both of them.
2021-12-20 16:03:19 -05:00
Dylan Baker 4d8c91134c gnome: use typed_kwargs for mkenums_simple
the simple_version still goes through the big version of this function,
but at last we have type checking
2021-12-20 16:03:19 -05:00
Dylan Baker b2eb890da9 gnome: remove 'template' handling from mkenums
This has never been in permittedKwargs, it does nothing, and it was
never documented, so it seems pretty safe to just remove it.
2021-12-20 16:03:19 -05:00
Dylan Baker 21c3ee3ee7 modules/gnome: fix genmarshall install_dir default
Which needs to be converted from None to an empty list
2021-12-09 13:00:42 -08:00
Dylan Baker e37fd94654 modules/gnome: Fix handling of flags to genmarshal
These are actually just flags, they don't take any arguments (except
prefix, which was already handled correctly), and as such their
arguments should be booleans, not strings, and they should default to
False.
2021-12-09 13:00:42 -08:00
Dylan Baker 29f6724f39 modules/gnome: set genmarshal extra_args default to list
Which is what it should have been all along.
2021-12-09 13:00:42 -08:00
Dylan Baker 824e09159b modules/gnome: replace FeatureDeprecatedKwarg with typed_kwarg
Using the deprected_message helper.
2021-12-07 16:12:23 -05:00
Dylan Baker 9ef36fa80b modules/gnome: use typed_kwargs for generate_vapi
There is a change here, in that packages has error messaging for using
IncludeDirs objects in the packages argument, but it never worked, so
the message was useless.
2021-12-07 16:12:23 -05:00
Dylan Baker 4ed0df4c31 modules/gnome: use typed_kwargs for genmarshal 2021-12-07 16:12:23 -05:00
Dylan Baker 2a1c0358f4 gnome/genmarshal: Add missing kwargs to permittedKwargs
There are thee arguments that are passed directly to CustomTarget which
are not in the permittedKwargs: depends, depend_files, and build_always.
The first two are obviously generically useful, as they allow creating
correct ordering. The latter, not so much. Since it was an error to pass
it, we'll just delete it.
2021-12-07 16:12:23 -05:00
Eli Schwartz bc8c938148
gnome module: deprecate passing false to install_dir_gir
Use a proper install option for this. Now `install_<type>` can directly
override `install` instead of passing a boolean to the string kwarg
`install_dir_<type>`.
2021-12-06 20:59:45 -05:00
Eli Schwartz bed55a902c
gnome module: document and fix install_dir x3, by allowing false *_gir and *_typelib
generate_gir forces building both the typelib and gir, and some people
only want one or the other (probably only the typelib?) which means
flagging the other as install_dir: false in the same way custom_target
supports.

As this always worked, albeit undocumented, make sure it keeps working.
It's pretty reasonable to allow, anyway.

Fixes https://github.com/mesonbuild/meson/pull/9484#issuecomment-980131791
2021-12-06 20:07:43 -05:00
Alexander Kanavin c88bfdbefc gtkdoc: add support for a binary wrapper
Make it possible to specify a wrapper for executing binaries
in cross-compiling scenarios.
(usually, some kind of target hardware emulator, such as qemu)
2021-12-02 19:33:45 -05:00
Pablo Correa Gómez 905a361ca0 modules/gnome: import missing FeatureDeprecated for generate_gir
Commit dbb109703e broke generate_gir
by using FeatureDeprecated without importing it.
2021-11-23 10:20:58 -08:00
Eli Schwartz 32821be623
add location nodes to some Feature calls 2021-11-20 20:48:30 -05:00
Eli Schwartz dbb109703e
convert more mlog.deprecation into FeatureDeprecated 2021-11-20 20:48:29 -05:00
Eli Schwartz 4a65f3dead
fix missing subproject kwarg to FeatureDeprecated
We went straight to the extra message, which when parsed as a subproject
string resulted in the Feature being entirely skipped because "project()
has not been parsed yet" as it could not find a subproject named that.
2021-11-20 20:48:29 -05:00
Dylan Baker 40a8a3f8fe modules/gnome: fix warning message that will always fire
`typed_pos_args` ensures that the length of args is always true.
2021-11-16 01:20:03 +02:00
Dylan Baker aaac5538bf modules/gnome: Add back deprecation message
This looks like it was probably removed in a bad rebase
2021-11-16 01:20:03 +02:00
Dylan Baker ef52e60936 modules/gnome: use typed_kwargs for gdbus_codegen 2021-11-08 12:39:38 -08:00
Dylan Baker 566c2c9a9c modules/gnome: use typed_kwargs for gtkdoc method 2021-11-08 12:29:01 -08:00
Dylan Baker be1d013453 modules/gnome: use typed_kwargs for generate_gir
This removes the `packages` keyword argument, which was added in
80d665e8de, but beyond not warning about
unknown arguments has never done anything, and has never been
documented. The only users I could find were in our own test suite. If
someone is using this we can add it back with a deprecation warning.
2021-11-08 12:29:01 -08:00
Dylan Baker 6137c21eb6 modules/gnome: use typed_kwargs for compile_resources 2021-11-08 12:29:01 -08:00
Dylan Baker fa2affe47c modules/gnome: use typed_kwargs for yelp 2021-11-08 12:29:01 -08:00
Dylan Baker 3894f80e21 modules/gnome: use typed_kwargs for compile_schemas 2021-11-08 12:29:01 -08:00
Eli Schwartz 038b31e72b
various manual conversion of percent-formatted strings to f-strings 2021-11-01 20:26:18 -04:00
Dylan Baker 86df7dd627 modules/gnome: don't use dict.keys() to test membership
This is slower than looking in the dictionary, as the dict lookup is
O(log n), while keys() is O(n).
2021-11-01 12:24:25 -07:00
Dylan Baker 83facb3959 modules/gnome: use textwrap.dedent
Python is a whitespace significant language, changing indent level
implies that scope is changing. So when a string like

```python
def foo():
    a = '''
somthing
'''
    return a
```

It's visually misleading. Couple that with folding editors like vim
getting utterly confused by this, and it turns into a real pain. Using
textwrap.dedent allows us to get rid of that:

```python
def foo():
    a = texwrap.dedent(
        '''
        something
        ''')
    return a
```

But we still get the same result
2021-11-01 12:24:25 -07:00
Dylan Baker ba85c71750 modules/gnome: use envconfig for VAPIGEN
we have a mechanism for doing "this could be an environment variable"
let's use that.
2021-11-01 12:24:25 -07:00
Dylan Baker 35bc0ad22f mesonbuild/module/gnome: remove unused variable 2021-11-01 12:24:25 -07:00
Dylan Baker 2acd22fdb5 modules/gnome: Use typed_pos_args for generate_vapi 2021-11-01 12:24:25 -07:00
Dylan Baker bfd47cdac6 modules/gnome: use typed_pos_args for genmarshal 2021-11-01 12:24:25 -07:00
Dylan Baker 4a426f3649 modules/gnome: use typed_pos_Args for mkenums_simple 2021-11-01 12:24:25 -07:00
Dylan Baker 625fbf5243 modules/gnome: use typed_pos_args for mkenums 2021-11-01 12:24:25 -07:00
Dylan Baker 53a187ba2a modules/gnome: use typed_pos_args for gdbus_codegen 2021-11-01 12:24:25 -07:00
Dylan Baker 3798423563 modules/gnome: use typed_pos_args for gtkdoc_html_dir 2021-11-01 12:24:25 -07:00
Dylan Baker 256d5a71ba modules/gnome: use typed_pos_args for gtkdoc 2021-11-01 12:24:25 -07:00
Dylan Baker 58a592c5b0 modules/gnome: use typed_pos_args for yelp 2021-11-01 12:24:25 -07:00
Dylan Baker f339c33394 modules/gnome: use noPosargs for compile_schemas 2021-11-01 12:24:25 -07:00
Dylan Baker fea24ca174 modules/gnome: use typed_pos_args for generate_gir 2021-11-01 12:24:25 -07:00
Dylan Baker 3dcc712583 modules/gnome: use typed_pos_args for compile_resources 2021-11-01 12:24:25 -07:00
Dylan Baker 31efad6016 modules/gnome: add some type annotations
This is not complete, but it's a start. The rest will have to get
finished as we go
2021-11-01 12:24:25 -07:00
Dylan Baker 34d3e383ec modules/gnome: clean and sort dependencies 2021-11-01 12:24:25 -07:00
Dylan Baker c8ea5dfe8a modules/gnome: use `install_dir = []` instead of false 2021-10-28 17:39:24 -04:00
Dylan Baker b7a3457765 modules/gnome: fix missing install_dir, again, harder
It turns out this could be missing in GResource*Target as well, due
mostly to the same problem, side effects of mutating a shared
dictionary; though it could also happen with a specific set of keywords
given and other omitted.

Fixes #9350
2021-10-28 17:39:24 -04:00
Dylan Baker ae35b1f45a modules/gnome: ensure that `install_dir` is set
The `mkenums` functions can have this unset if, and only if, the
c file only variant is called. Due to side effects if the header file is
generated then `install_dir` is ensured to be set for the c file. I have
removed this side effect so that our tests actually cover this case.

Fixes #9472
2021-10-27 20:50:29 -04:00
Eli Schwartz 8947352889 fix various flake8 whitespace errors 2021-10-27 09:51:52 -04:00
Dylan Baker 3f8c78b317 modules/gnome: Fix unset install_dir
install_dir needs to be set to something, because CustomTarget expects
that. genmarshal still relies on CustomTarget setting it internally
itself.

Fixes #9350
2021-10-08 08:44:30 -04:00
Dylan Baker cfa6ff52e9 modules/gnome: Fix case that could never be hit due to bad types
It's impossible to get a Holder here, we'd get the unholdered build
types. Mypy points this out for us.
2021-10-08 08:44:30 -04:00
Dylan Baker bd00ea6b13 modules/gnome: fix use of undefined variable
Theere is no 'output' key in the kwargs, so if this was it it would
result in an exception. Mypy spotted this in a branch I'm working on
full typing for gnome, but since that seems unlikely to be done before
the 0.60 branchpoint I'd like to get this in sooner
2021-10-08 08:44:30 -04:00
Dylan Baker bcfbfbb343 modules/gnome: deprecate yelp variadic sources
Yelp currently can take sources two different ways, the first is via
variadic arguments, the second is by a keyword argument. If the keyword
is passed then the variadic arguments are silently ignored, which is
obviously not ideal. Fortunately the variadic form was never documented,
and is likely not in wide use.

This patch fixes it by deprecating the variadic form, and warning if
both are passed. It does not change behavior as someone may be relying
on it.
2021-10-07 09:26:35 -07:00
Eli Schwartz d06cc042eb
f-strings 2021-10-04 16:29:32 -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
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
Ting-Wei Lan a70cdebfe7 gnome: Prepend devenv, not append
Otherwise, if these environment variables already exist, they will
override values we set for the developer environment.
2021-08-29 08:36:59 -04:00
Eli Schwartz 1dce556dc2 gnome: don't let fortify defines into the g-ir-scanner after stripping -O
The tool needs to run the preprocessor (but does not actually produce
compiled outputs), and meanwhile ignores lots of flags it doesn't think
it needs. In the case of -D_FORTIFY_SOURCE=...  this is only valid if -O
is there too, but otherwise spits out confusing warnings.

The warnings are spurious and can be safely ignored, but in this case
let's go the extra mile and fix g-ir-scanner's upstream bug by removing
the fortify flag first.

Fixes #9161
2021-08-23 21:01:16 -04:00
Xavier Claessens 8c5aa031b5 Add install tags
Fixes: #7007.
2021-08-17 15:19:18 -04:00
Emmanuele Bassi d9acd7505c gnome: Filter all compiler and linker flags
When sending them to the introspection scanner, we must always filter
all compiler and linker flags, because g-ir-scanner does not accept any
random argument but only a specific subset.

Fixes: #8876
2021-08-09 14:43:57 -04:00
Xavier Claessens 1dcde9da61 modules: Add API to add test
This fix kwargs not going through typed_kwargs() decorator that sets
defaults.

Fixes: #9009
2021-08-06 15:04:38 -04:00
Nirbheek Chauhan 4b00d15adf gnome: Always pass absolute -L paths to g-ir-scanner
g-ir-scanner does not convert relative -L paths to runtime paths which
are added to -Wl,-rpath and LD_LIBRARY_PATH / DYLD_LIBRARY_PATH
/ PATH. This means that the local library will either not be found at
runtime (while building introspection data), or the system-wide
library will be picked instead.

See: giscanner/ccompiler.py:get_internal_link_flags() in
gobject-introspection for more details.
2021-07-18 17:38:44 +05:30
Daniel Mensinger 3e396b3782
fix: Always explicitly set encoding for text files (fixes #8263) 2021-06-29 11:28:08 +02: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
Xavier Claessens d3d95d39be gnome: add update_desktop_database to post_install() 2021-06-23 15:48:32 -04:00
Xavier Claessens 39c6571a46 gnome: Set GSETTINGS_SCHEMA_DIR in devenv 2021-06-23 15:48:32 -04:00
Daniel Mensinger 0c4dd81c4d
fix: Handling BothLibraries objects (fixes #8907) 2021-06-22 21:09:19 +02:00
Daniel Mensinger 34c28dc92c holders: remove unholder 2021-06-18 23:48:33 +02:00
Dylan Baker 201dc64226 add a couple more type annotations 2021-06-02 15:53:17 -07:00
Xavier Claessens 8abbc5cc5d modules: Replace find_program_impl() by state.find_program() 2021-05-28 15:17:10 -04: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 a734bcfc83 modules: Stop using ModuleReturnValue where it's not needed
It is only needed in functions that need to add targets to the
interpreter.
2021-05-28 15:17:10 -04:00
Dylan Baker f1e053fa44 modules/gnome: Correctly handle generated sources for generate_gir
We need to pass any generated sources down the CustomTarget
inititalizers so that they will generate a dependency correctly,
otherwise we get race conditions.
2021-05-28 08:47:11 -04:00
Xavier Claessens 4e312c19e6 gnome: Fix gtkdoc generation
install_scripts used to replace @BUILD_ROOT@ and @SOURCE_ROOT@ but it
was not documented and got removed in Meson 0.58.0. gnome.gtkdoc() was
relying on that behaviour, but it has always been broken in the case the
source or build directory contains spaces.

Fix this by changing get_include_args() to substitue paths directly
which will then get escaped correctly.

Add a unit test that builds GObject documentation which is where this
issue has been spotted.

Fixes: #8744
2021-05-12 15:54:37 -04:00
Ross Burton 5892362268 gnome: improve dependency lookup of G-I
Cross-compiling and generating gobject-introspection isn't trivial, but
with wrapper scripts that call qemu-user it's perfectly doable[1].

Currently looking up the gobject-introspection pkgconfig is done as a
native dependency, which means in cross-compilation environments this
is not the right paths (wrong library path, for example).

Solve this by generalisiing _get_native_dep() to _get_dep(native) and
asking for the host gobject-introspection instead.

[1] https://git.yoctoproject.org/cgit.cgi/poky/tree/meta/recipes-gnome/gobject-introspection/
2021-05-08 21:30:03 +03:00