summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-05-23 12:30:43 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-05-23 12:30:43 -0400
commit5df00b86e178c1c66049f1b482451df53e656997 (patch)
tree00b76cb44158b42c904893a0df7f55909c56f4c6 /utils
parent2f07e562fc1fe370d3c7d9ce70158480a33d3a0a (diff)
downloadpango-5df00b86e178c1c66049f1b482451df53e656997.tar.gz
pango-segmentation: Fixes
Only build pango-segmentation if we have cairo. And add --version here too.
Diffstat (limited to 'utils')
-rw-r--r--utils/meson.build21
-rw-r--r--utils/pango-segmentation.c14
2 files changed, 29 insertions, 6 deletions
diff --git a/utils/meson.build b/utils/meson.build
index 74d8668b..6d06dbec 100644
--- a/utils/meson.build
+++ b/utils/meson.build
@@ -79,11 +79,24 @@ if cairo_dep.found()
'-DPACKAGE_VERSION="@0@"'.format(meson.project_version()),
])
+ pango_segmentation_sources = [
+ 'pango-segmentation.c',
+ ]
+
+ pango_segmentation_deps = [
+ pango_deps,
+ libpango_dep,
+ libpangocairo_dep
+ ]
+
pango_segmentation = executable('pango-segmentation',
- 'pango-segmentation.c',
- dependencies: [ libpango_dep, libpangocairo_dep ],
+ pango_segmentation_sources,
+ dependencies: pango_segmentation_deps,
include_directories: [ root_inc ],
- install: false,
- )
+ install: true,
+ c_args: [
+ '-DPACKAGE_NAME="@0@"'.format(meson.project_name()),
+ '-DPACKAGE_VERSION="@0@"'.format(meson.project_version()),
+ ])
endif
diff --git a/utils/pango-segmentation.c b/utils/pango-segmentation.c
index 3e774167..6931d180 100644
--- a/utils/pango-segmentation.c
+++ b/utils/pango-segmentation.c
@@ -151,15 +151,19 @@ show_segmentation (const char *input,
int
main (int argc, char *argv[])
{
- setlocale (LC_ALL, "");
char *opt_kind = "grapheme";
+ gboolean opt_version = FALSE;
GOptionEntry entries[] = {
{ "kind", 0, 0, G_OPTION_ARG_STRING, &opt_kind, "Kind of boundary (grapheme/word/line/sentence)", "KIND" },
+ { "version", 0, 0, G_OPTION_ARG_NONE, &opt_version, "Show version" },
{ NULL, },
};
GOptionContext *context;
GError *error = NULL;
+ g_set_prgname ("pango-segmentation");
+ setlocale (LC_ALL, "");
+
context = g_option_context_new ("TEXT");
g_option_context_add_main_entries (context, entries, NULL);
g_option_context_set_description (context,
@@ -170,9 +174,15 @@ main (int argc, char *argv[])
exit (1);
}
+ if (opt_version)
+ {
+ g_print ("%s (%s) %s\n", g_get_prgname (), PACKAGE_NAME, PACKAGE_VERSION);
+ exit (0);
+ }
+
if (argc < 2)
{
- g_printerr ("Usage: pango-segmentation [OPTIONS…] TEXT");
+ g_printerr ("Usage: pango-segmentation [OPTIONS…] TEXT\n");
exit (1);
}