Commit Graph

1204 Commits

Author SHA1 Message Date
John Lindgren a606ce22eb Add support for Qt 6.1+
Qt 6.1 moved the location of some binaries from QT_HOST_BINS to
QT_HOST_LIBEXECS as noted in the changelog:

c515ee178f Move build tools to libexec instead of the bin dir
- Tools that are called by the build system and are unlikely to be
called by the user are now installed to the libexec directory.

https://code.qt.io/cgit/qt/qtreleasenotes.git/tree/qt/6.1.0/release-note.txt

It's possible to help the 'qt' module find the tools by adding Qt's
libexec directory to the PATH environment variable, but this manual
workaround is not ideal.

To compensate, meson now needs to look for moc, rcc, uic, etc. in
QT_HOST_LIBEXECS as well as QT_HOST_BINS.

Co-authored-by: Stefan Hajnoczi <stefanha@jammr.net>
2022-04-12 20:42:42 -04:00
Matti Picus 73fa3aad43 python module: windows dll name for pypy needs special casing 2022-04-12 06:58:04 -04:00
Jussi Pakkanen 3c80f8f965 Use a temp file to invoke the introspection command.
This is more reliable as '-c' can, for example, exhaust
the maximum command line length.
2022-04-10 17:13:51 +03:00
Eli Schwartz d27fd555e8 python module: restore logging for broken python
This check was erroneously removed in commit c5c02b72e1
2022-04-10 15:17:22 +03: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 fdcc566590
i18n: don't let our maintainer targets run via wrapped env
They are RunTargets because they are one-shot commands without outputs.
But we implement them purely via our internal wrapper for gettext, so
there is no reason to wrap them *again* in our internal wrapper for
meson_exe and set a bunch of environment variables we know we absolutely
do not need, use, or want.

This avoids the ugly "wrapped due to env" status, and allows users to
directly see the command being run without going into despair at obscure
pickled nonsense.

It also offers a tiny defense against upgrading Meson without
reconfiguring. People should not do that, and we error out about this in
a bunch of places, but `--internal gettext` has a perfectly stable
interface just like most build tools that aren't part of Meson
internals, since it uses command line arguments instead of pickling.
2022-03-31 22:52:31 -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
Xavier Claessens f2d21bf8a9 Make compilers list per subproject
Previously subprojects inherited languages already added by main
project, or any previous subproject. This change to have a list of
compilers per interpreters, which means that if a subproject does not
add 'c' language  it won't be able to compile .c files any more, even if
main project added the 'c' language.

This delays processing list of compilers until the interpreter adds the
BuildTarget into its list of targets. That way the interpreter can add
missing languages instead of duplicating that logic into BuildTarget for
the cython case.
2022-03-24 12:27:06 -04:00
Eli Schwartz c827462593
hotdoc module: use typed_pos_args to check positional arguments
We cannot use typed_kwargs though, because we allow fully arbitrary
kwargs and pass them as arguments to the hotdoc program.
2022-03-24 02:07:02 -04:00
Eli Schwartz 71a5db0a03
dub module: use typed_pos_args to check positional arguments
We cannot use typed_kwargs though, because we allow fully arbitrary
kwargs and add them as keys in the generated dub file.
2022-03-24 02:07:02 -04:00
Eli Schwartz 9c7868e343
python 3 module: type-check all posargs
Yes, it's deprecated, but we can still stop people doing the wrong thing
with it if they are still using it.
2022-03-24 02:07:02 -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
Dylan Baker adc509ed98 modules/rust: set bindgen include_dirs for both build and source dir
Which we pretty obviously need if any of our headers are generated
2022-03-20 11:00:53 -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
Xavier Claessens 54213683e2 python: Remove warning about invalid install path
It was originally added because proper detection was not working on
Debian, but that has been fixed since. It was causing annoying warning
by default when prefix is /usr/local that can only be avoided by setting
options.
2022-03-16 07:03:43 -04:00
Eli Schwartz 68b8fbcf6d Revert "devenv: Set PYTHONPATH where we install python modules"
This reverts commit 79c6075b56.

