Commit Graph

107 Commits

Author SHA1 Message Date
Dylan Baker afa8e31cf3 modules/qt: Fix annotations for state.find_program
Because this too, has the wrong assumptions
2023-01-10 09:53:22 -08:00
Hagen Möbius 6860e42c06 Raise an error, if the file element in a resource file has no text.
- minor cleanups in the vicinity
2022-11-14 00:26:55 +02:00
Dylan Baker 188c552dcf pylint: enable use-maxsplit-arg
This finds a bunch of places where we can do more efficient string
splitting.
2022-09-19 20:57:52 -04:00
Eli Schwartz 1e1dee738b qt module: correctly compare program name for lrelease version
(b, name) will always have the canonical tool name, not just a
potentially weird bin path. We need to check stderr for qt4 tools other
than lrelease, but we keyed off of the tool bin path, so matches were by
no means guaranteed, and specifically, would fail if the tool is looked
up via bindir.

This really should always have checked the canonical name, which is
guaranteed to be correct.

Partial fix for #10443
2022-07-25 21:56:11 -07: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
Eli Schwartz 93ed7531c4 qt module: fix missing sanity check for install_dir + install
Regression in commit 11f9638035. When
`install: true` the install_dir must be set. The CustomTarget
initializer no longer checks this for us, so we must include the check
ourselves.
2022-04-30 11:49:12 +03:00
Eli Schwartz 945252a3bb qt module: fix broken install_dir kwarg
Regression in commit 11f9638035. We expect
exactly one string as an install_dir, but CustomTarget started expecting
it to be a list. So we need to pass it as such when forwarding
compile_translations() arguments to the CustomTarget initializer.
2022-04-30 11:49:12 +03:00
Eli Schwartz 22b9a66f7c
qt module: move comment to the correct location after refactoring
In commit f291b637b1 the tools were moved
around but a comment got forgotten. Now, in order to be meaningful and
remind us of anything, it needs to be in a different location.
2022-04-14 18:37:04 -04:00
Eli Schwartz d68a0651e4
qt module: also prefer the changed name scheme for the tools
Although Qt6 has decided these are "internal" commands and should never
be run directly, so they don't get symlinked to /usr/bin at all, and are
only available in the qt_dep.bindir anyway.

But, the general naming pattern should be followed on principle.
2022-04-12 20:44:51 -04:00
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
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
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 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 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
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
Eli Schwartz 32821be623
add location nodes to some Feature calls 2021-11-20 20:48:30 -05: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
Eli Schwartz 8947352889 fix various flake8 whitespace errors 2021-10-27 09:51:52 -04:00
Christian Clauss a5020857f3 Fix typos discovered by codespell 2021-10-10 16:12:25 -04:00
Dylan Baker c3c30d4b06 interpreter: Use typed_kwargs for func_custom_target
This does not convert the build side, or remove any of the checking it
does. We still need that for other callers of custom target. What we'll
do for those is add an internal interface that defaults things, then
we'll be able to have those callers do their own validation, and the
CustomTarget validation machinary can be removed.

Fixes #9096
2021-09-30 21:01:38 +02:00
Dylan Baker 9795323b86 pylint: check for duplicate imports
I ran into one of these from LGTM, and it would be nice if pylint could
warn me as part of my local development process instead of waiting for
the CI to tell me.
2021-09-24 10:36:05 -07:00
Eli Schwartz f291b637b1
qt module: consolidate on one list of bins 2021-09-10 17:57:28 -04:00
Eli Schwartz d2bf77342e
qt module: fix regression in building translations via qresource
In commit 3c4c7d0429 the qresource
variable stopped being overwritten with a mesonlib.File, which is
reasonable. However, one call site for it which relied on being a built
file did not get renamed when needed.

