Commit 0836518d authored by Christian Hergert's avatar Christian Hergert

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.
parent 2f25f535
/* 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 */
/* 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 */
......@@ -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"
......
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 = []
......
......@@ -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')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment