Commit Graph

474 Commits

Author SHA1 Message Date
Thibault Saunier 01275fb09e gnome: Deduplicate include dirs to generate gir
Ensuring the order is respected
2023-01-26 15:34:01 -05:00
Dylan Baker 27df0e09f7 modules/gnome: fix type annotations from `__init__`, which are wrong
Mainly thi sis that `state.find_program()` is annotated incorrectly, it
returns `ExternalProgram | Executable | OverrideProgram`, but it's
annotated to return only `ExteranlProgram`, and thus a bunch of the
annotations in the gnome module are wrong.
2023-01-10 09:53:22 -08:00
Paolo Bonzini b3fc3cd6b5 add objects keyword argument to declare_dependencies 2023-01-04 09:44:32 -08:00
Dylan Baker 5ef824b2f3 modules/gnome: use `mlog.log(once=True)` in a few more places
It's probably not useful to spam the user with warnings that old
versions of software may not behave correctly when the first warning was
perfectly valid.
2023-01-03 14:49:02 -05:00
Dylan Baker f7cde8d3f6 Add fatal=False to many mlog.warnings()
There are lots of warnings that become fatal, that are simply unfixable
by the end user. Things like using old versions of software (because
they're using some kind of LTS release), warnings about compilers not
supporting certain kinds of checks, or standards being upgraded due to
skipped implementations (MSVC has c++98 and c++14, but not c++11). None
of these should be fatal, they're informative, and too important to
reduce to notices, but not important enough to stop meson if they're
printed.
2023-01-03 14:49:02 -05:00
Eli Schwartz e5a9272034
typing: fix some broken Sequence annotations
T.Sequence is a questionable concept. The idea is to hammer out generic,
maximally forgiving APIs that operate on protocols, which is a fancy way
of saying "I don't care if you use tuples or lists". This is rarely
needed, actually, and in exchange for this fancy behavior you get free
bugs.

Specifically, `somestr` is of type `T.Sequence[str]`, and also
`somestr[0]` is another string of type you guessed it. It's ~~turtles~~
strings all the way down.

It's worth noting that trying to code for "protocols" is a broken
concept if the contents have semantic meaning, e.g. it operates on
"the install tags of this object" rather than "an iterable that supports
efficient element access".

The other way to use T.Sequence is "I don't like that T.List is
invariant, but also I don't like that T.Tuple makes you specify exact
ordering". This sort of works. In fact it probably does work as long as
you don't allow str in your sequences, which of course everyone allows
anyway.

Use of Sequence has cute side effects, such as actually passing lists
around, knowing that you are going to get a list and knowing that you
need to pass it on as a list, and then having to re-allocate as
`list(mylist)` "because the type annotations says it could be a str or
tuple".

Except it cannot be a str, because if it is then the application is
fatally flawed and logic errors occur to disastrous end user effects,
and the type annotations:
- do not enforce their promises of annotating types
- fail to live up to "minimal runtime penalties" due to all the `list()`

Shun this broken concept, by hardening the type annotations. As it turns
out, we do not actually need any of this covariance or protocol-ism for
a list of strings! The whole attempt was a slow, buggy waste of time.
2022-12-11 18:28:39 -05:00
Xavier Claessens 548c9adad4 Remove useless EmptyExternalProgram
It is only used by Environment.get_exe_wrapper() and every callers were
handling None already. Type annotation was wrong, it already could
return None for the case an exe wrapper is needed but none is provided.
2022-12-07 11:58:36 -05:00
Dylan Baker 2d349eae8c
pylint: enable the set_membership plugin
Which adds the `use-set-for-membership` check. It's generally faster in
python to use a set with the `in` keyword, because it's a hash check
instead of a linear walk, this is especially true with strings, where
it's actually O(n^2), one loop over the container, and an inner loop of
the strings (as string comparison works by checking that `a[n] == b[n]`,
in a loop).

Also, I'm tired of complaining about this in reviews, let the tools do
it for me :)
2022-11-30 16:23:29 -05:00
Paolo Bonzini 212af2b278 gnome: allow generator outputs as gdbus-codegen inputs
GeneratedLists as sources to `gnome.gdbus_codegen` worked until
version 0.60 of Meson, but broke in 0.61 because of the conversion to
typed_pos_args and typed_kwargs.  Reinstate this by adding them to the
decorators and annotations.

Note that gdbus_codegen desugars to two custom_targets and therefore the
generator is invoked twice.  This is not optimal, but it should not be
an issue and can be changed later.

Fixes: 53a187ba2 ("modules/gnome: use typed_pos_args for gdbus_codegen", 2021-11-01)
Fixes: ef52e6093 ("modules/gnome: use typed_kwargs for gdbus_codegen", 2021-11-08)
2022-10-28 13:06:52 +03:00
Paolo Bonzini 2fe3271f77 gnome: allow custom targets as gdbus-codegen inputs
Custom targets as sources to `gnome.gdbus_codegen` worked until version 0.60
of Meson, but broke in 0.61 because of the conversion to typed_pos_args
and typed_kwargs.  Reinstate this by adding custom targets to the
decorators and annotations.

