Commit 9c339f8b authored by Christoph Reiter's avatar Christoph Reiter 🐍

girepository: Add version macros and functions. Fixes #200

This adds the following macros and functions: GI_MAJOR_VERSION, GI_MICRO_VERSION,
GI_MINOR_VERSION, GI_CHECK_VERSION, gi_get_major_version,gi_get_micro_version,
gi_get_minor_version.

Since we share a prefix with glib we have to namespace these by using the gi_
prefix. g_gi would also work but we already export symbols with gi_ like
gi_cclosure_marshal_generic(), gi_type_tag_get_ffi_type() and
gi_type_info_extract_ffi_return_value(), so let's not add another naming scheme.
parent c0dd66c3
Pipeline #46291 passed with stages
in 6 minutes and 46 seconds
......@@ -135,6 +135,7 @@ docs/reference/version.xml
docs/giscanner/_build/*
giscanner/_version.py
girepository/giversion.h
#g-ir-doc-tool tests
*.page
......
noinst_PROGRAMS += glib-print
glib_print_SOURCES = examples/glib-print.c
glib_print_CFLAGS = $(GOBJECT_CFLAGS) $(WARN_CFLAGS) -I$(top_srcdir)/girepository
glib_print_CFLAGS = $(GOBJECT_CFLAGS) $(WARN_CFLAGS) -I$(top_srcdir)/girepository -I$(top_builddir)/girepository
glib_print_LDFLAGS = $(WARN_LDFLAGS)
glib_print_LDADD = libgirepository-1.0.la $(GOBJECT_LIBS)
......
......@@ -201,19 +201,23 @@ GIRepository_2_0_gir_SCANNERFLAGS = \
$(WARN_SCANNERFLAGS) \
--identifier-prefix=GI \
--symbol-prefix=g \
--symbol-prefix=gi \
--c-include="girepository.h" \
--add-include-path=.
GIRepository_2_0_gir_PACKAGES = gobject-2.0
GIRepository_2_0_gir_INCLUDES = GObject-2.0
GIRepository_2_0_gir_EXPORT_PACKAGES = gobject-introspection-1.0
GIRepository_2_0_gir_CFLAGS = \
-I$(top_srcdir)/girepository -I$(top_srcdir) \
-I$(top_srcdir)/girepository \
-I$(top_srcdir) \
-I$(top_builddir)/girepository \
-DGI_COMPILATION
GIRepository_2_0_gir_FILES = \
$(top_srcdir)/girepository/girepository.h \
$(top_srcdir)/girepository/girepository.c \
$(top_srcdir)/girepository/gi*info.c \
$(top_srcdir)/girepository/gi*info.h \
$(top_builddir)/girepository/giversion.h \
$(top_srcdir)/girepository/gitypelib.h \
$(top_srcdir)/girepository/gitypes.h
......
......@@ -24,7 +24,8 @@ girepo_HEADERS = \
girepository/gitypes.h \
girepository/giunioninfo.h \
girepository/giversionmacros.h \
girepository/givfuncinfo.h
girepository/givfuncinfo.h \
$(top_builddir)/girepository/giversion.h
lib_LTLIBRARIES += libgirepository-1.0.la
noinst_LTLIBRARIES += libgirepository-internals.la libgirepository-gthash.la
......@@ -35,7 +36,8 @@ libgirepository_gthash_la_CFLAGS = \
$(WARN_CFLAGS) \
$(GIREPO_CFLAGS) \
$(GI_HIDDEN_VISIBILITY_CFLAGS) \
-I$(top_srcdir)/girepository
-I$(top_srcdir)/girepository \
-I$(top_builddir)/girepository
libgirepository_gthash_la_LDFLAGS = \
$(WARN_LDFLAGS)
libgirepository_gthash_la_LIBADD = libcmph.la $(GIREPO_LIBS)
......@@ -55,7 +57,8 @@ libgirepository_internals_la_CFLAGS = \
$(WARN_CFLAGS) \
$(GIREPO_CFLAGS) \
$(GI_HIDDEN_VISIBILITY_CFLAGS) \
-I$(top_srcdir)/girepository
-I$(top_srcdir)/girepository \
-I$(top_builddir)/girepository
libgirepository_internals_la_LDFLAGS = \
$(WARN_LDFLAGS)
......@@ -86,6 +89,7 @@ libgirepository_1_0_la_SOURCES = \
girepository/gitypelib.c \
girepository/gitypelib-internal.h \
girepository/giunioninfo.c \
girepository/giversion.c \
girepository/givfuncinfo.c
libgirepository_1_0_la_CPPFLAGS = \
......@@ -93,6 +97,7 @@ libgirepository_1_0_la_CPPFLAGS = \
$(GIREPO_CFLAGS) \
$(GI_HIDDEN_VISIBILITY_CFLAGS) \
-I$(top_srcdir)/girepository \
-I$(top_builddir)/girepository \
-DG_IREPOSITORY_COMPILATION
libgirepository_1_0_la_LIBADD = libgirepository-gthash.la $(GIREPO_LIBS)
libgirepository_1_0_la_LDFLAGS = \
......@@ -117,5 +122,5 @@ CLEANFILES += gthash-test
TESTS += gthash-test
gthash_test_SOURCES = girepository/gthash.c girepository/gthash-test.c
gthash_test_CFLAGS = -I$(top_srcdir)/girepository $(GOBJECT_CFLAGS)
gthash_test_CFLAGS = -I$(top_srcdir)/girepository -I$(top_builddir)/girepository $(GOBJECT_CFLAGS)
gthash_test_LDADD = libcmph.la libgirepository-1.0.la $(GOBJECT_LIBS)
......@@ -21,7 +21,7 @@ libgiscanner_la_SOURCES = \
giscanner/sourcescanner.h \
giscanner/scannerlexer.l \
giscanner/scannerparser.y
libgiscanner_la_CPPFLAGS = -I$(top_srcdir)/girepository -I$(top_srcdir)/giscanner
libgiscanner_la_CPPFLAGS = -I$(top_srcdir)/girepository -I$(top_builddir)/girepository -I$(top_srcdir)/giscanner
libgiscanner_la_LIBADD = $(GOBJECT_LIBS) $(GIO_LIBS)
libgiscanner_la_CFLAGS = $(GOBJECT_CFLAGS) $(GIO_CFLAGS) $(WARN_CFLAGS_FLEX)
libgiscanner_la_LDFLAGS = $(WARN_LDFLAGS)
......
......@@ -24,7 +24,7 @@ g-ir-doc-tool: tools/g-ir-tool-template.in _giscanner.la Makefile
@chmod a+x $@
g_ir_compiler_SOURCES = tools/compiler.c
g_ir_compiler_CPPFLAGS = -I$(top_srcdir)/girepository
g_ir_compiler_CPPFLAGS = -I$(top_srcdir)/girepository -I$(top_builddir)/girepository
g_ir_compiler_CFLAGS = $(GIO_CFLAGS) $(WARN_CFLAGS)
g_ir_compiler_LDFLAGS = $(WARN_LDFLAGS)
g_ir_compiler_LDADD = \
......@@ -33,7 +33,7 @@ g_ir_compiler_LDADD = \
$(GIREPO_LIBS)
g_ir_generate_SOURCES = tools/generate.c
g_ir_generate_CPPFLAGS = -I$(top_srcdir)/girepository
g_ir_generate_CPPFLAGS = -I$(top_srcdir)/girepository -I$(top_builddir)/girepository
g_ir_generate_CFLAGS = $(GIO_CFLAGS) $(WARN_CFLAGS)
g_ir_generate_LDFLAGS = $(WARN_LDFLAGS)
g_ir_generate_LDADD = \
......@@ -42,7 +42,7 @@ g_ir_generate_LDADD = \
$(GIREPO_LIBS)
g_ir_inspect_SOURCES = tools/g-ir-inspect.c
g_ir_inspect_CFLAGS = $(GIO_CFLAGS) $(WARN_CFLAGS) -I$(top_srcdir)/girepository
g_ir_inspect_CFLAGS = $(GIO_CFLAGS) $(WARN_CFLAGS) -I$(top_srcdir)/girepository -I$(top_builddir)/girepository
g_ir_inspect_LDFLAGS = $(WARN_LDFLAGS)
g_ir_inspect_LDADD = \
libgirepository-1.0.la \
......
......@@ -26,6 +26,13 @@ AM_SILENT_RULES([yes])
GI_VERSION=gi_version
AC_SUBST(GI_VERSION)
GI_MAJOR_VERSION=gi_major_version
GI_MINOR_VERSION=gi_minor_version
GI_MICRO_VERSION=gi_micro_version
AC_SUBST(GI_MAJOR_VERSION)
AC_SUBST(GI_MINOR_VERSION)
AC_SUBST(GI_MICRO_VERSION)
# Check for Win32
AC_CANONICAL_HOST
case "$host" in
......@@ -388,6 +395,7 @@ docs/Makefile
docs/reference/Makefile
docs/reference/version.xml
giscanner/_version.py
girepository/giversion.h
gobject-introspection-1.0.pc
gobject-introspection-no-export-1.0.pc])
AC_OUTPUT
......@@ -23,6 +23,7 @@
<xi:include href="xml/girepository.xml"/>
<xi:include href="xml/gitypelib.xml" />
<xi:include href="xml/giversion.xml"/>
<xi:include href="xml/gicommontypes.xml"/>
<chapter>
......@@ -98,5 +99,9 @@
<title>Index of new symbols in 1.46</title>
<xi:include href="xml/api-index-1.46.xml"><xi:fallback /></xi:include>
</index>
<index id="api-index-1-60" role="1.60">
<title>Index of new symbols in 1.60</title>
<xi:include href="xml/api-index-1.60.xml"><xi:fallback /></xi:include>
</index>
<xi:include href="xml/annotation-glossary.xml" />
</book>
......@@ -55,6 +55,7 @@ GI_AVAILABLE_IN_1_40
GI_AVAILABLE_IN_1_42
GI_AVAILABLE_IN_1_44
GI_AVAILABLE_IN_1_46
GI_AVAILABLE_IN_1_60
GI_AVAILABLE_IN_ALL
GI_DEPRECATED_IN_1_32
GI_DEPRECATED_IN_1_32_FOR
......@@ -74,6 +75,17 @@ GI_DEPRECATED_IN_1_46
GI_DEPRECATED_IN_1_46_FOR
</SECTION>
<SECTION>
<FILE>giversion</FILE>
GI_MAJOR_VERSION
GI_MINOR_VERSION
GI_MICRO_VERSION
GI_CHECK_VERSION
gi_get_major_version
gi_get_minor_version
gi_get_micro_version
</SECTION>
<SECTION>
<FILE>gibaseinfo</FILE>
GIBaseInfo
......
......@@ -387,6 +387,7 @@ gir_files += custom_target('gir-gio',
girepository_command = scanner_command + [
'--identifier-prefix=GI',
'--symbol-prefix=g',
'--symbol-prefix=gi',
'--c-include=girepository.h',
'--namespace=GIRepository',
'--nsversion=2.0',
......@@ -410,6 +411,7 @@ gir_files += custom_target('gir-girepository',
'--include-uninstalled=' + gobject_gir.full_path(),
'--cflags-begin'] + glib_includes + [
'-I' + meson.current_source_dir() + '/../girepository',
'-I' + meson.current_build_dir() + '/../girepository',
'-DGI_COMPILATION',
'--cflags-end',
'@INPUT@',
......
......@@ -47,6 +47,7 @@
#include <giunioninfo.h>
#include <giversionmacros.h>
#include <givfuncinfo.h>
#include <giversion.h>
G_BEGIN_DECLS
......
/* Copyright (C) 2018 Christoph Reiter
*
* 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 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., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <girepository.h>
/**
* SECTION:giversion
* @Title: Version Information
* @Short_description: macros and functions to check the girepository version
*/
/**
* GI_MAJOR_VERSION:
*
* The major version number of the girepository library.
*
* Since: 1.60
*/
/**
* GI_MINOR_VERSION:
*
* The minor version number of the girepository library.
*
* Since: 1.60
*/
/**
* GI_MICRO_VERSION:
*
* The micro version number of the girepository library.
*
* Since: 1.60
*/
/**
* GI_CHECK_VERSION:
* @major: the major version to check for
* @minor: the minor version to check for
* @micro: the micro version to check for
*
* Checks the version of the girepository library that is being compiled
* against.
*
* Returns: %TRUE if the version of the girepository header files
* is the same as or newer than the passed-in version.
*
* Since: 1.60
*/
/**
* gi_get_major_version:
*
* Returns the major version number of the girepository library.
* (e.g. in version 1.58.2 this is 1.)
*
* Returns: the major version number of the girepository library
*
* Since: 1.60
*/
guint
gi_get_major_version (void)
{
return GI_MAJOR_VERSION;
}
/**
* gi_get_minor_version:
*
* Returns the minor version number of the girepository library.
* (e.g. in version 1.58.2 this is 58.)
*
* Returns: the minor version number of the girepository library
*
* Since: 1.60
*/
guint
gi_get_minor_version (void)
{
return GI_MINOR_VERSION;
}
/**
* gi_get_micro_version:
*
* Returns the micro version number of the girepository library.
* (e.g. in version 1.58.2 this is 2.)
*
* Returns: the micro version number of the girepository library
*
* Since: 1.60
*/
guint
gi_get_micro_version (void)
{
return GI_MICRO_VERSION;
}
/* Copyright (C) 2018 Christoph Reiter
*
* 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 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., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GIVERISON_H__
#define __GIVERISON_H__
#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION)
#error "Only <girepository.h> can be included directly."
#endif
G_BEGIN_DECLS
#define GI_MAJOR_VERSION @GI_MAJOR_VERSION@
#define GI_MINOR_VERSION @GI_MINOR_VERSION@
#define GI_MICRO_VERSION @GI_MICRO_VERSION@
#define GI_CHECK_VERSION(major,minor,micro) \
(GI_MAJOR_VERSION > (major) || \
(GI_MAJOR_VERSION == (major) && GI_MINOR_VERSION > (minor)) || \
(GI_MAJOR_VERSION == (major) && GI_MINOR_VERSION == (minor) && \
GI_MICRO_VERSION >= (micro)))
GI_AVAILABLE_IN_1_60
guint gi_get_major_version (void) G_GNUC_CONST;
GI_AVAILABLE_IN_1_60
guint gi_get_minor_version (void) G_GNUC_CONST;
GI_AVAILABLE_IN_1_60
guint gi_get_micro_version (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GIVERISON_H__ */
......@@ -153,4 +153,10 @@
# define GI_AVAILABLE_IN_1_46 _GI_EXTERN
#endif
#if defined(GLIB_VERSION_2_60) && GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_60
# define GI_AVAILABLE_IN_1_60 GLIB_UNAVAILABLE(2, 60)
#else
# define GI_AVAILABLE_IN_1_60 _GI_EXTERN
#endif
#endif /* __GIVERSIONMACROS_H__ */
......@@ -36,6 +36,12 @@ girepo_internals_dep = declare_dependency(
include_directories: include_directories('.'),
)
gi_version_h = configure_file(
configuration: config,
input: 'giversion.h.in',
output: 'giversion.h',
)
girepo_headers = [
'giarginfo.h',
'gibaseinfo.h',
......@@ -58,6 +64,7 @@ girepo_headers = [
'giunioninfo.h',
'giversionmacros.h',
'givfuncinfo.h',
gi_version_h,
]
girepo_sources = [
......@@ -81,6 +88,7 @@ girepo_sources = [
'gitypeinfo.c',
'gitypelib.c',
'giunioninfo.c',
'giversion.c',
'givfuncinfo.c',
]
......@@ -102,6 +110,7 @@ girepo_gir_sources = files(
'gistructinfo.c',
'gitypeinfo.c',
'giunioninfo.c',
'giversion.c',
'givfuncinfo.c',
'giarginfo.h',
'gibaseinfo.h',
......@@ -122,7 +131,8 @@ girepo_gir_sources = files(
'gitypes.h',
'giunioninfo.h',
'givfuncinfo.h',
)
) + [gi_version_h]
install_headers(girepo_headers, subdir: 'gobject-introspection-1.0')
......
......@@ -23,6 +23,11 @@ endif
cc = meson.get_compiler('c')
config = configuration_data()
config.set('GI_MAJOR_VERSION', gi_versions[0])
config.set('GI_MINOR_VERSION', gi_versions[1])
config.set('GI_MICRO_VERSION', gi_versions[2])
config.set_quoted('GIR_SUFFIX', 'gir-1.0')
gir_dir_prefix = get_option('gir-dir-prefix')
if gir_dir_prefix == ''
......
......@@ -36,7 +36,7 @@ CLEANFILES += Offsets-1.0.gir Offsets-1.0.typelib liboffsets.la
EXTRA_PROGRAMS += gitestoffsets
nodist_gitestoffsets_SOURCES = gitestoffsets.c
gitestoffsets_CPPFLAGS = $(GIREPO_CFLAGS) -I$(top_srcdir)/girepository -I$(top_srcdir)/tests
gitestoffsets_CPPFLAGS = $(GIREPO_CFLAGS) -I$(top_srcdir)/girepository -I$(top_builddir)/girepository -I$(top_srcdir)/tests
gitestoffsets_CFLAGS = $(WARN_CFLAGS)
gitestoffsets_LDFLAGS = $(WARN_LDFLAGS)
gitestoffsets_LDADD = $(top_builddir)/libgirepository-1.0.la $(GIREPO_LIBS)
......
......@@ -6,19 +6,19 @@ EXTRA_PROGRAMS = gitestrepo giteststructinfo gitestthrows gitypelibtest
CLEANFILES = $(EXTRA_PROGRAMS)
gitestrepo_SOURCES = gitestrepo.c
gitestrepo_CPPFLAGS = $(GIREPO_CFLAGS) -I$(top_srcdir)/girepository
gitestrepo_CPPFLAGS = $(GIREPO_CFLAGS) -I$(top_srcdir)/girepository -I$(top_builddir)/girepository
gitestrepo_LDADD = $(top_builddir)/libgirepository-1.0.la $(GIREPO_LIBS)
giteststructinfo_SOURCES = giteststructinfo.c
giteststructinfo_CPPFLAGS = $(GIREPO_CFLAGS) -I$(top_srcdir)/girepository
giteststructinfo_CPPFLAGS = $(GIREPO_CFLAGS) -I$(top_srcdir)/girepository -I$(top_builddir)/girepository
giteststructinfo_LDADD = $(top_builddir)/libgirepository-1.0.la $(GIREPO_LIBS)
gitestthrows_SOURCES = gitestthrows.c
gitestthrows_CPPFLAGS = $(GIREPO_CFLAGS) -I$(top_srcdir)/girepository
gitestthrows_CPPFLAGS = $(GIREPO_CFLAGS) -I$(top_srcdir)/girepository -I$(top_builddir)/girepository
gitestthrows_LDADD = $(top_builddir)/libgirepository-1.0.la $(GIREPO_LIBS)
gitypelibtest_SOURCES = gitypelibtest.c
gitypelibtest_CPPFLAGS = $(GIREPO_CFLAGS) -I$(top_srcdir)/girepository
gitypelibtest_CPPFLAGS = $(GIREPO_CFLAGS) -I$(top_srcdir)/girepository -I$(top_builddir)/girepository
gitypelibtest_LDADD = $(top_builddir)/libgirepository-1.0.la $(GIREPO_LIBS)
TESTS = gitestrepo giteststructinfo gitestthrows gitypelibtest
......
......@@ -21,7 +21,7 @@ EXTRA_LTLIBRARIES = \
CLEANFILES += $(EXTRA_LTLIBRARIES)
GI_SCANNER_CFLAGS = -I$(top_srcdir)/tests
AM_CPPFLAGS = -I$(top_srcdir)/girepository
AM_CPPFLAGS = -I$(top_srcdir)/girepository -I$(top_builddir)/girepository
AM_CFLAGS = $(GIO_CFLAGS) $(GOBJECT_CFLAGS) $(GTHREAD_CFLAGS) $(GI_HIDDEN_VISIBILITY_CFLAGS) $(GI_SCANNER_CFLAGS) $(WARN_CFLAGS)
# -rpath needed to force libtool to build a shared library for a check_LTLIBRARIES
# target. See http://lists.gnu.org/archive/html/automake/2005-10/msg00107.html
......
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