Make the build target use the built file.
2021-09-10 17:57:28 -04:00
Eli Schwartz 7171d22f5f
qt module: correctly register a found tool and stop looking for it
Regression in commit d7ac2f1065 since
self.{tool_name} is not how it used to be tracked, and the "found"
dictionary is a legacy of the old location.
2021-09-10 17:57:28 -04:00
Dylan Baker 11fbaf29d8 interpreter: fix cases of `KwargInfo(..., T, default=None)`
The correct way to mark these is `KwargInfo(..., (T, type(None)))`.
There's also a few cases of `(T, None)` which is invalid, as `None`
isn't a type
2021-08-27 14:54:29 -07:00
Dylan Baker a7f3703440 modules/qt: Allow using generated sources for compile_translations ts_files 2021-08-18 19:47:07 -07:00
Dylan Baker a16335a958 modules/qt: Allow Generated sources in compile_resources 2021-08-18 19:46:47 -07:00
Dylan Baker ff573620b0 modules/qt: allow passing generated targets to compile_ui 2021-08-18 19:46:47 -07:00
Dylan Baker 965fcf2883 modules/qt: Allow generated sources for arguemnts to compile_moc 2021-08-18 19:46:47 -07:00
Xavier Claessens 8c5aa031b5 Add install tags
Fixes: #7007.
2021-08-17 15:19:18 -04:00
Dylan Baker 5583e44826 qt: Allow CustomTargets for qt.preprocess source arguments
This works for `moc_*` and `ui_files`, but it never could have worked
for `qresources` due to the implementation assuming a `str` or `File`.
To restore previous compatibility I've added `CustomTarget` where it
would have worked, but not where it would have failed, the former would
raised an exception along the lines anyway.

Fixes #9007
2021-07-23 00:46:22 +05:30
Dylan Baker 3e66bd4035 modules/qt: use _impl private methods to avoid incorrect FeatureNew
`qt.preprocess` dispatches to the individual methods instead of
duplicating all of the logic itself, but this means that it goes through
the type checking, and feature checking a second time. To avoid this we
need to use a private helper method instead.

Fixes #8920
2021-06-27 23:59:40 +03:00
Daniel Mensinger 7c757dff71 holders: Fix the remaining code to respect the holder changes 2021-06-18 23:48:33 +02:00
Dylan Baker 79fec1ce4e modules/qt: use append rather than extend in preprocess
Because that's what we need, of course
2021-06-18 09:52:23 -07:00
Dylan Baker f7eda0e822 modules/qt: allow string values for include_directories
This should have been supported before, but wasn't.
2021-06-18 09:52:23 -07:00
Dylan Baker bfaa529a7a modules/qt: sort and clean up dependencies 2021-06-15 12:48:53 -07:00
Dylan Baker 2a8a6bb881 modules/qt: Return GeneratedListHolder instead of GeneratedList
This really shouldn't be necissary, but fixing the typing annotations of
ModuleReturnValue is much harder than just returning the Holder
directly.
2021-06-15 12:48:53 -07:00
Dylan Baker c422621317 interpreterobjects|build: use typed_kwargs for generator.process 2021-06-15 12:48:53 -07:00
Dylan Baker 2043461b87 build: Pass name of generator to initializer
It's really a property of the Generator what name to use, not something
that should be passed to each call to process files.
2021-06-15 12:48:53 -07:00
Dylan Baker 35bdaada1d interpreter|build: Do Generator keyword argument checking in the interpreter
For qt we already have all of the necissary checking in place. Now in
the interpreter we have the same, the intrperter does all of the
checking, then passed the arguments to the Generator initializer, which
just assigns the passed values. This is nice, neat, and clean and fixes
the layering violatino between build and interpreter.
2021-06-15 12:48:53 -07:00
Dylan Baker d2c1ab40a0 interpreter|build: Pass just the executable down to Generator
This requires that the interpreter has done the validation, which it now
does at all callsites. This simplifies the Generator initializer.
2021-06-15 12:48:53 -07:00
Dylan Baker d064466e8b modues/qt: Make use of typed_kwargs since/deprecation abiltiy 2021-06-15 12:48:52 -07:00
Dylan Baker 3824e30f7a modules/qt: fix remaining typing issues and add to run_mypy
This just ignores the fact taht Generator is unchecked. Generator needs
some real love in terms of type checking.
2021-06-15 12:36:05 -07:00
Dylan Baker 3c4c7d0429 modules/qt: use type checking and annotations for compile_translations 2021-06-15 12:36:05 -07:00
Dylan Baker 2bc7a1b3da modules/qt: fully annotate and check qt.has_tools 2021-06-15 12:36:05 -07:00
Dylan Baker 61ddceb3b9 modules/qt: Make use of the default=[] availability 2021-06-15 12:36:02 -07:00
Dylan Baker ffa83f7f8a modules/qt: Type anotations and cleanups
This adds a number of missing type annotations to existing functions,
and makes a few members protected instead of public, as they were never
meant to be public
2021-06-15 12:35:15 -07:00
Dylan Baker 118f70fede modules/qt: have pre-process dispatch to moc_compile
for ode sharing and simplicity
2021-06-15 12:35:15 -07:00
Dylan Baker 2322804a4d modules/qt: Add a compile_moc method
This method only compiles moc resources, nothing else
2021-06-15 12:35:15 -07:00