diff --git a/util/meson.build b/util/meson.build index 27a25bea9..1a5472bb5 100644 --- a/util/meson.build +++ b/util/meson.build @@ -15,6 +15,17 @@ 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 +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@'] +help2man_env = environment() +help2man_env.set('HB_UTIL_HELP_VERBOSE', '1') + util_deps = [freetype_dep, cairo_dep, cairo_ft_dep, glib_dep] if conf.get('HAVE_GLIB', 0) == 1 @@ -27,6 +38,18 @@ 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], + env: help2man_env, + install: true, + install_dir: get_option('mandir') / 'man1', + ) + endif endif hb_shape = executable('hb-shape', hb_shape_sources, @@ -56,6 +79,21 @@ 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], + env: help2man_env, + 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,4 +112,4 @@ else # Disable tests that use this hb_shape = disabler() hb_subset = disabler() -endif +endif \ No newline at end of file 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");