# Conflicts:
#	docs/markdown/snippets/devenv.md
#	mesonbuild/modules/python.py
#	test cases/unit/91 devenv/test-devenv.py

PYTHONPATH cannot be reliably determined. The standard use case for
installing python modules with Meson is mixed pure sources (at least
`__init__.py`) and compiled extension_modules or configured files.
Unfortunately that doesn't actually work because python will not load
the same package hierarchy from two different directories, one a source
directory and one a (mandatory) out of tree build directory.

(It kind of can, but you need to do what this test case accidentally
stumbled upon, which is namespace packages. Namespace packages are a
very specific use case and you are NOT SUPPOSED to use them outside that
use case, so people are not going to use them just to circumvent Meson
devenv stuff as that would have negative install-time effects.)

Adding PYTHONPATH anyway will just lead to documentation commitments
which we cannot actually uphold, and confusing issues at time of use
because some imports *will* work... and some will *not*. The end result
will be a half-created tree of modules which just doesn't work together
at all, but because it partially works, users attempting to debug it
will spend time wondering why parts of it do import.

For any case where the automatic devenv would work correctly, it will
also work correctly to use `meson.add_devenv()` a single time, which is
very easy to manually get correct and doesn't provide any significant
value to automate.

In the long run, an uninstalled python package environment will require
"editable installs" support.
2022-03-15 11:22:59 +02:00
Paolo Bonzini 7c20890a05 sourceset: reorder fields in SourceSetRule
Keep conditions first, then "if true" fields, and the if_false sources last.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-03-14 10:27:38 -07:00
Paolo Bonzini 94be5b8b48 sourceset: document fields of SourceSetRule
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-03-14 10:27:38 -07:00
Paolo Bonzini 6dd04ce57c sourceset: improve typing of SourceSetRule
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-03-14 10:27:38 -07:00
Paolo Bonzini 9d42e58ea2 sourceset: reinstate extra_deps
Dependencies in the "if_true" keyword argument do not prevent the
sources from being used; in other words, they work just like dependencies
with "disabler: false".

