Skip to content

Commit

Permalink
Add functions and macros for library version
Browse files Browse the repository at this point in the history
Fixes #103
  • Loading branch information
khaledhosny committed May 27, 2019
1 parent a8b0995 commit 80d75c8
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 3 deletions.
15 changes: 13 additions & 2 deletions configure.ac
@@ -1,5 +1,5 @@
AC_INIT([Raqm],
[0.6.0],
[0.7.0],
[https://github.com/HOST-Oman/libraqm/issues],
[raqm],
[https://github.com/HOST-Oman/libraqm/])
Expand All @@ -18,11 +18,21 @@ AX_COMPILER_FLAGS

LT_INIT

# Libtool version
# Version
m4_define([_triplet], m4_split(AC_PACKAGE_VERSION, [[.]]))
m4_define([_major], m4_argn(1, _triplet))
m4_define([_minor], m4_argn(2, _triplet))
m4_define([_micro], m4_argn(3, _triplet))
RAQM_VERSION_MAJOR=_major
RAQM_VERSION_MINOR=_minor
RAQM_VERSION_MICRO=_micro
RAQM_VERSION=AC_PACKAGE_VERSION
AC_SUBST(RAQM_VERSION_MAJOR)
AC_SUBST(RAQM_VERSION_MINOR)
AC_SUBST(RAQM_VERSION_MICRO)
AC_SUBST(RAQM_VERSION)

# Libtool version
m4_define([_age], m4_eval(_major*10000 + _minor*100))
m4_define([_current], m4_eval(_major + _age))
RAQM_LIBTOOL_VERSION=_current:_micro:_age
Expand Down Expand Up @@ -56,6 +66,7 @@ AC_CONFIG_FILES([
Makefile
raqm.pc
src/Makefile
src/raqm-version.h
tests/Makefile
docs/Makefile
docs/version.xml
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile.am
Expand Up @@ -57,7 +57,7 @@ CFILE_GLOB=$(top_srcdir)/src/raqm.c

# Extra header to include when scanning, which are not under DOC_SOURCE_DIR
# e.g. EXTRA_HFILES=$(top_srcdir}/contrib/extra.h
EXTRA_HFILES=
EXTRA_HFILES=$(top_builddir)/src/raqm-version.h

# Images to copy into HTML directory.
# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png
Expand Down
4 changes: 4 additions & 0 deletions docs/raqm-docs.xml
Expand Up @@ -42,6 +42,10 @@
<title>Index of new symbols in 0.6.x</title>
<xi:include href="xml/api-index-0.6.xml"><xi:fallback /></xi:include>
</index>
<index id="api-index-0-7" role="0.7">
<title>Index of new symbols in 0.7.x</title>
<xi:include href="xml/api-index-0.7.xml"><xi:fallback /></xi:include>
</index>
<index id="deprecated-api-index" role="deprecated">
<title>Index of deprecated API</title>
<xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include>
Expand Down
8 changes: 8 additions & 0 deletions docs/raqm-sections.txt
Expand Up @@ -16,6 +16,14 @@ raqm_layout
raqm_get_glyphs
raqm_index_to_position
raqm_position_to_index
raqm_version
raqm_version_atleast
raqm_version_string
RAQM_VERSION_ATLEAST
RAQM_VERSION_MAJOR
RAQM_VERSION_MICRO
RAQM_VERSION_MINOR
RAQM_VERSION_STRING
raqm_t
raqm_direction_t
raqm_glyph_t
Expand Down
2 changes: 2 additions & 0 deletions src/Makefile.am
Expand Up @@ -6,10 +6,12 @@ check_LTLIBRARIES = libraqm-test.la
libraqm_la_SOURCES = \
raqm.c \
raqm.h \
raqm-version.h \
$(NULL)

include_HEADERS = \
raqm.h \
raqm-version.h \
$(NULL)

libraqm_la_LIBADD = \
Expand Down
44 changes: 44 additions & 0 deletions src/raqm-version.h.in
@@ -0,0 +1,44 @@
/*
* Copyright © 2011 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and its documentation for any purpose, provided that the
* above copyright notice and the following two paragraphs appear in
* all copies of this software.
*
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* Google Author(s): Behdad Esfahbod
*/

#ifndef _RAQM_H_IN_
#error "Include <raqm.h> instead."
#endif

#ifndef _RAQM_VERSION_H_
#define _RAQM_VERSION_H_

#define RAQM_VERSION_MAJOR @RAQM_VERSION_MAJOR@
#define RAQM_VERSION_MINOR @RAQM_VERSION_MINOR@
#define RAQM_VERSION_MICRO @RAQM_VERSION_MICRO@

#define RAQM_VERSION_STRING "@RAQM_VERSION@"

#define RAQM_VERSION_ATLEAST(major,minor,micro) \
((major)*10000+(minor)*100+(micro) <= \
RAQM_VERSION_MAJOR*10000+RAQM_VERSION_MINOR*100+RAQM_VERSION_MICRO)

#endif /* _RAQM_VERSION_H_ */
104 changes: 104 additions & 0 deletions src/raqm.c
Expand Up @@ -1974,3 +1974,107 @@ _raqm_in_hangul_syllable (hb_codepoint_t ch)
(void)ch;
return false;
}

/**
* raqm_version:
* @major: (out): Library major version component.
* @minor: (out): Library minor version component.
* @micro: (out): Library micro version component.
*
* Returns library version as three integer components.
*
* Since: 0.7
**/
void
raqm_version (unsigned int *major,
unsigned int *minor,
unsigned int *micro)
{
*major = RAQM_VERSION_MAJOR;
*minor = RAQM_VERSION_MINOR;
*micro = RAQM_VERSION_MICRO;
}

/**
* raqm_version_string:
*
* Returns library version as a string with three components.
*
* Return value: library version string.
*
* Since: 0.7
**/
const char *
raqm_version_string (void)
{
return RAQM_VERSION_STRING;
}

/**
* raqm_version_atleast:
* @major: Library major version component.
* @minor: Library minor version component.
* @micro: Library micro version component.
*
* Checks if library version is less than or equal the specified version.
*
* Return value:
* %true if library version is less than or equal the specfied version, %false
* otherwise.
*
* Since: 0.7
**/
bool
raqm_version_atleast (unsigned int major,
unsigned int minor,
unsigned int micro)
{
return RAQM_VERSION_ATLEAST (major, minor, micro);
}

/**
* RAQM_VERSION_ATLEAST:
* @major: Library major version component.
* @minor: Library minor version component.
* @micro: Library micro version component.
*
* Checks if library version is less than or equal the specified version.
*
* Return value:
* %true if library version is less than or equal the specfied version, %false
* otherwise.
*
* Since: 0.7
**/

/**
* RAQM_VERSION_STRING:
*
* Library version as a string with three components.
*
* Since: 0.7
**/

/**
* RAQM_VERSION_MAJOR:
*
* Library major version component.
*
* Since: 0.7
**/

/**
* RAQM_VERSION_MINOR:
*
* Library minor version component.
*
* Since: 0.7
**/

/**
* RAQM_VERSION_MICRO:
*
* Library micro version component.
*
* Since: 0.7
**/
18 changes: 18 additions & 0 deletions src/raqm.h
Expand Up @@ -24,6 +24,7 @@

#ifndef _RAQM_H_
#define _RAQM_H_
#define _RAQM_H_IN_

#ifdef HAVE_CONFIG_H
#include "config.h"
Expand All @@ -38,6 +39,8 @@
extern "C" {
#endif

#include "raqm-version.h"

/**
* raqm_t:
*
Expand Down Expand Up @@ -161,7 +164,22 @@ raqm_position_to_index (raqm_t *rq,
int y,
size_t *index);

void
raqm_version (unsigned int *major,
unsigned int *minor,
unsigned int *micro);

const char *
raqm_version_string (void);

bool
raqm_version_atleast (unsigned int major,
unsigned int minor,
unsigned int micro);


#ifdef __cplusplus
}
#endif
#undef _RAQM_H_IN_
#endif /* _RAQM_H_ */
12 changes: 12 additions & 0 deletions tests/raqm-test.c
Expand Up @@ -116,8 +116,20 @@ main (int argc, char **argv)
raqm_direction_t dir;
int x = 0, y = 0;

unsigned int major, minor, micro;

setlocale (LC_ALL, "");

fprintf (stderr, "Raqm " RAQM_VERSION_STRING "\n");

raqm_version (&major, &minor, &micro);

assert (major == RAQM_VERSION_MAJOR);
assert (minor == RAQM_VERSION_MINOR);
assert (micro == RAQM_VERSION_MICRO);

assert (raqm_version_atleast (major, minor, micro));

if (!parse_args(argc, argv))
return 1;

Expand Down

0 comments on commit 80d75c8

Please sign in to comment.