Commit Graph

447 Commits

Author SHA1 Message Date
Dylan Baker 764b3bf327 modules/gnome: fix some typing issues
That come to light with some of the changes later in this series,
particularly around dependencies.
2022-05-25 22:41:03 -04:00
Xavier Claessens ca77adea89 gnome: Make sure g-ir-scanner can use pkg-config properly
We need to setup the environment we pass to g-ir-scanner because it will
try to use pkg-config to find dependencies, and that must respect user
settings from machine file. Also make it use uninstalled pc files Meson
generated in the case dependencies, such as glib, have been built as
subproject.
2022-04-30 15:01:28 -04:00
Ferdinand Thiessen 6f156e8ddd gnome: Use 'doc' install_tag for gnome.yelp 2022-04-27 09:29:38 -04:00
Eli Schwartz e5aa47d8af Revert "wayland: Also lookup scanner in pkgconfig"
This reverts commit 7954a4c9cb.
2022-04-07 23:44:34 -04:00
Xavier Claessens 7954a4c9cb wayland: Also lookup scanner in pkgconfig
This moves generally useful logic from GNOME module's
_get_native_binary() into find_program() implementation. We could decide
later to expose it as public API.
2022-04-04 09:17:34 -04:00
Eli Schwartz 1cfead6647
fix continued breakage in gnome module API
In commit 823da39909 we tried to fix
disappearing dependencies. Instead, we appended the replacement
dependencies to the existing ones. But this, too, was wrong. The
function doesn't return new dependencies... it returns a copied list
of all the dependencies, then alone of all parts of that API, expects to
overwrite the existing variable.

(Sadly, part of the internals actually uses the entire list for
something.)

As a result, we produced a repeatedly growing list, which eventually
scaled really badly and e.g. OOMed on gstreamer.

Instead, let's just replace the dependencies with the updated copy.
2022-03-31 14:50:27 -04:00
Eli Schwartz c9938f8f60
move a bunch of imports into TYPE_CHECKING blocks
These are only used for type checking, so don't bother importing them at
runtime.

Generally add future annotations at the same time, to make sure that
existing uses of these imports don't need to be quoted.
2022-03-29 16:44:54 -04:00
Xavier Claessens e33ec88ac7 Pass environment down to base Target class 2022-03-29 16:10:28 -04:00
Jan Tojnar b7686dfed5 gnome: Fix gtkdoc when using multiple Apple frameworks
The `-framework Foundation -framework CoreFoundation` ended up
de-duplicated by OrderedSet into `-framework Foundation CoreFoundation`.
2022-03-29 12:52:55 -04:00
Jan Tojnar 39623a36ca gnome: Fix typo in _get_dependencies_flags
This was introduced in 823da39909
2022-03-29 12:52:55 -04:00
Eli Schwartz 823da39909
fix regression in propagating depends in gtkdoc
In commit 68e684d51f the function
signature was changed, but several places did not adapt. Additionally,
we now totally dropped the in-place update of gtkdoc's sole source of
dependencies, but didn't propagate them upward to assign the newly
collected dependencies anywhere.

Fixes building gtkdoc with internal dependencies and failing when
specified directly (when building the 'all' target with sufficiently
random parallelism, deps may be built on time).

Fixes:
  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1008382
  https://gitlab.gnome.org/GNOME/libmediaart/-/issues/4
2022-03-28 23:33:28 -04:00
Antoine Jacoutot dac212e1bb gnome module: properly fallback to gtk-update-icon-cache
Commit a0cade8f introduced a typo and wrongly check for
gtk4-update-icon-cache twice.
If gtk4-update-icon-cache (gtk4) is not found, look for
gtk-update-icon-cache (gtk3) instead.
2022-03-23 17:54:12 -04:00
Eli Schwartz a0cade8f1d
gnome module: fix incorrect lookup of nonexistent dependencies in post_install
While gtk+-3.0 / gtk4 do exist, they have never provided the location of
the gtk-update-icon-cache program as a pkgconfig variable. Trying to
find one anyway, resulted in two things happening:
- a useless dep lookup
- a fatal-meson-warnings error and build failure because the
  get_pkgconfig_variable() in question never existed

