From 7f10c0edfd3f19ce75de8e0dfcbe84018d3fe6b3 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 26 Mar 2025 22:20:57 -0600 Subject: [PATCH 1/5] [util] Towards building manpages TODO: 1. Only when docs are enabled? 2. Installdir 3. How to include in release? Fixes https://github.com/harfbuzz/harfbuzz/issues/5208 --- util/meson.build | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/util/meson.build b/util/meson.build index 27a25bea9..4e7291e4d 100644 --- a/util/meson.build +++ b/util/meson.build @@ -75,3 +75,22 @@ else hb_shape = disabler() hb_subset = disabler() endif + +# Build man pages +help2man = find_program('help2man', required: false) +# If found, invoke it on our four binaries to build man pages +# If not found, just skip this step +if help2man.found() + foreach binary: [hb_view, hb_shape, hb_info, hb_subset] + target = binary.name() + '.1' + manpage = custom_target(target, + input: binary, + output: target, + command: [help2man, '--help-option=--help-all', '--no-info', '--output=' + '@OUTPUT@', '@INPUT@'], + build_by_default: true, + #install: true, + #install_dir: ???, + ) + endforeach +endif + From 9a80c0da84108c8ad19e2071ee985a5c403c4956 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Thu, 27 Mar 2025 21:16:12 +0200 Subject: [PATCH 2/5] [util] Install man pages --- util/meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/meson.build b/util/meson.build index 4e7291e4d..4f34ab944 100644 --- a/util/meson.build +++ b/util/meson.build @@ -88,8 +88,8 @@ if help2man.found() output: target, command: [help2man, '--help-option=--help-all', '--no-info', '--output=' + '@OUTPUT@', '@INPUT@'], build_by_default: true, - #install: true, - #install_dir: ???, + install: true, + install_dir: get_option('mandir') / 'man1', ) endforeach endif From 9609f50badb2047a96e399bcc8e33c8860655d8a Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Thu, 27 Mar 2025 21:21:58 +0200 Subject: [PATCH 3/5] [util] Build man page only if the corresponding util is built --- util/meson.build | 51 +++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/util/meson.build b/util/meson.build index 4f34ab944..fc1a44253 100644 --- a/util/meson.build +++ b/util/meson.build @@ -15,6 +15,11 @@ hb_subset_cli_sources = [ 'helper-subset.hh', ] +# If found, invoke it on our four binaries to build man pages +# If not found, just skip this step +help2man = find_program('help2man', required: false) +help2man_command = [help2man, '--help-option=--help-all', '--no-info', '--output=' + '@OUTPUT@', '@INPUT@'] + util_deps = [freetype_dep, cairo_dep, cairo_ft_dep, glib_dep] if conf.get('HAVE_GLIB', 0) == 1 @@ -27,6 +32,17 @@ if conf.get('HAVE_GLIB', 0) == 1 install: true, ) meson.override_find_program('hb-view', hb_view) + if help2man.found() + target = hb_view.name() + '.1' + hb_view_manpage = custom_target(target, + input: hb_view, + output: target, + command: help2man_command, + depends: [hb_view], + install: true, + install_dir: get_option('mandir') / 'man1', + ) + endif endif hb_shape = executable('hb-shape', hb_shape_sources, @@ -56,6 +72,20 @@ if conf.get('HAVE_GLIB', 0) == 1 ) meson.override_find_program('hb-subset', hb_subset) + if help2man.found() + foreach binary: [hb_shape, hb_info, hb_subset] + target = binary.name() + '.1' + manpage = custom_target(target, + input: binary, + output: target, + command: help2man_command, + depends: [binary], + install: true, + install_dir: get_option('mandir') / 'man1', + ) + endforeach + endif + if get_option('experimental_api') test('test-hb-subset-parsing', executable('test-hb-subset-parsing', @@ -74,23 +104,4 @@ else # Disable tests that use this hb_shape = disabler() hb_subset = disabler() -endif - -# Build man pages -help2man = find_program('help2man', required: false) -# If found, invoke it on our four binaries to build man pages -# If not found, just skip this step -if help2man.found() - foreach binary: [hb_view, hb_shape, hb_info, hb_subset] - target = binary.name() + '.1' - manpage = custom_target(target, - input: binary, - output: target, - command: [help2man, '--help-option=--help-all', '--no-info', '--output=' + '@OUTPUT@', '@INPUT@'], - build_by_default: true, - install: true, - install_dir: get_option('mandir') / 'man1', - ) - endforeach -endif - +endif \ No newline at end of file From 7ab42f9af3f18ee1a99b67c71a4914c23419edec Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Thu, 27 Mar 2025 21:25:13 +0200 Subject: [PATCH 4/5] [util] Build man pages only if docs are enabled --- util/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/util/meson.build b/util/meson.build index fc1a44253..6448b9881 100644 --- a/util/meson.build +++ b/util/meson.build @@ -17,7 +17,11 @@ hb_subset_cli_sources = [ # If found, invoke it on our four binaries to build man pages # If not found, just skip this step -help2man = find_program('help2man', required: false) +if not get_option('docs').disabled() + help2man = find_program('help2man', required: false) +else + help2man = disabler() +endif help2man_command = [help2man, '--help-option=--help-all', '--no-info', '--output=' + '@OUTPUT@', '@INPUT@'] util_deps = [freetype_dep, cairo_dep, cairo_ft_dep, glib_dep] From d47a47e20b7496379face2b90ee7c924d041daa4 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 27 Mar 2025 13:59:08 -0600 Subject: [PATCH 5/5] [util] Make --help less verbose again Just the main page gets env-vars, exit-codes, and see-also. --- util/meson.build | 4 ++++ util/options.hh | 41 +++++++++++++++++++++++------------------ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/util/meson.build b/util/meson.build index 6448b9881..1a5472bb5 100644 --- a/util/meson.build +++ b/util/meson.build @@ -23,6 +23,8 @@ else help2man = disabler() endif help2man_command = [help2man, '--help-option=--help-all', '--no-info', '--output=' + '@OUTPUT@', '@INPUT@'] +help2man_env = environment() +help2man_env.set('HB_UTIL_HELP_VERBOSE', '1') util_deps = [freetype_dep, cairo_dep, cairo_ft_dep, glib_dep] @@ -43,6 +45,7 @@ if conf.get('HAVE_GLIB', 0) == 1 output: target, command: help2man_command, depends: [hb_view], + env: help2man_env, install: true, install_dir: get_option('mandir') / 'man1', ) @@ -84,6 +87,7 @@ if conf.get('HAVE_GLIB', 0) == 1 output: target, command: help2man_command, depends: [binary], + env: help2man_env, install: true, install_dir: get_option('mandir') / 'man1', ) diff --git a/util/options.hh b/util/options.hh index e4700429a..f87e8bcba 100644 --- a/util/options.hh +++ b/util/options.hh @@ -168,26 +168,31 @@ struct option_parser_t { GString *s = g_string_new (description); - // Exit codes - assert (exit_codes->len); - g_string_append_printf (s, "\n\n*Exit Codes*\n"); - for (unsigned i = 0; i < exit_codes->len; i++) - if (exit_codes->pdata[i]) - g_string_append_printf (s, "\n %u: %s\n", i, (const char *) exit_codes->pdata[i]); - - // Environment variables if any - if (environs->len) + const char *env = getenv ("HB_UTIL_HELP_VERBOSE"); + bool verbose = env && atoi (env); + if (verbose) { - g_string_append_printf (s, "\n\n*Environment*\n"); - for (unsigned i = 0; i < environs->len; i++) - { - g_string_append_printf (s, "\n %s\n", (char *)environs->pdata[i]); - } - } + // Exit codes + assert (exit_codes->len); + g_string_append_printf (s, "\n\n*Exit Codes*\n"); + for (unsigned i = 0; i < exit_codes->len; i++) + if (exit_codes->pdata[i]) + g_string_append_printf (s, "\n %u: %s\n", i, (const char *) exit_codes->pdata[i]); - // See also - g_string_append_printf (s, "\n\n*See also*\n"); - g_string_append_printf (s, " hb-view(1), hb-shape(1), hb-subset(1), hb-info(1)"); + // Environment variables if any + if (environs->len) + { + g_string_append_printf (s, "\n\n*Environment*\n"); + for (unsigned i = 0; i < environs->len; i++) + { + g_string_append_printf (s, "\n %s\n", (char *)environs->pdata[i]); + } + } + + // See also + g_string_append_printf (s, "\n\n*See also*\n"); + g_string_append_printf (s, " hb-view(1), hb-shape(1), hb-subset(1), hb-info(1)"); + } // Footer g_string_append_printf (s, "\n\nFind more information or report bugs at \n");