[gnome-builder] build: add version and build identifier headers
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] build: add version and build identifier headers
- Date: Sun, 18 Jun 2017 20:45:07 +0000 (UTC)
commit 0836518d50c2a62a6ee93bcb36be619235da8dfb
Author: Christian Hergert <chergert redhat com>
Date: Sun Jun 18 13:44:33 2017 -0700
build: add version and build identifier headers
We need the version helper anyway, especially without a stable ABI. We also
add a build identifier and build type defines so that we can use that later
in our about dialog.
libide/ide-build-ident.h.in | 30 ++++++++++++
libide/ide-version.h.in | 106 +++++++++++++++++++++++++++++++++++++++++++
libide/ide.h | 3 +
libide/meson.build | 26 ++++++++++-
meson.build | 1 +
5 files changed, 164 insertions(+), 2 deletions(-)
---
diff --git a/libide/ide-build-ident.h.in b/libide/ide-build-ident.h.in
new file mode 100644
index 0000000..ea3ca17
--- /dev/null
+++ b/libide/ide-build-ident.h.in
@@ -0,0 +1,30 @@
+/* ide-build-ident.h.in
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef IDE_BUILD_IDENT_H
+#define IDE_BUILD_IDENT_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#define IDE_BUILD_IDENTIFIER "@VCS_TAG@"
+
+G_END_DECLS
+
+#endif /* IDE_BUILD_IDENT_H */
diff --git a/libide/ide-version.h.in b/libide/ide-version.h.in
new file mode 100644
index 0000000..1678336
--- /dev/null
+++ b/libide/ide-version.h.in
@@ -0,0 +1,106 @@
+/* ide-version.h.in
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef IDE_VERSION_H
+#define IDE_VERSION_H
+
+#if !defined(IDE_INSIDE) && !defined(IDE_COMPILATION)
+# error "Only <ide.h> can be included directly."
+#endif
+
+#include "ide-build-ident.h"
+
+/**
+ * SECTION:jsonrpc-version
+ * @short_description: libide version checking
+ *
+ * libide provides macros to check the version of the library
+ * at compile-time
+ */
+
+/**
+ * IDE_BUILD_TYPE:
+ *
+ * The build type of the installed build.
+ */
+#define IDE_BUILD_TYPE @BUILD_TYPE@
+
+/**
+ * IDE_MAJOR_VERSION:
+ *
+ * libide major version component (e.g. 1 if %IDE_VERSION is 1.2.3)
+ */
+#define IDE_MAJOR_VERSION (@MAJOR_VERSION@)
+
+/**
+ * IDE_MINOR_VERSION:
+ *
+ * libide minor version component (e.g. 2 if %IDE_VERSION is 1.2.3)
+ */
+#define IDE_MINOR_VERSION (@MINOR_VERSION@)
+
+/**
+ * IDE_MICRO_VERSION:
+ *
+ * libide micro version component (e.g. 3 if %IDE_VERSION is 1.2.3)
+ */
+#define IDE_MICRO_VERSION (@MICRO_VERSION@)
+
+/**
+ * IDE_VERSION
+ *
+ * libide version.
+ */
+#define IDE_VERSION (@VERSION@)
+
+/**
+ * IDE_VERSION_S:
+ *
+ * libide version, encoded as a string, useful for printing and
+ * concatenation.
+ */
+#define IDE_VERSION_S "@VERSION@"
+
+#define IDE_ENCODE_VERSION(major,minor,micro) \
+ ((major) << 24 | (minor) << 16 | (micro) << 8)
+
+/**
+ * IDE_VERSION_HEX:
+ *
+ * libide version, encoded as an hexadecimal number, useful for
+ * integer comparisons.
+ */
+#define IDE_VERSION_HEX \
+ (IDE_ENCODE_VERSION (IDE_MAJOR_VERSION, IDE_MINOR_VERSION, IDE_MICRO_VERSION))
+
+/**
+ * IDE_CHECK_VERSION:
+ * @major: required major version
+ * @minor: required minor version
+ * @micro: required micro version
+ *
+ * Compile-time version checking. Evaluates to %TRUE if the version
+ * of libide is greater than the required one.
+ */
+#define IDE_CHECK_VERSION(major,minor,micro) \
+ (IDE_MAJOR_VERSION > (major) || \
+ (IDE_MAJOR_VERSION == (major) && IDE_MINOR_VERSION > (minor)) || \
+ (IDE_MAJOR_VERSION == (major) && IDE_MINOR_VERSION == (minor) && \
+ IDE_MICRO_VERSION >= (micro)))
+
+#endif /* IDE_VERSION_H */
diff --git a/libide/ide.h b/libide/ide.h
index 5065986..28b8be4 100644
--- a/libide/ide.h
+++ b/libide/ide.h
@@ -25,6 +25,9 @@ G_BEGIN_DECLS
#define IDE_INSIDE
+#include "ide-build-ident.h"
+#include "ide-version.h"
+
#include "ide-types.h"
#include "application/ide-application-addin.h"
diff --git a/libide/meson.build b/libide/meson.build
index 48d6699..5aca58f 100644
--- a/libide/meson.build
+++ b/libide/meson.build
@@ -1,3 +1,26 @@
+libide_header_dir = pkgincludedir + '/libide'
+
+version_data = configuration_data()
+version_data.set('MAJOR_VERSION', MAJOR_VERSION)
+version_data.set('MINOR_VERSION', MINOR_VERSION)
+version_data.set('MICRO_VERSION', MICRO_VERSION)
+version_data.set('VERSION', meson.project_version())
+version_data.set_quoted('BUILD_TYPE', get_option('buildtype'))
+
+libide_version_h = configure_file(
+ input: 'ide-version.h.in',
+ output: 'ide-version.h',
+ install_dir: libide_header_dir,
+ install: true,
+ configuration: version_data)
+
+vcs_tag(
+ input: 'ide-build-ident.h.in',
+ output: 'ide-build-ident.h',
+ install: true,
+ install_dir: libide_header_dir,
+)
+
libide_enum_headers = [
'buffers/ide-buffer.h',
'buildsystem/ide-build-log.h',
@@ -16,8 +39,6 @@ libide_enum_headers = [
'workbench/ide-layout-stack-split.h',
]
-libide_header_dir = pkgincludedir + '/libide'
-
libide_enums = gnome.mkenums('ide-enums',
h_template: 'ide-enums.h.in',
c_template: 'ide-enums.c.in',
@@ -392,6 +413,7 @@ libide_generated_headers = [
libide_icons_resources[1],
libide_enums[1],
libide_debug_h,
+ libide_version_h,
]
libide_args = []
diff --git a/meson.build b/meson.build
index 1fa6f4d..d840dd1 100644
--- a/meson.build
+++ b/meson.build
@@ -44,6 +44,7 @@ add_global_arguments([
'-DHAVE_CONFIG_H',
'-I' + meson.build_root(), # config.h
'-D_GNU_SOURCE',
+ '-DIDE_COMPILATION',
], language: 'c')
cc = meson.get_compiler('c')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]