Commit Graph

58 Commits

Author SHA1 Message Date
Eli Schwartz 2fc7592e13
i18n module: provide targets as return value for gettext()
Users may wish to make use of these files for their own purposes.

For example, the -pot and -update-po pseudo targets could be reused in
an alias_target(), and at least one person wanted to reuse the built .mo
files as custom_target input.

Fixes #6227
2021-08-31 23:37:33 -04:00
Xavier Claessens 8c5aa031b5 Add install tags
Fixes: #7007.
2021-08-17 15:19:18 -04:00
Xavier Claessens 223991c09e Fix i18n target name when using @BASENAME@ and configure_file() input
Fixes: #9022
2021-08-09 19:43:45 -04:00
Eli Schwartz 487d45c1e5
i18n: use real build/install targets for gmo files
Don't just create a .PHONY target which runs a script that magically
generates files ninja doesn't know about. It results in untracked files,
and `meson install` has to run additional commands instead of copying
over files, and then cannot track them to uninstall them later.

I'm not even really sure why it was originally done via a proxy script,
most likely bad legacy design. This is after all one of the oldest
modules...

One side effect of this is that meson doesn't know how to rename
build.CustomTarget files on install (only data files are supported?),
and every file needs to be installed as "domainname.mo" so it must be
named that in-tree too. To prevent clashes, every locale gets its own
locale-specific subdirectory.

Once we are doing that anyway, we can output them to the actual
structure required by the gettext family of functions, and
bindtextdomain() can therefore point to this location if desired. This
might be useful for running localized programs from the build tree.
2021-08-09 18:25:17 -04:00
Daniel Mensinger 34c28dc92c holders: remove unholder 2021-06-18 23:48:33 +02: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
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 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 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 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 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
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
Jussi Pakkanen 5f2e44b0dd Make gettext targets no-ops if gettext is not installed. Closes: #821. 2019-08-04 21:46:52 +03:00
Konstantin 841995cddf i18n: add args keyword to merge_file
* i18n: add args keyword to merge_file

* i18n: add testcase to msgfmt args
2019-04-22 14:54:05 +03:00
Georges Basile Stavracas Neto 5f00c30200 i18n: Use CustomTarget.known_kwargs at permittedKwargs()
@permittedKwargs() is basically copying the logic of CustomTarget,
but it is not actually up to date, leading to warnings on perfectly
valid values such as 'build_by_default'.

Use CustomTarget.known_kwargs instead, and only append the specific
kwargs of i18n.merge_file().

Fixes https://github.com/mesonbuild/meson/issues/5079
2019-03-14 05:14:29 +00:00
Frediano Ziglio 683c768fed i18n: Catch additional GLib functions
Add some missing functions having C-format strings to the list.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-02-16 15:00:06 +02:00
Sergey Shatunov c07e5124bc Add install_dir to i18n.gettext 2019-01-26 23:29:05 +02:00
Jussi Pakkanen fe3efe0bc6 Fix merge file using an array. Closes #4424. 2018-10-29 23:33:21 +02:00
Jon Turney 99b0a7acda Fix flake8 whitespace reports
$ flake8 | grep -E '(E128|E203|E221|E226|E303|W291|W293)'
./mesonbuild/backend/backends.py:32:1: E303 too many blank lines (3)
./mesonbuild/modules/i18n.py:90:56: E128 continuation line under-indented for visual indent
2018-10-24 19:11:46 +03:00
Marty E. Plummer 8fd5297f76 i18n: replace path separator with @
using state.subdir will cause / or \ to be inserted into the target name.
Replace them with @ to future-proof it.

Signed-off-by: Marty E. Plummer <hanetzer@startmail.com>
2018-10-06 03:10:11 -07:00
Jussi Pakkanen 2ff69b20df Fix handling generated .desktop files. Closes #4304. 2018-10-05 00:48:22 +03:00
Marty E. Plummer add55bb861 i18n: allow custom target names for merge_file
As it currently stands, if for whatever reason you have two files you
want to merge with the same output name, it will fail due to multiple
targets with the same name due to the target name being autogenerated
from the output kwarg.

Signed-off-by: Marty E. Plummer <hanetzer@startmail.com>
2018-09-16 15:08:43 +03:00
Corentin Noël 176af2c8c3 i18n: respect variable substitution for the target name when merging translations
Previously it wasn't possible to use twice @BASENAME@ as the targets would then be named @BASENAME@_merge
2018-09-03 22:34:22 -07:00
Salamandar accea4889b Add 0.37.0 features 2018-06-01 14:23:24 +02:00
Jussi Pakkanen 998892ed29 Updated all modules to work with the new API. 2018-04-15 13:32:38 +05:30
Martin Kelly 02bea7d5bf namespace run_targets by subproject
Currently, run_target does not get namespaced for each subproject,
unlike executable and others. This means that two subprojects sharing
the same run_target name cause meson to crash.

