1/* ide-version.h.in
2 *
3 * Copyright (C) 2017 Christian Hergert <chergert@redhat.com>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef IDE_VERSION_H
20#define IDE_VERSION_H
21
22#if !defined(IDE_CORE_INSIDE) && !defined(IDE_CORE_COMPILATION)
23# error "Only <libide-core.h> can be included directly."
24#endif
25
26/**
27 * SECTION:ide-version
28 * @title: Version Checking
29 * @short_description: Conditionally include code based on Builder version
30 *
31 * This module provides various macros that may be used to build code based
32 * on the version of Builder at build time.
33 */
34
35/**
36 * IDE_BUILD_TYPE:
37 *
38 * The build type of the installed build.
39 */
40#define IDE_BUILD_TYPE @BUILD_TYPE@
41
42/**
43 * IDE_BUILD_CHANNEL:
44 *
45 * The release channel of Builder. This should be a string such as
46 * "other", "flatpak-stable", or "flatpak-nightly".
47 */
48#define IDE_BUILD_CHANNEL @BUILD_CHANNEL@
49
50/**
51 * IDE_MAJOR_VERSION:
52 *
53 * libide major version component (e.g. 1 if %IDE_VERSION is 1.2.3)
54 */
55#define IDE_MAJOR_VERSION (@MAJOR_VERSION@)
56
57/**
58 * IDE_MINOR_VERSION:
59 *
60 * libide minor version component (e.g. 2 if %IDE_VERSION is 1.2.3)
61 */
62#define IDE_MINOR_VERSION (@MINOR_VERSION@)
63
64/**
65 * IDE_VERSION
66 *
67 * libide version.
68 */
69#define IDE_VERSION (@VERSION@)
70
71/**
72 * IDE_VERSION_S:
73 *
74 * libide version, encoded as a string, useful for printing and
75 * concatenation.
76 */
77#define IDE_VERSION_S "@VERSION@"
78
79#define IDE_ENCODE_VERSION(major,minor,micro) \
80        ((major) << 24 | (minor) << 16 | (micro) << 8)
81
82/**
83 * IDE_VERSION_HEX:
84 *
85 * libide version, encoded as an hexadecimal number, useful for
86 * integer comparisons.
87 */
88#define IDE_VERSION_HEX \
89        (IDE_ENCODE_VERSION (IDE_MAJOR_VERSION, IDE_MINOR_VERSION, 0))
90
91/**
92 * IDE_CHECK_VERSION:
93 * @major: required major version
94 * @minor: required minor version
95 * @micro: required micro version
96 *
97 * Compile-time version checking. Evaluates to %TRUE if the version
98 * of libide is greater than the required one.
99 *
100 * Micro is no longer used.
101 */
102#define IDE_CHECK_VERSION(major,minor,micro)   \
103        (IDE_MAJOR_VERSION > (major) || \
104         (IDE_MAJOR_VERSION == (major) && IDE_MINOR_VERSION > (minor)) || \
105         (IDE_MAJOR_VERSION == (major) && IDE_MINOR_VERSION == (minor) && \
106          0 >= (micro)))
107
108#endif /* IDE_VERSION_H */
109