Commit Graph

345 Commits

Author SHA1 Message Date
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
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