Fix this by moving the subproject namespacing logic from the BuildTarget
class to the Target class.
2017-10-31 01:04:38 +02:00
Jussi Pakkanen be0aa7fd74 Merge pull request #2357 from LukeShu/flake8
Bring into compliance with flake8
2017-09-22 21:33:34 +03:00
Luke Shumaker 4dbbb4884c flake8: Clean up complained-about unused imports
This also adds a "# noqa: F401" comment on an unused "import lzma",
which we are using it in a try/except block that is being used to
check if the lzma module is importable; of course it is unused.

v2: This turned out to be a little tricky.

    mesonbuild/modules/__init__.py had the "unused" import:

        from ..interpreterbase import permittedKwargs, noKwargs

    However, that meant that the various modules could do things like:

        from . import noKwargs # "." is "mesonbuild.modules"

    Which breaks when you remove __init__.py's "unused" import.  I
    could have tagged that import with "# noqa: F401", but instead I
    chose to have each of the module import directly from
    "..interpreterbase" instead of ".".
2017-09-21 13:41:03 -04:00
Luke Shumaker bb25260f00 flake8: Perform suggested whitespace/formatting changes
This only touches newlines, spaces, and (occaisionally) commas.  Anything
else is left for another commit.
2017-09-21 11:59:03 -04:00
Corentin Noël 3e6c3ea10c Change ternary to another argument 2017-09-20 20:34:20 +02:00
Corentin Noël 6a2926870c Add 'install' keyword to the gettext macro 2017-09-20 20:17:59 +02:00
Jussi Pakkanen 50fb7d37ab Make all functionality invokable via the main Meson binary,
which can be a Windows .exe file.
2017-08-18 12:08:20 +03:00
Iñigo Martínez b43f4841ba i18n: Fixed gettext permitted Kwargs list 2017-07-20 12:28:45 +03:00
Jussi Pakkanen 3262be23dc Fixed issues raised in review. 2017-06-26 23:29:42 +03:00
Jussi Pakkanen 80d665e8de Converted some modules. 2017-06-26 21:10:27 +03:00
Patrick Griffis 12504b2385 i18n: Fix handling relative data_dirs 2017-04-29 04:05:20 -04:00
Patrick Griffis 82492f5d76 i18n: Add data_dirs kwarg to merge_file()
For parity with gettext()

Fixes #1565
2017-04-29 04:05:20 -04:00
Jussi Pakkanen fbabe8ad85 There are two different kinds of extensions: modules that create new
objects directly and snippets that just call into interpreter methods.
2017-01-09 21:11:48 +02:00
Jussi Pakkanen 570c9b150b Fix a few more modules. 2017-01-06 19:22:56 +02:00
Jussi Pakkanen 56e2c46ce1 Merge pull request #1272 from mesonbuild/ignatenko/lint
fix some linting errors
2017-01-03 16:04:24 -05:00
Jussi Pakkanen 027af6b064 Error out if trying to do gettext without appropriate tools. 2017-01-03 15:10:38 -05:00
Igor Gnatenko cdd05aa5dc style: fix E241 violations
E241: multiple spaces after ','

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-02 19:12:52 +01:00
Jussi Pakkanen a2528a8816 Merge pull request #1233 from mesonbuild/wip/ignatenko/code-style
Trivial cleanups in code
2016-12-21 00:09:44 +02:00
Nirbheek Chauhan 589a56e78f Cache the scripts used for postconf and install phases
Cache the absolute dir that the script is searched in and the name of
the script. These are the only two things that change.

Update the test to test for both #1235 and the case when a script of the
same name is in a different directory (which also covers the subproject
case).

Closes #1235
2016-12-20 00:09:02 +02:00
Igor Gnatenko 139e020ede tree-wide: use proper 'not in' notation
Let's be more pythonic and 'not is' seems really weird.

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 21:48:35 +01:00
Nirbheek Chauhan c693bd9bb4 Allow passing arguments to install scripts
Closes #1213
2016-12-18 18:30:47 +02:00
Patrick Griffis 155617e539 i18n: Improve language handling
- Fix LINGUAS changes not being picked up
- Fix multiple langs per line in LINGUAS
- Make empty languages acceptable

Fixes #1127
2016-12-06 20:29:20 +02:00
Patrick Griffis acb0a38aac i18n: Add preset kwarg
Many frameworks, such as glib, provide translation functions and
functions that take format strings. As such every application using
these must duplicate the gettext arguments to function properly.

This reduces that duplication and improves correctness so they are
not left out.

Fixes #1123
2016-12-03 21:01:48 +02:00
Patrick Griffis 7d68715297 i18n: Add merge_file function
This is a repeated task that we can simplify

Closes #1120
2016-12-03 21:00:20 +02:00