1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

doc: stop build of docs if a locale is missing, add CMake option "ENABLE_DOC_WARN_LOCALE" (closes #1985)

This commit is contained in:
Sébastien Helleu
2023-07-31 21:27:16 +02:00
parent 1ffd0a58b9
commit 8bfd25e2e6
5 changed files with 109 additions and 36 deletions
+34 -33
View File
@@ -95,39 +95,40 @@ else()
set(INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME}")
endif()
option(ENABLE_NCURSES "Compile the Ncurses interface" ON)
option(ENABLE_HEADLESS "Compile the headless binary" ON)
option(ENABLE_NLS "Enable Native Language Support" ON)
option(ENABLE_LARGEFILE "Enable Large File Support" ON)
option(ENABLE_ALIAS "Enable Alias plugin" ON)
option(ENABLE_BUFLIST "Enable Buflist plugin" ON)
option(ENABLE_CHARSET "Enable Charset plugin" ON)
option(ENABLE_EXEC "Enable Exec plugin" ON)
option(ENABLE_FIFO "Enable FIFO plugin" ON)
option(ENABLE_FSET "Enable Fast Set plugin" ON)
option(ENABLE_IRC "Enable IRC plugin" ON)
option(ENABLE_LOGGER "Enable Logger plugin" ON)
option(ENABLE_RELAY "Enable Relay plugin" ON)
option(ENABLE_SCRIPT "Enable Script plugin (script manager)" ON)
option(ENABLE_SCRIPTS "Enable script plugins (perl, python, …)" ON)
option(ENABLE_PERL "Enable Perl scripting language" ON)
option(ENABLE_PYTHON "Enable Python scripting language" ON)
option(ENABLE_RUBY "Enable Ruby scripting language" ON)
option(ENABLE_LUA "Enable Lua scripting language" ON)
option(ENABLE_TCL "Enable Tcl scripting language" ON)
option(ENABLE_GUILE "Enable Scheme (guile) scripting language" ON)
option(ENABLE_JAVASCRIPT "Enable JavaScript scripting language" OFF)
option(ENABLE_PHP "Enable PHP scripting language" ON)
option(ENABLE_SPELL "Enable Spell checker plugin" ON)
option(ENABLE_ENCHANT "Use Enchant lib in Spell checker plugin" OFF)
option(ENABLE_TRIGGER "Enable Trigger plugin" ON)
option(ENABLE_TYPING "Enable Typing plugin" ON)
option(ENABLE_XFER "Enable Xfer plugin" ON)
option(ENABLE_MAN "Enable build of man page" OFF)
option(ENABLE_DOC "Enable build of documentation" OFF)
option(ENABLE_DOC_INCOMPLETE "Enable incomplete doc" OFF)
option(ENABLE_TESTS "Enable tests" OFF)
option(ENABLE_CODE_COVERAGE "Enable code coverage" OFF)
option(ENABLE_NCURSES "Compile the Ncurses interface" ON)
option(ENABLE_HEADLESS "Compile the headless binary" ON)
option(ENABLE_NLS "Enable Native Language Support" ON)
option(ENABLE_LARGEFILE "Enable Large File Support" ON)
option(ENABLE_ALIAS "Enable Alias plugin" ON)
option(ENABLE_BUFLIST "Enable Buflist plugin" ON)
option(ENABLE_CHARSET "Enable Charset plugin" ON)
option(ENABLE_EXEC "Enable Exec plugin" ON)
option(ENABLE_FIFO "Enable FIFO plugin" ON)
option(ENABLE_FSET "Enable Fast Set plugin" ON)
option(ENABLE_IRC "Enable IRC plugin" ON)
option(ENABLE_LOGGER "Enable Logger plugin" ON)
option(ENABLE_RELAY "Enable Relay plugin" ON)
option(ENABLE_SCRIPT "Enable Script plugin (script manager)" ON)
option(ENABLE_SCRIPTS "Enable script plugins (perl, python, …)" ON)
option(ENABLE_PERL "Enable Perl scripting language" ON)
option(ENABLE_PYTHON "Enable Python scripting language" ON)
option(ENABLE_RUBY "Enable Ruby scripting language" ON)
option(ENABLE_LUA "Enable Lua scripting language" ON)
option(ENABLE_TCL "Enable Tcl scripting language" ON)
option(ENABLE_GUILE "Enable Scheme (guile) scripting language" ON)
option(ENABLE_JAVASCRIPT "Enable JavaScript scripting language" OFF)
option(ENABLE_PHP "Enable PHP scripting language" ON)
option(ENABLE_SPELL "Enable Spell checker plugin" ON)
option(ENABLE_ENCHANT "Use Enchant lib in Spell checker plugin" OFF)
option(ENABLE_TRIGGER "Enable Trigger plugin" ON)
option(ENABLE_TYPING "Enable Typing plugin" ON)
option(ENABLE_XFER "Enable Xfer plugin" ON)
option(ENABLE_MAN "Enable build of man page" OFF)
option(ENABLE_DOC "Enable build of documentation" OFF)
option(ENABLE_DOC_INCOMPLETE "Enable incomplete doc" OFF)
option(ENABLE_DOC_WARN_LOCALE "Warning instead of error on missing locale" OFF)
option(ENABLE_TESTS "Enable tests" OFF)
option(ENABLE_CODE_COVERAGE "Enable code coverage" OFF)
# code coverage
add_library(coverage_config INTERFACE)
+4
View File
@@ -44,6 +44,10 @@ Bug fixes::
* script: fix cursor position after `/script list -i` or `/script list -il`
* script: fix buffer used by command `/script list -i|-il|-o|-ol`
Build::
* doc: stop build of docs if a locale is missing, add CMake option "ENABLE_DOC_WARN_LOCALE" (issue #1985)
[[v4.0.2]]
== Version 4.0.2 (2023-07-12)
+31
View File
@@ -62,6 +62,37 @@ You can reset it with this command:
/reset weechat.key_mouse.@chat(fset.fset):button1
----
[[v4.1.0_doc_locales]]
=== Required locales for auto-generated docs
The build of auto-generated files for docs now requires all locales to be installed. +
If at least one locale is not installed, the following error is displayed:
----
doc generator: ERROR: failed to set locale "de_DE.UTF-8", these locales must be installed to build docs:
de_DE.UTF-8
en_US.UTF-8
fr_FR.UTF-8
it_IT.UTF-8
ja_JP.UTF-8
pl_PL.UTF-8
sr_RS.UTF-8
doc generator: you can turn this error as a warning with the cmake option ENABLE_DOC_WARN_LOCALE
----
A new CMake option "ENABLE_DOC_WARN_LOCALE" has been added to allow the build
of docs even if locales are missing:
----
cmake .. -DENABLE_DOC_WARN_LOCALE=ON
----
When this option is enabled, such warning is displayed and the doc is built anyway:
----
doc generator: WARNING: failed to set locale "de_DE.UTF-8", docs will include auto-generated English content
----
[[v4.0.2]]
== Version 4.0.2 (2023-07-12)
+1 -1
View File
@@ -180,7 +180,7 @@ if(ENABLE_MAN OR ENABLE_DOC)
)
endforeach()
add_custom_target(doc-autogen ALL
COMMAND "${CMAKE_COMMAND}" -E env "WEECHAT_EXTRA_LIBDIR=${PROJECT_BINARY_DIR}/src" "WEECHAT_DOCGEN_LOCALEDIR=${PROJECT_BINARY_DIR}/po" "${CMAKE_BINARY_DIR}/src/gui/curses/headless/weechat-headless" --temp-dir --doc-gen "${CMAKE_CURRENT_BINARY_DIR}/autogen"
COMMAND "${CMAKE_COMMAND}" -E env "WEECHAT_EXTRA_LIBDIR=${PROJECT_BINARY_DIR}/src" "WEECHAT_DOCGEN_LOCALEDIR=${PROJECT_BINARY_DIR}/po" "WEECHAT_DOCGEN_WARN_LOCALE=${ENABLE_DOC_WARN_LOCALE}" "${CMAKE_BINARY_DIR}/src/gui/curses/headless/weechat-headless" --temp-dir --doc-gen "${CMAKE_CURRENT_BINARY_DIR}/autogen"
DEPENDS
# the headless binary is required
weechat-headless
+39 -2
View File
@@ -1602,7 +1602,7 @@ doc_gen_api_config_priority (const char *path, const char *lang)
int
doc_generate (const char *path)
{
int i, j, rc_doc_gen, rc, num_files;
int i, j, rc_doc_gen, rc, num_files, warn_locale;
char *locales[] = {
"de_DE.UTF-8",
"en_US.UTF-8",
@@ -1662,10 +1662,47 @@ doc_generate (const char *path)
if (localedir && localedir[0])
bindtextdomain (PACKAGE, localedir);
/*
* if warn locale is enabled, any missing locale triggers a warning
* instead of a fatal error
*/
warn_locale = (string_strcasecmp (getenv ("WEECHAT_DOCGEN_WARN_LOCALE"), "on") == 0) ?
1 : 0;
for (i = 0; locales[i]; i++)
{
setenv ("LANGUAGE", locales[i], 1);
setlocale (LC_ALL, locales[i]);
if (!setlocale (LC_ALL, locales[i]))
{
if (warn_locale)
{
/* warning on missing locale */
string_fprintf (
stderr,
"doc generator: WARNING: failed to set locale \"%s\", "
"docs will include auto-generated English content\n",
locales[i]);
setlocale (LC_ALL, "C");
}
else
{
/* fatal error on missing locale */
string_fprintf (
stderr,
"doc generator: ERROR: failed to set locale \"%s\", "
"these locales must be installed to build docs:\n",
locales[i]);
for (j = 0; locales[j]; j++)
{
string_fprintf (stderr, " %s\n", locales[j]);
}
string_fprintf (
stderr,
"doc generator: you can turn this error as a warning "
"with the cmake option ENABLE_DOC_WARN_LOCALE\n");
goto end;
}
}
memcpy (lang, locales[i], 2);
lang[2] = '\0';
for (j = 0; doc_gen_functions[j]; j++)