diff options
-rw-r--r-- | libappstream-glib/as-version.c | 50 | ||||
-rw-r--r-- | libappstream-glib/as-version.h.in | 4 | ||||
-rw-r--r-- | libappstream-glib/meson.build | 2 |
3 files changed, 56 insertions, 0 deletions
diff --git a/libappstream-glib/as-version.c b/libappstream-glib/as-version.c new file mode 100644 index 0000000..228ba90 --- /dev/null +++ b/libappstream-glib/as-version.c @@ -0,0 +1,50 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2018 Richard Hughes <richard@hughsie.com> + * + * Licensed under the GNU Lesser General Public License Version 2.1 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * SECTION:as-version + * @short_description: Helpers for the current runtime version. + * @include: appstream-glib.h + * @stability: Unstable + * + * The version number can be different between build-time and runtime. + */ + +#include "config.h" + +#include "as-version.h" + +/** + * as_version_string: + * + * Gets the libappstream-glib installed runtime version. + * + * Returns: a version numer, e.g. "0.7.8" + * + * Since: 0.7.8 + **/ +const gchar * +as_version_string (void) +{ + return G_STRINGIFY(AS_MAJOR_VERSION) "." + G_STRINGIFY(AS_MINOR_VERSION) "." + G_STRINGIFY(AS_MICRO_VERSION); +} diff --git a/libappstream-glib/as-version.h.in b/libappstream-glib/as-version.h.in index e580fff..538c6a5 100644 --- a/libappstream-glib/as-version.h.in +++ b/libappstream-glib/as-version.h.in @@ -36,6 +36,8 @@ #ifndef __AS_VERSION_H #define __AS_VERSION_H +#include <glib.h> + /* compile time version */ #define AS_MAJOR_VERSION (@AS_MAJOR_VERSION_CONF@) @@ -51,4 +53,6 @@ (AS_MAJOR_VERSION == (major) && AS_MINOR_VERSION == (minor) && \ AS_MICRO_VERSION >= (micro))) +const gchar *as_version_string (void); + #endif /* __AS_VERSION_H */ diff --git a/libappstream-glib/meson.build b/libappstream-glib/meson.build index 33e1f61..417e054 100644 --- a/libappstream-glib/meson.build +++ b/libappstream-glib/meson.build @@ -103,6 +103,7 @@ sources = [ 'as-tag.c', 'as-translation.c', 'as-utils.c', + 'as-version.c', 'as-yaml.c', asresources, ] @@ -219,6 +220,7 @@ introspection_sources = [ 'as-translation.h', 'as-utils.c', 'as-utils.h', + 'as-version.c', ] if get_option('introspection') |