However, this was broken in commit ab0ffc6a2 ("modules/sourceset: Fix
remaining typing issues", 2022-02-23) which changed logic instead of
just fixing typing issues.  This was likely an attempt to avoid using
"dependencies.Dependency" after the "dependencies" field was declared,
but it also broke QEMU.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-03-14 10:27:38 -07:00
Paolo Bonzini 076855c22f sourceset: rename "dependencies" fields to deps
The dependencies field clashes with the dependencies module, so that
mypy interprets "dependencies.Dependency" as a "Dependency" attribute
of the "dependencies" field.

Rename the field to something else, so that it does not clash.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-03-14 10:27:38 -07: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
Ralf Gommers 44104e820a Remove a spurious debug print in Python module
This prints many lines of unwanted "done /absolute/path",
I noticed this when testing 0.62.0rc1 with SciPy.

[ci skip]
2022-03-10 15:30:31 -05:00
Tristan Partin 2c03b2bb7f Move dataonly pkgconfig file to datadir/pkgconfig
dataonly files are architecture independent (lib vs lib64 for example).

Fixes #9902
2022-03-09 17:50:41 -05: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 2540ad6e9e
fix correctly detecting whether python is found if link args are empty
There are two cases where we can assume we found the python dependency
with its requisite libraries using sysconfig:

- we found the library with find_library and are prepared to link to it
- the library is not actually part of the dependency, so its presence or
  absence is irrelevant

In the latter case, we should consider it found if link_libpython is
False. Originally we did this, but the logic was inverted in commit
5b422fce87 in an unrelated change and
without explanation, likely by accident.

Normally this doesn't much matter, since a python invariably comes with
a predictably located libpython and the first condition evaluates true.
But that is not true for pypy, and in fact that is the reason the
link_libpython check was originally added in commit
1bd14b52b2.

Restore that original logic.

Fixes #8570
2022-03-07 20:35:43 -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
Eli Schwartz 187dc656f4
merge various TYPE_CHECKING blocks into one
A bunch of files have several T.TYPE_CHECKING blocks that each do some
things which could just as well be done once, with a single `if`
statement. Make them do so.
2022-03-07 19:01:04 -05:00
Tristan Partin d072ebc955 Fix @typed_pos_args on java.generate_native_headers 2022-03-07 15:42:07 -08:00
Dylan Baker 7d1431a060 build: plumb structured sources into BuildTargets 2022-03-07 12:33:33 -08:00
Jussi Pakkanen ade6e3a19e
Merge pull request #10043 from dcbaker/submit/type-checking-for-subproject
Add typing for subproject()
2022-03-07 16:43:44 +02:00
Eli Schwartz 8b573d7dc6
i18n.merge_file: do not disable in the absence of gettext tools
Disabling targets because the tools used to build them aren't available
is a pretty suspicious thing to do. Users who want this are probably, in
general, advised to check themselves whether it is possible to build
those targets with find_program(..., required: false)

The i18n.gettext() invocation is a bit unusual because the product of
running it is non-critical files, specifically, translation catalogs. If
users don't have the tools needed to build them, they may not be able to
use them either, because perhaps they have NLS disabled on their
platform or it's difficult to put it in the bootstrap path.

So, for this reason, it was made non-fatal and the message catalogs are
just not created, and the resulting build is still perfectly usable
*unless* you want to use it in another language, at which point it
"works" but the text is all inscrutable to the end user, and that's a
feature of the target platform.

That's an acceptable tradeoff for translation catalogs.

It is NOT an acceptable tradeoff for merge_file, which produces desktop
files or MIME database catalogs or other files which have crucial roles
to perform, without which the software in question simply doesn't work
at all. In such cases, this just fails to install crucial files, users
report bugs to the project in question, and the project adds
`find_program('xgettext')` to guarantee the hard error due to lack of
confidence in Meson.

Fixes #6165
Fixes #8436
2022-03-06 11:09:56 -05:00
Eli Schwartz 1f3640c7db
i18n module: report initial call site when disabling translation support 2022-03-06 11:09:56 -05:00
Eli Schwartz 08928821ec
i18n module: detect gettext tools at configure time
Use this instead of shutil.which to detect whether they will be
available, and pass the ExternalProgram object to CustomTarget
invocations, or else make use of the new functionality to specify the
correct program path in wrapper scripts.

Drop duplicate reporting for itstool missing. Since we use find_program
in required mode, its absence is already fatal, and already has a really
good error description.
2022-03-06 11:09:47 -05:00
Eli Schwartz e67fd1f551
i18n module: fix bug that made msgfmthelper die on combinations of args
Due to misuse of argparse in commit 82492f5d76
it was impossible to use both --datadirs and extra args passed directly
to msgfmt at the same time.

I'm not sure anyone actually knows how argparse works, so misusing it is
easy. What is definitely known is that argparse is NOT a POSIX compliant
parser and doesn't behave the way you'd expect a standards based parser
to handle options. Instead it caters to the easy use case, and hopes and
prays you don't need to do anything too complicated "with the wrong kind
of complicated".

Apparently, this particular type of complicated is when you have mixed
option_arguments and operands while simultaneously passing some operands
as nargs after a --.

It totally breaks, and interprets --datadirs, which is supposed to be an
option_argument, as an operand, eats it up as a msgfmt wrapped argument,
and breaks.

But if you don't pass additional arguments with -- then it interprets
--datadirs after operands as an option_argument. This is what we were
doing.

Instead pass option_arguments before all operands (including the ones
specified via `-- ...`). Add test case to pass meaningless datadirs (we
don't actually care if $GETTEXTDATADIRS is set to something that doesn't
contain gettext data).
2022-03-06 10:48:34 -05:00
Xavier Claessens e80a9c2cba wayland module: Allow building both client and server sides
- Change `scope` kwarg to `public` boolean default to false.
- Change `side`  kwarg to `client` and `server` booleans.
- Document returned values
- Aggregate in a single unit test because have lots of small tests
  increases CI time.

Fixes: #10040.
2022-03-06 06:31:43 -05:00
Tristan Partin 5048390a98 Port JavaModule to NewExtensionModule API 2022-03-04 14:59:02 -08:00
Tristan Partin 1960810d64 Fix @typed_pos args on java.generate_native_header 2022-03-04 14:59:02 -08:00
Dylan Baker 3e90f27703 interpreter: replace build_def_files with OrderedSet
We do a bunch of backbending to make sure we don't have duplicates,
let's just use the right datastructure to begin with.
2022-03-03 10:29:14 -08:00
Dylan Baker 5787f81615 interpreter: add cm_interpreter to SubprojectHolder
This is used in the cmake module, as an extra attribute we just tack on.
Instead, let's actually define and type it.
2022-03-03 10:29:14 -08:00
Dylan Baker 4a2058cb83 interpreter: use typed_kwargs for subproject() 2022-03-03 10:29:14 -08:00
Dylan Baker f4ae32c2ad modules/cmake: add type annotations for subproject method
This will be used to handle the interpreter subproject as well
2022-03-03 10:29:14 -08:00
Remi Thebault 4fe6f0dd29 add D features to InternalDependency 2022-03-03 08:42:56 -08:00
Tristan Partin 18147b91ff Deprecate java.generate_native_header() in favor of java.generate_native_headers()
After implementing a much more extensive Java native module than what
currently exists in the tests, I found shortcomings.

1. You need to be able to pass multiple Java files.
2. Meson needs more information to better track the generated native
   headers.
3. Meson wasn't tracking the header files generated from inner classes.

This new function should fix all the issues the old function had with
room to grow should more functionality need to be added. What I
implemented here in this new function is essentially what I have done in
the Heterogeneous-Memory Storage Engine's Java bindings.
2022-03-01 13:18:50 -08:00
Eli Schwartz d39b330075 clean up FeatureCheck signature to move location to use time
The point of a .use() function is because we don't always have the
information we need to use a feature check, so we allow creating the
feature and then storing it for later use. When implementing location
checks, although it is optional, actually using it violated that design.

Move the location out of the init method for FeatureCheck itself. It
remains compatible with all cases of .single_use(), but fix the rest up.
2022-03-01 12:13:24 -08:00
Xavier Claessens 79c6075b56 devenv: Set PYTHONPATH where we install python modules 2022-02-28 09:03:27 -05:00
Xavier Claessens c4b8c23eb1 Add API for modules that wants to define their devenv 2022-02-28 09:03:27 -05:00
Xavier Claessens ad75a2bfec modules: Make ExtensionModule inherit from NewExtensionModule
It reduces duplicated code.
2022-02-28 09:03:27 -05:00
Xavier Claessens c5c02b72e1 Cache the result of python.find_installation()
This avoids running sanity checks everytime find_installation() is
called.
2022-02-28 09:03:27 -05:00
Eli Schwartz 880d5000b2
sourceset module: fix minor regression in making sourcesets immutable
In commit c0be7e05b0 the setting of merged
sourcesets as immutable in a loop accidentally got dedented, and only
applied to the last loop iteration.
2022-02-27 15:20:34 -05:00
Mark Bolhuis 5a4177523e modules/wayland: Add unstable_wayland module 2022-02-27 14:33:33 -05:00
Andrea Pappacoda fcca265035 cmake: configure_package_config_file can now take a dict 2022-02-27 11:45:26 -05:00
Andrea Pappacoda c42a3fd2fb cmake: typed_kwargs for configure_package_config_file 2022-02-27 11:45:26 -05:00
Dylan Baker 57c8e1a780 run_mypy: add sourceset module 2022-02-23 10:18:34 -08:00
Dylan Baker ab0ffc6a22 modules/sourceset: Fix remaining typing issues 2022-02-23 10:18:34 -08:00
Dylan Baker c0be7e05b0 modules/sourceset: use typed_kwargs for all functions
removing permittedKwargs usage
2022-02-23 10:18:34 -08:00
Dylan Baker 5dc355105a modules/sourceset: Use typed_pos_args 2022-02-23 10:18:34 -08:00
Dylan Baker d39bb133f0 modules/sourceset: add a few super easy type annotations 2022-02-23 10:18:34 -08:00
Dylan Baker 8712afd35e modules/sourceset: sort imports 2022-02-23 10:18:34 -08:00
Eli Schwartz 78945fb983
python module: add option to specify a python environment to install to
The default behavior of installing relative to prefix may be unexpected,
and is definitely wrong in many cases.

Give users control in order to specify that yes, they actually want to
install to a venv.

This is particularly useful for projects that use meson as a build
system for a python module, where *all* files shall be installed into
the python site-packages.
2022-02-22 22:22:16 -05:00
Eli Schwartz e8375d20a9
modules: add ModuleState API to check whether an option was user-specified
Needed to check exclusivity of module options.
2022-02-22 22:22:15 -05:00
Eli Schwartz 9daaece785
flake8: fix various whitespace errors with badly aligned code 2022-02-16 23:00:31 -05:00
Eli Schwartz 6240920c21
pkgconfig module: allow custom variables to reference builtin directories
Automatically generate additional variables and write them into the
generated pkg-config file.

This means projects no longer need to manually define the ones they
use, which is annoying for dataonly usages (it used to forbid setting
the base library-relevant "reserved" ones, and now allows it only for
dataonly. But it's bloat to manualy list them anyway).

It also fixes a regression in commit
248e6cf473 which caused libdir to not be
set, and to be unsettable, if the pkg-config file has no libraries but
uses the ${libdir} expansion in a custom variable. This could be
considered likely a case for dataonly, but it's not guaranteed.
2022-02-15 16:50:41 -05:00
Andrea Pappacoda 316cf3a717 cmake: add arch_independent kwarg
CMake's write_basic_package_version_file has supported since version 3.14
an ARCH_INDEPENDENT option that makes it skip its architecture check in
the Version file.

With this patch Meson now supports it as well, and the change is also
compatible with older CMake versions, as they will simply ignore the
option.

This also slightly changes the contents of the generated Version file
when arch_independent is not set: previously, the if() needed to skip
the arch check was always filled with an empty string, while CMake puts
"FALSE" (or "TRUE") in it. Now, that if() will always be filled with
either "False" or "True", better matching CMake's behaviour.
2022-02-01 23:48:17 -05:00
Andrea Pappacoda a755750cae cmake: typed_kwargs for write_basic_package_version_file 2022-02-01 23:48:17 -05:00
Andrea Pappacoda 248e6cf473 pkgconfig: set libdir only if used
This should address some concerns outlined in
https://github.com/yhirose/cpp-httplib/pull/1182
2022-02-01 12:23:06 -08: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
Eli Schwartz 3990dc6d64 flake8: fix indentation style 2022-01-27 10:48:01 -08:00
Eli Schwartz cf3a1d31f8 fix some flake8 violations for unused imports
And one undefined T.cast name in a file that isn't yet mypy-ready
anyway.
2022-01-27 10:48:01 -08:00
Eli Schwartz d73e81c77b
Popen_safe and wrappers can accept os.PathLike for cwd
Do not require users to convert it to a string first. This is a waste of
time and effort for exactly the same results.
2022-01-26 22:08:09 -05:00
Bilal Elmoussaoui dd4e712024 gnome: Fix gtk4 pkgconfig name 2022-01-26 21:31:20 -05:00
Eli Schwartz 603244b059
fix broken version annotations for the new itstool_join feature
It was not added in 0.61.0 as that was already released.
2022-01-22 22:11:32 -05:00
Jussi Pakkanen 4316b71017
Merge pull request #9742 from ximion/wip/itstool
i18n: Add support for joining XML localization via itstool
2022-01-22 01:01:29 +02:00
Matthias Klumpp 02fb0c3f8b i18n: Add support for joining XML localization via itstool 2022-01-21 22:26:17 +01:00
Eli Schwartz 2a99252604
python module: only find a pkg-config dependency from the found python
If the found python returns None from sysconfig.get_config_var('LIBPC')
then we cannot (and don't) set PKG_CONFIG_LIBDIR from it. In fact, we
can virtually guarantee we won't find a PkgConfigDependency either,
because any python that doesn't have a LIBPC is presumably not installed
to the system pkg-config directory (maybe it's an isolated relocatable
install, maybe it just doesn't have pkg-config support for who knows
what reason).

Trying to find one anyway using pkg-config's builtin search paths can
unexpectedly succeed, though, by finding a completely unrelated python
installation installed to a system location, which isn't the one we are
actually building for.

Instead, return early so that we use the system dependency class
fallback.

While we are at it, add back the debug messages from #3989 which got
removed.
2022-01-20 23:50:04 -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 5074e2d3b5 interpreter: replace ConfigurationDataObject with ConfigurationDataHolder
This is much cleaner, and more in line with the way we handle
interpreter objects in modern meson practice
2022-01-18 17:53:29 -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
Eli Schwartz 81fbcd1df4
fix broken module tests which caused gtkdoc-check to traceback on assert
Regression in commit 566c2c9a9c.

The interpreter details are a bit of black magic. Functions expect
tuples, but they receive lists and then the type-checking decorators
convert those to tuples.

So, directly manhandling a self._interpreter.func_*() but passing it the
tuple it nominally expected, actually explodes in your face by way of
failing an assert, then dumping 'ERROR: Unhandled python exception'.

Fixes use of gnome.gtkdoc(..., check: true), for example when building
glib.
2022-01-10 23:06:51 -05: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
Eli Schwartz f67994476d remove the RPM module
It is unmaintained, broken (frequently for long periods of time) and not
really required for any meson functionality. Its purpose is to be used
as a one-shot tool for creating a distro package recipe, and then
deleted from your meson.build files.

Due to its fragile dependency on coredata implementation details, we
cannot assume it will reliably work, or continue to work, without
someone who is actively willing to take responsibility for it.

Even if that were to happen, this might be better off as an external
script that parses introspection data.

Closes #9764
Closes #9763
2022-01-10 20:21:40 +02: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
Eli Schwartz 688b4bac76 add FeatureNew decorators for various modules that were lacking them
Going back to 0.38, though some of them are far older. The original
implementation of FeatureNew only added backdated feature checks that
far, anyway.
2021-12-31 12:03:57 +02:00
Xavier Claessens 95a4c6a62a pkgconfig: Fix linking to a custom target
When generating pkgconfig file for a library that links to an
uninstalled static library built by custom_target() Meson was crashing
when trying to access some attributes that does not exist on that class.

Also fix is_internal() implementation, it only really make sense on a
CustomTargetIndex or if CustomTarget has only a single output.
2021-12-22 08:04:08 +05:30
Eli Schwartz ee0baa97cd modules: use find_program implementation to find programs
Do not use ExternalProgram as that is too low-level and doesn't handle
e.g. machine file overrides.

Fixes #9733
2021-12-21 12:17:10 +01:00
Eli Schwartz 6be258137e
modules: let the proxy state find_program do silent lookups 2021-12-20 16:03:43 -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
Matthias Klumpp efd7c7f228 i18n: Fix typo for typed_pos_args 2021-12-18 04:43:19 +01:00
Daniel Mensinger c5ce9744b2 Fix mypy errors 2021-12-17 14:00:28 -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
Dylan Baker 4f0c5af390 modules/qt: compeil_resources allow name to be unset
Originally name should have been set to required=True, but since then
the requirement to name CustomTargets (which compile_resources is a
wrapper around) has been dropped. As such we just need to allow the
default value of None through.

Fixes: #9698
2021-12-05 08:33:32 -08: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
Eli Schwartz 172fa4d3b2
i18n module: correctly annotate the availability of data_dirs
It was originally forgotten in merge_file() and later added for parity
with gettext(). This means that the FeatureNew for each function is
different.
2021-12-02 12:29:58 -05:00
Dylan Baker 904771c4e1 modules/keyval: add type annotations
And use typed_pos_args
2021-11-23 13:20:11 -08:00
Dylan Baker 717d03af1c modules/keyval: cleanup imports 2021-11-23 13:15:28 -08: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
Paolo Bonzini 47ba919b21 rust: clean up inputs and outputs to bindgen
Make the handling of bindgen inputs consistent with the inputs and outputs of
source_strings_to_files.

However, for the first source argument reject anything that cannot
possibly be an header file.  This also fixes a mypy failure from the next
patch, since ExtractedObjects does not have a zero-argument get_outputs
method.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-11-23 18:10:15 +05:30
Eli Schwartz 5163a02fec
qt module: fix stupid copy-paste error
As evidenced by the warning message immediately below this, I meant to
write "5.15" here. As is, this will enable depfile support on too-old
versions of moc.
2021-11-22 16:28:13 -05:00
Chris Lamb 958b1a7fb4 Make the generated reproducible .cmake files reproducible.
Whilst working on the Reproducible Builds effort [0], I noticed that meson did
not generate reproducible .cmake files: they include the full path name.

This commit not only makes the build reproducible, but it also matches CMake's
own behaviour. Specifically, CMakePackageConfigHelpers.cmake does the
equivalent transformation using:

    get_filename_component(inputFileName "${_inputFile}" NAME)

I originally filed this in Debian as bug #1000327 [1].

 [0] https://reproducible-builds.org/
 [1] https://bugs.debian.org/1000327
2021-11-21 14:38:33 -05: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
Xavier Claessens 018d928cf5 i18n: Fix backtrace when missing input kwarg
When input kwarg is missing in i18n.merge_file() it was crashing with a
backtrace because of kwargs['input'][0]. That code was useless anyway
because CustomTarget now uses first output as default name which is what
we need here.
2021-11-16 23:35:46 -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
Matthew Brett bd5e520672 Fix to find Python files for Windows virtualenvs
Virtualenvs do not have their Python DLLs etc in the `sys.prefix`
directory, but in the `sys.base_prefix` directory.  This directory is
the same as `sys.prefix` if not in a virtualenv, so is safe for either
case:

https://docs.python.org/3/library/sys.html#sys.base_prefix
2021-11-15 23:20:48 +02:00
Jussi Pakkanen cad109607d
Merge pull request #9520 from dcbaker/submit/gnome-first-typed-kwargs
Add typed_kwargs to some of the gnome module functions
2021-11-15 22:07:03 +02:00
Eli Schwartz 0bc0905210
qt module: add depfile support to moc as well
We currently enable this only for rcc (where this really really matters)
but it can often matter for moc as well, and is just generally more
correct.

Really, this should have been added in #7451 too, but I neglected it
since the module warned about inaccurate dependencies only for rcc...
2021-11-13 23:28:59 -05:00
Xavier Claessens 898bf6e518 python: Better detect when install path is not in sys.path
Using pathlib ensure propre platform specific path handling, such as
case sensitivity.
2021-11-09 18:49:03 +02:00
Dylan Baker ef52e60936 modules/gnome: use typed_kwargs for gdbus_codegen 2021-11-08 12:39:38 -08:00