While generators also used to work, they are a bit tricky because
gdbus_codegen desugars to two custom_targets and therefore the generator
is invoked twice.  This should not be a problem, but be explicit and
leave that to a separate commit to highlight the problem.

Fixes: 53a187ba2 ("modules/gnome: use typed_pos_args for gdbus_codegen", 2021-11-01)
Fixes: ef52e6093 ("modules/gnome: use typed_kwargs for gdbus_codegen", 2021-11-08)
2022-10-28 13:06:52 +03:00
Dylan Baker a72840cd2e
pylint: enable use-a-generator
This catches some optimization problems, mostly in the use of `all()`
and `any()`. Basically writing `any([x == 5 for x in f])` vs `any(x == 5
for x in f)` reduces the performance because the entire concrete list
must first be created, then iterated over, while in the second f is
iterated and checked element by element.
2022-10-04 00:33:04 -04:00
Paolo Borelli a58ec322b3 gnome: add support for update-mime-database
Fixes https://github.com/mesonbuild/meson/issues/10865
2022-09-28 12:07:24 -04:00
Jan Tojnar c8d5f93cb0 gnome/yelp: fix `xml:lang` attributes
itstool detects a language code from the mo file’s basename,
so when 26c1869a14
changed the file name to be prefixed with project name,
values like “my-project-xx” ended up in the `xml:lang` attribute
of the generated page files, instead of the expected
IETF BCP 47 language tag.

Let’s fix it by passing a locale code to itstool explicitly.
2022-09-27 22:04:45 +03:00
Dylan Baker 1917b9253e modules/gnome: make_native_glib_version an instance var
This removes the need for the use of the global statement. I've also
updated the test that overrides this to use mock.patch instead of hand
monkey patching.
2022-09-22 18:17:43 -04:00
Xavier Claessens 635cb1b873 gnome: Add some missing install_tag 2022-09-18 21:59:30 -04:00
David Ward ee5a729190 modules: Fix paths to (sub)project source/build directories
The subproject directory name (i.e. 'subprojects') was being added
to the path even for the main project.
2022-09-12 00:27:21 -04:00
Dylan Baker 6843f56f6b modules: use module level information about new and deprecation
Instead of using FeatureNew/FeatureDeprecated in the module.

The goal here is to be able to handle information about modules in a
single place, instead of having to handle it separately. Each module
simply defines some metadata, and then the interpreter handles the rest.
2022-08-17 16:25:36 -04:00
Eli Schwartz 37f95303f0
typing: simplify type annotations for libraries
In a bunch of places we need to list various types of libraries
including custom_target outputs, and it gets very long. Use a common
T.Union for this.
2022-08-04 20:06:01 -04:00
Richard Hughes 407eaa3b4a gnome module: Use --quiet to supress printing the link command line
This removes one line of stderr output per GObject Introspection file
processed, e.g.

g-ir-scanner: link: gcc -o Fwupd-2.0 Fwupd-2.0.o -L. -Wl,-rpath...
2022-07-06 15:29:41 -04:00
Eli Schwartz 0703ee0aef
move various unused typing-only imports into type-checking blocks 2022-07-03 14:11:31 -04:00
Eli Schwartz 28835cce71 gnome module: fix regression that broke using built xml files as gresources
In commit 3dcc712583 we moved to
typed_pos_args. In the process, we deleted some code to specifically
raise an error if you use custom_target or generator outputs, instead
leaving it out of the typed pos args.

However, that support was specifically supposed to be there. It was only
an error in part of an if statement for handling old versions of
glib-compile-resources. The specific error it calls out is that we need
to manually parse the depfile at configure time, due to an external bug;
obviously this is impossible if the gresource is only created at build
time.

Reinstate the original error message check, and allow built outputs to
be used as compile_resources() inputs.

Fixes #10367
2022-06-19 17:39:18 +03:00
Eli Schwartz 462b35e4b1 flake8: fix various whitespace nits 2022-06-13 13:34:39 +03:00
Xavier Claessens 0aeb61bd52 wayland: Lookup for wayland-scanner using pkgconfig
Just like some of glib tools, wayland-scanner can be defined in the
pkgconfig dependency variables. Share code between gnome and wayland
modules into ModuleState.
2022-06-10 00:48:25 -04:00
Dylan Baker 618b187f70 interpreter: use a shared KwargInfo for install_dir
CustomTarget allows multiple install dirs, while basically everything
else allows only one. So this provides a shared instance for that.
2022-06-01 22:49:10 -04:00
Dylan Baker 7b90066a01 modules/gnome: fix gen_marshall annotation 2022-06-01 22:49:10 -04:00
Dylan Baker a2def550c5 modules: move gnome targets into gnome module
They're not used outside of the gnome module anyway, and they create
some annoying potentials for dependency loops
2022-06-01 22:49:10 -04:00
Dylan Baker 9c9be9d74b modules/gnome: Fix missing type annotation 2022-05-25 22:41:03 -04:00
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