ami pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=d88f08f7e92a06ce114466da41886463be58c8d8

commit d88f08f7e92a06ce114466da41886463be58c8d8
Author: Amitesh Singh <[email protected]>
Date:   Wed Aug 31 16:17:52 2016 +0530

    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
---
 src/Makefile_Eina.am                    | 14 +++++-
 src/bin/eina/.gitignore                 |  1 +
 src/bin/eina/eina_modinfo.c             | 57 ++++++++++++++++++++++++
 src/lib/eina/eina_inline_modinfo.x      | 77 +++++++++++++++++++++++++++++++++
 src/lib/eina/eina_module.h              |  1 +
 src/modules/elementary/test_entry/mod.c |  5 +++
 6 files changed, 154 insertions(+), 1 deletion(-)

diff --git a/src/Makefile_Eina.am b/src/Makefile_Eina.am
index f2a5762..020052a 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/.gitignore b/src/bin/eina/.gitignore
index ec4ebaa..a35f69e 100644
--- a/src/bin/eina/.gitignore
+++ b/src/bin/eina/.gitignore
@@ -1 +1,2 @@
 eina_btlog
+eina_modinfo
diff --git a/src/bin/eina/eina_modinfo.c b/src/bin/eina/eina_modinfo.c
new file mode 100644
index 0000000..943c92b
--- /dev/null
+++ b/src/bin/eina/eina_modinfo.c
@@ -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;
+}
diff --git a/src/lib/eina/eina_inline_modinfo.x 
b/src/lib/eina/eina_inline_modinfo.x
new file mode 100644
index 0000000..7c931da
--- /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 d1030b9..74395dc 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 d2d5171..623cb48 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);

-- 


Reply via email to