forked from enlightenment/efl
eina: module - Add macros for adding module informations
Summary: These macros allow you to define module informations like author/description/version/license e.g. // Use "Name <email id>" or just "Name" EINA_MODULE_AUTHOR("Enlightenment Community"); // Mention license EINA_MODULE_LICENSE("GPL v2"); // What your module does EINA_MODULE_DESCRIPTION("This is what this module does"); // Module version EINA_MODULE_VERSION("0.1"); Now eina_modinfo can show these informations to users $ eina_modinfo module.so version: 0.1 description: Entry test license: GPLv2 author: Enlightenment Community @feature Reviewers: cedric, tasn, raster, jpeg Subscribers: seoz Differential Revision: https://phab.enlightenment.org/D4257
This commit is contained in:
parent
f88a4b8308
commit
d88f08f7e9
|
@ -101,7 +101,8 @@ lib/eina/eina_bezier.h \
|
||||||
lib/eina/eina_safepointer.h \
|
lib/eina/eina_safepointer.h \
|
||||||
lib/eina/eina_inline_safepointer.x \
|
lib/eina/eina_inline_safepointer.x \
|
||||||
lib/eina/eina_slice.h \
|
lib/eina/eina_slice.h \
|
||||||
lib/eina/eina_inline_slice.x
|
lib/eina/eina_inline_slice.x \
|
||||||
|
lib/eina/eina_inline_modinfo.x
|
||||||
|
|
||||||
lib_eina_libeina_la_SOURCES = \
|
lib_eina_libeina_la_SOURCES = \
|
||||||
lib/eina/eina_abi.c \
|
lib/eina/eina_abi.c \
|
||||||
|
@ -268,6 +269,17 @@ bin_eina_eina_btlog_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||||
bin_eina_eina_btlog_LDADD = @USE_EINA_LIBS@
|
bin_eina_eina_btlog_LDADD = @USE_EINA_LIBS@
|
||||||
bin_eina_eina_btlog_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@
|
bin_eina_eina_btlog_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@
|
||||||
|
|
||||||
|
bin_PROGRAMS += bin/eina/eina_modinfo
|
||||||
|
|
||||||
|
bin_eina_eina_modinfo_SOURCES = bin/eina/eina_modinfo.c
|
||||||
|
bin_eina_eina_modinfo_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||||
|
-DPACKAGE_BIN_DIR=\"$(bindir)\" \
|
||||||
|
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
|
||||||
|
-DPACKAGE_DATA_DIR=\"$(datadir)/eina\" \
|
||||||
|
@EINA_CFLAGS@
|
||||||
|
|
||||||
|
bin_eina_eina_modinfo_LDADD = @USE_EINA_LIBS@
|
||||||
|
|
||||||
### Script
|
### Script
|
||||||
|
|
||||||
bin_SCRIPTS += scripts/eina/eina-bench-cmp
|
bin_SCRIPTS += scripts/eina/eina-bench-cmp
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
eina_btlog
|
eina_btlog
|
||||||
|
eina_modinfo
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
/* EINA - EFL data type library
|
||||||
|
* Copyright (C) 2016 Amitesh Singh
|
||||||
|
*
|
||||||
|
* 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.1 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* --------------- usage ---------------------
|
||||||
|
* $ eina_modinfo <module.so>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Eina.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
Eina_Module *em;
|
||||||
|
|
||||||
|
eina_init();
|
||||||
|
if (argc != 2)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error: Missing module or filename\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
em = eina_module_new(argv[1]);
|
||||||
|
if (!em)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error: Failed to open: %s\n", argv[1]);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
if (!eina_module_load(em))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error: Failed to load module\n");
|
||||||
|
eina_module_free(em);
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("version: %s\n", (char *)eina_module_symbol_get(em, "__EINA_MODULE_UNIQUE_ID_ver"));
|
||||||
|
printf("description: %s\n", (char *)eina_module_symbol_get(em, "__EINA_MODULE_UNIQUE_ID_desc"));
|
||||||
|
printf("license: %s\n", (char *)eina_module_symbol_get(em, "__EINA_MODULE_UNIQUE_ID_license"));
|
||||||
|
printf("author: %s\n", (char *)eina_module_symbol_get(em, "__EINA_MODULE_UNIQUE_ID_author"));
|
||||||
|
|
||||||
|
eina_module_free(em);
|
||||||
|
eina_shutdown();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
/* EINA - EFL data type library
|
||||||
|
* Copyright (C) 2016 Amitesh Singh
|
||||||
|
*
|
||||||
|
* 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.1 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EINA_INLINE_MODINFO_X_
|
||||||
|
#define EINA_INLINE_MODINFO_X_
|
||||||
|
|
||||||
|
#define __EINA_MODINFO_CONCAT(a, b) a##b
|
||||||
|
#define _EINA_MODINFO_CONCAT(a, b) __EINA_MODINFO_CONCAT(a, b)
|
||||||
|
#define __EINA_MODULE_UNIQUE_ID(id) _EINA_MODINFO_CONCAT(__EINA_MODULE_UNIQUE_ID_, id)
|
||||||
|
|
||||||
|
#define _EINA_MODINFO(name, info) \
|
||||||
|
EAPI const char __EINA_MODULE_UNIQUE_ID(name)[] \
|
||||||
|
__attribute__((__used__)) __attribute__((unused, aligned(1))) = info;
|
||||||
|
#define EINA_MODINFO(tag, info) _EINA_MODINFO(tag, info)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup Eina_Module_Group Module
|
||||||
|
*
|
||||||
|
* These macros allow you to define module informations like author/description/version/license.
|
||||||
|
* eina_modinfo can show these informations to users
|
||||||
|
*
|
||||||
|
* $ eina_modinfo module.so
|
||||||
|
* version: 0.1
|
||||||
|
* description: Entry test
|
||||||
|
* license: GPLv2
|
||||||
|
* author: Enlightenment Community
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup Eina_Module_Group Module
|
||||||
|
*
|
||||||
|
* This macro is used for defining license.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define EINA_MODULE_LICENSE(_license) EINA_MODINFO(license, _license)
|
||||||
|
/**
|
||||||
|
* @defgroup Eina_Module_Group Module
|
||||||
|
*
|
||||||
|
* This macro is used for defining author
|
||||||
|
* Use "name <email>" or just "name"
|
||||||
|
* for multiple authors, use multiple lines like below
|
||||||
|
* EINA_MODULE_AUTHOR("Author 1 <author1.email>\n
|
||||||
|
"Author 2 <author2.email>");
|
||||||
|
*/
|
||||||
|
#define EINA_MODULE_AUTHOR(_author) EINA_MODINFO(author, _author)
|
||||||
|
/**
|
||||||
|
* @defgroup Eina_Module_Group Module
|
||||||
|
*
|
||||||
|
* This macro is used for defining version.
|
||||||
|
*/
|
||||||
|
#define EINA_MODULE_VERSION(_ver) EINA_MODINFO(ver, _ver)
|
||||||
|
/**
|
||||||
|
* @defgroup Eina_Module_Group Module
|
||||||
|
*
|
||||||
|
* This macro is used for defining description.
|
||||||
|
* Explain what your module does.
|
||||||
|
*/
|
||||||
|
#define EINA_MODULE_DESCRIPTION(_desc) EINA_MODINFO(desc, _desc)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "eina_types.h"
|
#include "eina_types.h"
|
||||||
#include "eina_array.h"
|
#include "eina_array.h"
|
||||||
#include "eina_error.h"
|
#include "eina_error.h"
|
||||||
|
#include "eina_inline_modinfo.x"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup Eina_Module_Group Module
|
* @addtogroup Eina_Module_Group Module
|
||||||
|
|
|
@ -47,5 +47,10 @@ _module_shutdown(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EINA_MODULE_VERSION("0.1");
|
||||||
|
EINA_MODULE_AUTHOR("Enlightenment Community");
|
||||||
|
EINA_MODULE_DESCRIPTION("Entry test");
|
||||||
|
EINA_MODULE_LICENSE("GPLv2");
|
||||||
|
|
||||||
EINA_MODULE_INIT(_module_init);
|
EINA_MODULE_INIT(_module_init);
|
||||||
EINA_MODULE_SHUTDOWN(_module_shutdown);
|
EINA_MODULE_SHUTDOWN(_module_shutdown);
|
||||||
|
|
Loading…
Reference in New Issue