summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitesh Singh <amitesh.sh@samsung.com>2016-08-29 23:22:15 +0530
committerAmitesh Singh <amitesh.sh@samsung.com>2016-08-31 11:23:59 +0530
commit81244929a2e8d98c9227b825e00d9da18f7f23b8 (patch)
treec3c261d3ece1b68f9f112b4e2708b9221ed7771d
parent3f5149a675f71a213fcf1265892f8080d20045ec (diff)
downloadefl-devs/ami/eina.tar.gz
eina: module - Add macros for adding module informationsdevs/ami/eina
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 use"); // 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
-rw-r--r--src/Makefile_Eina.am14
-rw-r--r--src/bin/eina/eina_modinfo.c47
-rw-r--r--src/lib/eina/eina_inline_modinfo.x77
-rw-r--r--src/lib/eina/eina_module.h1
-rw-r--r--src/modules/elementary/test_entry/mod.c5
5 files changed, 143 insertions, 1 deletions
diff --git a/src/Makefile_Eina.am b/src/Makefile_Eina.am
index f2a5762836..020052ad28 100644
--- a/src/Makefile_Eina.am
+++ b/src/Makefile_Eina.am
@@ -101,7 +101,8 @@ lib/eina/eina_bezier.h \
lib/eina/eina_safepointer.h \
lib/eina/eina_inline_safepointer.x \
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/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_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
bin_SCRIPTS += scripts/eina/eina-bench-cmp
diff --git a/src/bin/eina/eina_modinfo.c b/src/bin/eina/eina_modinfo.c
new file mode 100644
index 0000000000..9457ba15bd
--- /dev/null
+++ b/src/bin/eina/eina_modinfo.c
@@ -0,0 +1,47 @@
+/* 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/>.
+ */
+
+#include <stdio.h>
+#include <dlfcn.h>
+
+int main(int argc, char **argv)
+{
+ void *lib;
+
+ if (argc != 2)
+ {
+ fprintf(stderr, "Error: Missing module or filename\n");
+ return 1;
+ }
+
+ lib = dlopen(argv[1], RTLD_LAZY);
+ if (!lib)
+ {
+ fprintf(stderr, "Error: Failed to open: %s\n", argv[1]);
+ return 2;
+ }
+
+ printf("version:\t%s\n", (char *)dlsym(lib, "__EINA_MODULE_UNIQUE_ID_ver"));
+ printf("description:\t%s\n", (char *)dlsym(lib, "__EINA_MODULE_UNIQUE_ID_desc"));
+ printf("license:\t%s\n", (char *)dlsym(lib, "__EINA_MODULE_UNIQUE_ID_license"));
+ printf("author:\t%s\n", (char *)dlsym(lib, "__EINA_MODULE_UNIQUE_ID_author"));
+
+ dlclose(lib);
+
+ return 0;
+}
diff --git a/src/lib/eina/eina_inline_modinfo.x b/src/lib/eina/eina_inline_modinfo.x
new file mode 100644
index 0000000000..7c931dab27
--- /dev/null
+++ b/src/lib/eina/eina_inline_modinfo.x
@@ -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
+
diff --git a/src/lib/eina/eina_module.h b/src/lib/eina/eina_module.h
index d1030b9681..74395dcd14 100644
--- a/src/lib/eina/eina_module.h
+++ b/src/lib/eina/eina_module.h
@@ -22,6 +22,7 @@
#include "eina_types.h"
#include "eina_array.h"
#include "eina_error.h"
+#include "eina_inline_modinfo.x"
/**
* @addtogroup Eina_Module_Group Module
diff --git a/src/modules/elementary/test_entry/mod.c b/src/modules/elementary/test_entry/mod.c
index d2d5171af2..623cb48609 100644
--- a/src/modules/elementary/test_entry/mod.c
+++ b/src/modules/elementary/test_entry/mod.c
@@ -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_SHUTDOWN(_module_shutdown);