libostree: add versioning macros
OSTree currently provides no way to inspect the versioning information at run time, being only available at compile time through pkg-config. This is a problem for e.g. Flatpak, that needs to check whether the 'update-frequency' option is available. Checking at compile time isn't great since it's not looking for new symbols, but only if an optional feature is present. This commit, then, adds a new header that is generated at compile time, exposing OSTree's versioning information. Closes: #728 Approved by: cgwalters
This commit is contained in:
1 parent
75907cb513
commit
fda4a47cae
7 files changed
+103
-5
No files matched your search
@@ -0,0 +1,82 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
||||
*
|
||||
* Copyright (C) 2017 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
||||
*
|
||||
* This program 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 of the licence 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., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* SECTION:ostree-version
|
||||
* @short_description: ostree version checking
|
||||
*
|
||||
* ostree provides macros to check the version of the library
|
||||
* at compile-time
|
||||
*/
|
||||
|
||||
/**
|
||||
* OSTREE_YEAR_VERSION:
|
||||
*
|
||||
* ostree year version component (e.g. 2017 if %OSTREE_VERSION is 2017.2)
|
||||
*/
|
||||
#define OSTREE_YEAR_VERSION (@YEAR_VERSION@)
|
||||
|
||||
/**
|
||||
* OSTREE_RELEASE_VERSION:
|
||||
*
|
||||
* ostree release version component (e.g. 2 if %OSTREE_VERSION is 2017.2)
|
||||
*/
|
||||
#define OSTREE_RELEASE_VERSION (@RELEASE_VERSION@)
|
||||
|
||||
/**
|
||||
* OSTREE_VERSION
|
||||
*
|
||||
* ostree version.
|
||||
*/
|
||||
#define OSTREE_VERSION (@VERSION@)
|
||||
|
||||
/**
|
||||
* OSTREE_VERSION_S:
|
||||
*
|
||||
* ostree version, encoded as a string, useful for printing and
|
||||
* concatenation.
|
||||
*/
|
||||
#define OSTREE_VERSION_S "@VERSION@"
|
||||
|
||||
#define OSTREE_ENCODE_VERSION(year,release) \
|
||||
((year) << 16 | (release))
|
||||
|
||||
/**
|
||||
* OSTREE_VERSION_HEX:
|
||||
*
|
||||
* ostree version, encoded as an hexadecimal number, useful for
|
||||
* integer comparisons.
|
||||
*/
|
||||
#define OSTREE_VERSION_HEX \
|
||||
(OSTREE_ENCODE_VERSION (OSTREE_YEAR_VERSION, OSTREE_RELEASE_VERSION))
|
||||
|
||||
/**
|
||||
* OSTREE_CHECK_VERSION:
|
||||
* @year: required year version
|
||||
* @release: required release version
|
||||
*
|
||||
* Compile-time version checking. Evaluates to %TRUE if the version
|
||||
* of ostree is equal or greater than the required one.
|
||||
*/
|
||||
#define OSTREE_CHECK_VERSION(year,release) \
|
||||
(OSTREE_YEAR_VERSION >= (year) || \
|
||||
(OSTREE_YEAR_VERSION == (year) && OSTREE_RELEASE_VERSION >= (release)))
|
||||
Reference in new issue
Block a user