The desktop-file-utils package is a package solely providing some
command line programs, and has never provided a pkg-config file in the
first place, so this always logged that the dependency was not found and
fell back to normal find_program_impl(), although without
fatal-meson-warnings build errors.

Fixes #10139
2022-03-18 12:52:06 -04:00
Eli Schwartz a5bb654377
gnome module: fix crash due to misused function while generating gir command
In commit 68e684d51f the _get_link_args
function was modified from returning a list[str] of arguments, to a
tuple of both that and a modified copy of the entire target's
current/enhanced dependencies (why not just the new ones? I don't know).

However, the existing use of the function was not adapted to this
change, and tried to turn this entire tuple into a node of the command
line. Tuples cannot flatten to lists, and mesonlib.File or
HoldableObjects don't make good command line arguments.

As a result we errored out with:

ERROR: Argument (['-L/path/to/builddir/', '--extra-library=foo'], [<SharedLibrary 25a6634@@foo@sha: foo>, <SharedLibrary 25a6634@@foo@sha: foo>, <SharedLibrary 25a6634@@foo@sha: foo>]) in "command" is invalid

Split out the flags and the dependencies and update the former while
replacing the latter.
2022-03-13 21:23:36 -04:00
Jussi Pakkanen 69ade4f4cf
Merge pull request #9339 from dcbaker/submit/structured_sources
Structured Sources
2022-03-13 01:01:55 +02:00
Eli Schwartz 266e8acb58
fix python traceback when gtkdoc needs an exe_wrapper but doesn't have one
In commit c88bfdbefc we added support for
an exe_wrapper to gtkdoc, which checked twice whether the environment
says it is needed, and didn't check at all whether one was provided.

The result:

  File "/usr/lib/python3/dist-packages/mesonbuild/modules/gnome.py", line 1354, in gtkdoc
    t_args.append('--run=' + ' '.join(state.environment.get_exe_wrapper().get_command()))
AttributeError: 'NoneType' object has no attribute 'get_command'

Instead, check whether we have a valid exe_wrapper (if we don't need
one, then even when one is defined in the cross file, we get an
EmptyExternalProgram) and if we do, use it.

If we don't have one, but need one, then we revert back to the behavior
before commit c88bfdbefc, which probably
means "executing the doc target causes the command to error out with
"Exec format error".
2022-03-09 16:06:27 -05:00
Eli Schwartz a009eacc65
treewide: string-quote the first argument to T.cast
Using future annotations, type annotations become strings at runtime and
don't impact performance. This is not possible to do with T.cast though,
because it is a function argument instead of an annotation.

Quote the type argument everywhere in order to have the same effect as
future annotations. This also allows linters to better detect in some
cases that a given import is typing-only.
2022-03-07 19:01:04 -05:00
Dylan Baker 7d1431a060 build: plumb structured sources into BuildTargets 2022-03-07 12:33:33 -08:00
Remi Thebault 4fe6f0dd29 add D features to InternalDependency 2022-03-03 08:42:56 -08:00
Xavier Claessens c4b8c23eb1 Add API for modules that wants to define their devenv 2022-02-28 09:03:27 -05:00
Eli Schwartz 9daaece785
flake8: fix various whitespace errors with badly aligned code 2022-02-16 23:00:31 -05:00
Dylan Baker 029652ecb5 modules/gnome: remove unnecessary type check
This should have been removed when typed_kwargs was added
2022-01-28 15:53:20 -05:00
Dylan Baker 457fb53ea4 gnome: genmarshal: If the source includes the header, depend on it
Otherwise we're racing between the header generation and the source
generation.
2022-01-28 15:53:20 -05:00
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