Commit Graph

327 Commits

Author SHA1 Message Date
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
Xavier Claessens a9e9b7c750
devenv: Set GI_TYPELIB_PATH and LD_LIBRARY_PATH (#8548) 2021-03-23 23:35:05 +02:00
Dylan Baker 9016e4596c Move OverrideProgram to programs 2021-03-19 08:47:10 -04:00
Dylan Baker 40e3577a65 split program related classes and functions out of dependencies
Dependencies is already a large and complicated package without adding
programs to the list. This also allows us to untangle a bit of spaghetti
that we have.
2021-03-19 08:47:10 -04:00
Eli Schwartz 6a0fabc647
mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04 17:16:11 -05:00
Xavier Claessens 2fabd4c7dc minstall: Add --skip-subprojects option
By default all subprojects are installed. If --skip-subprojects is given
with no value only the main project is installed. If --skip-subprojects
is given with a value, it should be a coma separated list of subprojects
to skip and all others will be installed.

Fixes: #2550.
2021-02-22 23:03:55 +02:00
Jussi Pakkanen 8b82ffa9e4
Merge pull request #8305 from xclaesse/run-target-env
run_target: Add env kwarg
2021-02-07 11:46:41 +00:00
Xavier Claessens 522392e755 run_target: Add env kwarg
Re-implement it in backend using the same code path as for
custom_target(). This for example handle setting PATH on Windows when
command is an executable.
2021-02-05 17:53:09 -05:00
Xavier Claessens b5100fe86a gnome: Add post_install() method
Various GNOME projects have scripts that does similar task, better do it
directly in meson. This ensures it's done correctly regarding usage of
subprojects and pkg-config. See for example this gtk bug:
https://gitlab.gnome.org/GNOME/gtk/-/issues/3626.

Fixes: #8268
2021-02-05 15:08:47 -05:00
Xavier Claessens 0626465ea8 Fix executable as script on Windows
On Windows this would fail because of missing DLL:
```
mylib = library(...)
exe = executable(..., link_with: mylib)
meson.add_install_script(exe)
```

The reason is on Windows we cannot rely on rpath to find libraries from
build directory, they are searched in $PATH. We already have all that
mechanism in place for custom_target() using ExecutableSerialisation
class, so reuse it for install/dist/postconf scripts too.

This has bonus side effect to also use exe_wrapper for those scripts.

Fixes: #8187
2021-01-30 09:51:06 +00:00
Dylan Baker 022632c91b build/interperter: Add annotations and move input validation to interpreter
This moves the user input validation to the interpreter, instead of
being in the build module, and adds type annotations.
2021-01-13 13:32:48 -08:00
Dylan Baker e81acbd606 Use a single coredata dictionary for options
This patches takes the options work to it's logical conclusion: A single
flat dictionary of OptionKey: UserOptions. This allows us to simplify a
large number of cases, as we don't need to check if an option is in this
dict or that one (or any of 5 or 6, actually).
2021-01-04 12:20:58 -08:00
Dylan Baker 71db6b04a3 use OptionKey for builtin and base options
I would have prefered to do these seperatately, but they are combined in
some cases, so it was much easier to convert them together.

this eliminates the builtins_per_machine dict, as it's duplicated with
the OptionKey's machine parameter.
2021-01-04 12:20:40 -08:00
Philip Withnall 42ba8efaf2 gnome: Drop use of volatile in GLib type functions
See https://gitlab.gnome.org/GNOME/glib/-/issues/600

`volatile` was previously mistakenly used in GLib to indicate that a
variable was accessed atomically or otherwise multi-threaded. It’s not
meant for that, and up to date compilers (like gcc-11) will rightly warn
about it.

Drop the `volatile` qualifiers.

Based on a patch by Jeff Law.

See also http://isvolatileusefulwiththreads.in/c/.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-11-17 17:45:25 +02:00
Sam Thursfield 21897a10ca gnome: Handle libraries that are not in the current build dir
The generate_gir() function previously assumed all library
inputs were in the current build dir. This would fail if they
weren't.
2020-11-13 17:39:47 +02:00
Sam Thursfield 505b5b2391 gnome: Tweak error message
It's an easy mistake to do this:

    gir1 = gnome.generate_gir(...)
    gir2 = gnome.generate_gir(...
        includes: ['GObject-2.0', gir1])

This fails with an error:

    ERROR: Gir includes must be str, GirTarget, or list of them.

The issue is that the 'gir1[0]' should be passed instead of 'gir1'.
To make the problem slightly clearly, tweak the error message to be:

    ERROR: Gir includes must be str, GirTarget, or list of them. Got TypelibTarget.
2020-11-01 19:27:09 +02:00
Xavier Claessens a050db5e30 Fix gnome.compile_resources() when glib is a subproject
When glib is a subproject we should use glib-compile-resources it
overrides using find_program() in the case it is not installed on the
build machine. With old glib version we have to run
glib-compile-resources at configure time to generate the list of
dependencies, but not when glib is recent enough.
2020-10-17 22:25:57 +03:00
mimi89999 4d140eb830 gnome: generate cpp gresource source in cpp projects
Closes #7839
2020-10-15 08:09:51 -04:00
Xavier Claessens f40e1567f5 Update mesonbuild/modules/gnome.py
Co-authored-by: Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
2020-06-16 08:21:35 -04:00
Xavier Claessens 2ebda584ad Update mesonbuild/modules/gnome.py
Co-authored-by: Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
2020-06-16 08:21:35 -04:00
Xavier Claessens 0b4cf5a844 gnome: Add fatal_warnings kwarg to generate_gir()
Fixes: #7130
2020-06-16 08:21:35 -04:00
Dylan Baker 06481666f4 interpreter: Replace some uses of mlog.deprecation with FeatureDeprecated
This gives the version that the feature was deprecated in, and doesn't
print the warning if the project supports versions of meson in which the
project wasn't deprecated.
2020-05-14 11:28:04 -07:00
Xavier Claessens 93dc9cfcc3 gnome.generate_gir: Fix missing include directories
This revert a part of #7020 because it was using gir_inc_dirs
before it is set. Properly fix typelib_includes instead that was working
only when g-i is a pkgconfig dependency.
2020-05-14 17:59:17 +00:00
James Hilliard 1e073c4c1b Allow overriding g-ir-scanner and g-ir-compiler binaries.
This is useful when one needs to force meson to use wrappers for cross
compilation.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
2020-05-07 10:19:34 -04:00
Xavier Claessens 4929547b53 gnome: Print proper error when 'nsversion' or 'namespace' are missing 2020-04-30 09:40:35 -04:00
Xavier Claessens 707d3a2e20 gnome: Fix usage of gobject-introspection as subproject 2020-04-28 14:39:59 -04:00
Jon Turney 7005e211a2 Report an errror if glib-compile-resources is missing
Produce a diagnostic if we try to use gnome.compile_resources() when
glib-compile-resources isn't present, rather than a python backtrace.
2020-03-29 20:53:50 +03:00
Xavier Claessens 326e9dcc51 gtkdoc: Add missing permitted kwarg
The 'check' kwarg was added in Meson 0.52.0.
2020-03-23 23:57:49 +02:00
Dylan Baker 06b1a317d2 Make use of unholder
We have a lot of cases of code like:
```python
if hasattr(var, 'held_object'):
    var = var.held_object`
```

replace that with the unholder function.
2020-03-05 09:58:52 -08:00
Dylan Baker 581d69a8d3 remove ability to pass multiple keys to extract_as_list
This makes the typing annotations basically impossible to get right, but
if we only have one key then it's easy. Fortunately python provides
comprehensions, so we don't even need the ability to pass multiple keys,
we can just [extract_as_list(kwargs, c) for c in ('a', 'b', 'c')] and
get the same result.
2020-03-05 09:58:52 -08:00
Dylan Baker b231ff36df Remove some uses of mesonlib.run_once
These are basically doing what mlog.log(..., once=True) does, so lets
just use that. The once argument to mlog is newer, so these probably
should have been changed already.
2020-03-05 09:31:29 -08:00
Dylan Baker a8293dd59c mesonlib: Replace unholder argument to listify
listify shouldn't be unholdering, it's a function to turn scalar values
into lists, or flatten lists. Having a separate function is clearer,
easier to understand, and can be run recursively if necessary.
2020-03-05 09:31:29 -08:00
Adam Duskett 6ba034c37d mesonbuild/modules/gnome.py: Fix giscanner and gicompiler logic
Currently, giscanner and the gicompiler paths are only scanned via pkg-config
if they are first found in the host path.

Add a else statement to fix this oversite.
2020-02-26 11:49:34 -05:00
Adam Duskett f66b04b099 gobject-introspection: determine g-ir-scanner and g-ir-compiler paths from pkgconfig
Currently, meson hard codes the paths of these binaries which results in
cross-compiled environments to run the host versions of these tools.
However, GObject-introspection provides the appropriate paths to these
utilities via pkg-config

find_program is needed in the case g-i is built as a subproject. If
g-ir-scanner or g-ir-compiler are in the build or source directory use those.
If they aren't found in the source directory, use the results from pkg-config.
2020-02-25 20:16:44 -05:00
Dylan Baker cd895be99a dependencies: Add ability to set arbitrary variables on
declare_dependencies

This allows dependencies declared in subprojects to set variables, and
for those variables to be accessed via the get_variable method, just
like those from pkg-config and cmake. This makes it easier to use
projects from subprojects in a polymorphic manner, lowering the
distinction between a subproject and an external dependency every
further.
2020-01-09 11:02:17 -08:00
Wolfgang Stöggl f037e7ef45 Fix typos found by codespell
- Typos were found by codespell v1.16.0
2019-11-06 09:55:30 -05:00
Zbigniew Jędrzejewski-Szmek f745e8fc4d Use functools cache instead of open-coded implementation
Functional behaviour is not identical, because the cache not set
when an exception is thrown. I hope this doesn't matter in practice.
2019-09-25 14:52:07 +02:00
Zbigniew Jędrzejewski-Szmek 11c1f8644c Drop unused variable 2019-09-25 14:52:07 +02:00
Zbigniew Jędrzejewski-Szmek 3a6920ebdc Add helper to print warnings once
The helper is general, although in this patch it is only used for
warnings. No functional change intended.
2019-09-25 14:52:07 +02:00
Aleksey Gurtovoy 75daed27bc mesonlib.split_args/quote_arg/join_args 2019-09-05 23:42:47 +03:00
Thibault Saunier edec2ee0ee gnome: Handle overriden g-ir-scanner
When g-ir-scanner is overriden, we can't call it at configure time
but we know what options are avalaible (as it started using meson
after checked options where added) so do not try to call it to retrieve
the version as it will fail.

Also see https://github.com/mesonbuild/meson/issues/3442
2019-08-17 12:07:20 +03:00
Xavier Claessens 172a355b93 Revert "gnome: Use find_program() to get glib-compile-resources"
This reverts commit 0ab3d97566.
2019-08-13 09:34:25 -04:00
Xavier Claessens 0ab3d97566 gnome: Use find_program() to get glib-compile-resources
GLib does not currently use override_find_program() for this tool
because it is compiled and would not work in cross build. But this
prepares Meson for when/if GLib will rewrite it in Python.

See https://gitlab.gnome.org/GNOME/glib/issues/1859.
2019-08-12 04:26:27 +00:00
Xavier Claessens 44ac680e55 gtkdoc: Use find_program() to get gtkdoc tools
This will allow using gtk-doc as a subproject instead of having to
install it on the system. It also has the side effect of failing at
configuration time with a proper message if gtkdoc is not installed,
instead of failing at build time with a python backtrace.
2019-08-04 21:40:55 +03:00
Dylan Baker c8a6a44850 compilers: pull sanitzier args into compiler classes
This simplifies and cleans things up.
2019-07-23 09:58:24 +00:00
Xavier Claessens f5da881126 gtkdoc: Add 'check' kwarg (#5591)
* gtkdoc: Add 'check' kwarg

This runs gtkdoc-check in meson tests.

Also reorganize the gtkdoc test because we cannot reliably build
multiple doc into the same directory. Not all files generated by gtk-doc
are prefixed with the target name.
2019-07-16 22:50:33 +03:00
Alexander Kanavin ecbfc08dca gnome.py: correctly pick the compiler for gtk-doc builds 2019-06-27 09:17:49 -07:00
John Ericson 07777e15d4 Purge `is_cross` and friends without changing user interfaces
In most cases instead pass `for_machine`, the name of the relevant
machines (what compilers target, what targets run on, etc). This allows
us to use the cross code path in the native case, deduplicating the
code.

As one can see, environment got bigger as more information is kept
structured there, while ninjabackend got a smaller. Overall a few amount
of lines were added, but the hope is what's added is a lot simpler than
what's removed.
2019-06-09 13:13:25 -04:00