Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
pwmt
zathura
Commits
9c334cc6
Commit
9c334cc6
authored
Mar 21, 2012
by
Sebastian Ramacher
Browse files
Add ABI versioning.
parent
8b63def8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
9c334cc6
...
...
@@ -43,7 +43,8 @@ version.h: version.h.in config.mk
$(QUIET)
sed
's/ZVMAJOR/
${ZATHURA_VERSION_MAJOR}
/'
< version.h.in |
\
sed
's/ZVMINOR/
${ZATHURA_VERSION_MINOR}
/'
|
\
sed
's/ZVREV/
${ZATHURA_VERSION_REV}
/'
|
\
sed
's/ZVAPI/
${ZATHURA_API_VERSION}
/'
>
version.h
sed
's/ZVAPI/
${ZATHURA_API_VERSION}
/'
|
\
sed
's/ZVABI/
${ZATHURA_ABI_VERSION}
/'
>
version.h
%.o
:
%.c
$(ECHO)
CC
$<
...
...
@@ -80,6 +81,7 @@ ${PROJECT}.pc: ${PROJECT}.pc.in config.mk
$(QUIET)
echo
project
=
${PROJECT}
>
${PROJECT}
.pc
$(QUIET)
echo
version
=
${VERSION}
>>
${PROJECT}
.pc
$(QUIET)
echo
apiversion
=
${ZATHURA_API_VERSION}
>>
${PROJECT}
.pc
$(QUIET)
echo
abiversion
=
${ZATHURA_ABI_VERSION}
>>
${PROJECT}
.pc
$(QUIET)
echo
includedir
=
${INCLUDEDIR}
>>
${PROJECT}
.pc
$(QUIET)
echo
plugindir
=
${PLUGINDIR}
>>
${PROJECT}
.pc
$(QUIET)
echo
GTK_VERSION
=
${ZATHURA_GTK_VERSION}
>>
${PROJECT}
.pc
...
...
config.mk
View file @
9c334cc6
...
...
@@ -4,7 +4,10 @@
ZATHURA_VERSION_MAJOR
=
0
ZATHURA_VERSION_MINOR
=
1
ZATHURA_VERSION_REV
=
1
# If the API changes, the API version and the ABI version have to be bumped.
ZATHURA_API_VERSION
=
1
# If the ABI breaks for any reason, this has to be bumped.
ZATHURA_ABI_VERSION
=
1
VERSION
=
${ZATHURA_VERSION_MAJOR}
.
${ZATHURA_VERSION_MINOR}
.
${ZATHURA_VERSION_REV}
# the GTK+ version to use
...
...
document.c
View file @
9c334cc6
...
...
@@ -63,7 +63,7 @@ zathura_document_plugins_load(zathura_t* zathura)
continue
;
}
/* resolve symbol and check API version*/
/* resolve symbol
s
and check API
and ABI
version*/
zathura_plugin_api_version_t
api_version
;
*
(
void
**
)(
&
api_version
)
=
dlsym
(
handle
,
PLUGIN_API_VERSION_FUNCTION
);
if
(
api_version
!=
NULL
)
{
...
...
@@ -75,7 +75,35 @@ zathura_document_plugins_load(zathura_t* zathura)
continue
;
}
}
else
{
#if ZATHURA_API_VERSION == 1
girara_warning
(
"could not find '%s' function in plugin %s ... loading anyway"
,
PLUGIN_API_VERSION_FUNCTION
,
path
);
#else
girara_error
(
"could not find '%s' function in plugin %s"
,
PLUGIN_API_VERSION_FUNCTION
,
path
);
g_free
(
path
);
dlclose
(
handle
);
continue
;
#endif
}
zathura_plugin_abi_version_t
abi_version
;
*
(
void
**
)(
&
abi_version
)
=
dlsym
(
handle
,
PLUGIN_ABI_VERSION_FUNCTION
);
if
(
abi_version
!=
NULL
)
{
if
(
abi_version
()
!=
ZATHURA_ABI_VERSION
)
{
girara_error
(
"plugin %s has been built againt zathura with a different ABI version (plugin: %d, zathura: %d)"
,
path
,
abi_version
(),
ZATHURA_ABI_VERSION
);
g_free
(
path
);
dlclose
(
handle
);
continue
;
}
}
else
{
#if ZATHURA_API_VERSION == 1
girara_warning
(
"could not find '%s' function in plugin %s ... loading anyway"
,
PLUGIN_ABI_VERSION_FUNCTION
,
path
);
#else
girara_error
(
"could not find '%s' function in plugin %s"
,
PLUGIN_ABI_VERSION_FUNCTION
,
path
);
g_free
(
path
);
dlclose
(
handle
);
continue
;
#endif
}
zathura_plugin_register_service_t
register_plugin
;
...
...
document.h
View file @
9c334cc6
...
...
@@ -13,6 +13,7 @@
#define PLUGIN_REGISTER_FUNCTION "plugin_register"
#define PLUGIN_API_VERSION_FUNCTION "plugin_api_version"
#define PLUGIN_ABI_VERSION_FUNCTION "plugin_abi_version"
/**
* Register a plugin.
...
...
@@ -29,6 +30,7 @@
unsigned int plugin_version_minor() { return minor; } \
unsigned int plugin_version_revision() { return rev; } \
unsigned int plugin_api_version() { return ZATHURA_API_VERSION; } \
unsigned int plugin_abi_version() { return ZATHURA_ABI_VERSION; } \
\
void plugin_register(zathura_document_plugin_t* plugin) \
{ \
...
...
@@ -119,6 +121,14 @@ typedef void (*zathura_plugin_register_service_t)(zathura_document_plugin_t*);
*/
typedef
unsigned
int
(
*
zathura_plugin_api_version_t
)();
/**
* Function prototype that is called to get the ABI version the plugin is built
* against.
*
* @return plugin's ABI version
*/
typedef
unsigned
int
(
*
zathura_plugin_abi_version_t
)();
/**
* Image buffer
*/
...
...
version.h.in
View file @
9c334cc6
...
...
@@ -8,5 +8,6 @@
#define ZATHURA_VERSION_REV ZVREV
#define ZATHURA_VERSION "ZVMAJOR.ZVMINOR.ZVREV"
#define ZATHURA_API_VERSION ZVAPI
#define ZATHURA_ABI_VERSION ZVABI
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment