summaryrefslogtreecommitdiffstats
path: root/events
diff options
context:
space:
mode:
authorAravinda VK <avishwan@redhat.com>2016-07-28 15:49:59 +0530
committerAravinda VK <avishwan@redhat.com>2016-08-01 22:49:59 -0700
commit4429e842236015b51be37f3351d8f8df640744f5 (patch)
treed26116d2331dd35823d3527a956a5be2506cc4b5 /events
parent07b95cf8104da42d783d053d0fbb8497399f7d00 (diff)
eventsapi: Auto generate header files during make
$SRC/libglusterfs/src/eventtypes.h and $SRC/events/src/eventtypes.py are generated by running `python $SRC/events/eventskeygen.py` Header files generation step is added to make file itself, Now All new events should be added to only to $SRC/events/eventskeygen.py file. BUG: 1361094 Change-Id: I384961ef2978ca2d0be37f288b39ac0d834bdf06 Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: http://review.gluster.org/15035 Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Kotresh HR <khiremat@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'events')
-rw-r--r--events/eventskeygen.py49
-rw-r--r--events/src/Makefile.am9
-rw-r--r--events/src/eventtypes.py11
3 files changed, 35 insertions, 34 deletions
diff --git a/events/eventskeygen.py b/events/eventskeygen.py
index f9bdb9fed52..5bb03191135 100644
--- a/events/eventskeygen.py
+++ b/events/eventskeygen.py
@@ -11,11 +11,14 @@
#
import os
+import sys
GLUSTER_SRC_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
eventtypes_h = os.path.join(GLUSTER_SRC_ROOT, "libglusterfs/src/eventtypes.h")
eventtypes_py = os.path.join(GLUSTER_SRC_ROOT, "events/src/eventtypes.py")
+gen_header_type = sys.argv[1]
+
# When adding new keys add it to the END
keys = (
"EVENT_PEER_ATTACH",
@@ -39,29 +42,31 @@ ERRORS = (
"EVENT_ERROR_SEND"
)
-# Generate eventtypes.h
-with open(eventtypes_h, "w") as f:
- f.write("#ifndef __EVENTTYPES_H__\n")
- f.write("#define __EVENTTYPES_H__\n\n")
- f.write("typedef enum {\n")
- for k in ERRORS:
- f.write(" {0},\n".format(k))
- f.write("} event_errors_t;\n")
+if gen_header_type == "C_HEADER":
+ # Generate eventtypes.h
+ with open(eventtypes_h, "w") as f:
+ f.write("#ifndef __EVENTTYPES_H__\n")
+ f.write("#define __EVENTTYPES_H__\n\n")
+ f.write("typedef enum {\n")
+ for k in ERRORS:
+ f.write(" {0},\n".format(k))
+ f.write("} event_errors_t;\n")
- f.write("\n")
+ f.write("\n")
- f.write("typedef enum {\n")
- for k in keys:
- f.write(" {0},\n".format(k))
+ f.write("typedef enum {\n")
+ for k in keys:
+ f.write(" {0},\n".format(k))
- f.write(" {0}\n".format(LAST_EVENT))
- f.write("} eventtypes_t;\n")
- f.write("\n#endif /* __EVENTTYPES_H__ */\n")
+ f.write(" {0}\n".format(LAST_EVENT))
+ f.write("} eventtypes_t;\n")
+ f.write("\n#endif /* __EVENTTYPES_H__ */\n")
-# Generate eventtypes.py
-with open(eventtypes_py, "w") as f:
- f.write("# -*- coding: utf-8 -*-\n")
- f.write("all_events = [\n")
- for ev in keys:
- f.write(' "{0}",\n'.format(ev))
- f.write("]\n")
+if gen_header_type == "PY_HEADER":
+ # Generate eventtypes.py
+ with open(eventtypes_py, "w") as f:
+ f.write("# -*- coding: utf-8 -*-\n")
+ f.write("all_events = [\n")
+ for ev in keys:
+ f.write(' "{0}",\n'.format(ev))
+ f.write("]\n")
diff --git a/events/src/Makefile.am b/events/src/Makefile.am
index 50317d45191..8b2150e3aa9 100644
--- a/events/src/Makefile.am
+++ b/events/src/Makefile.am
@@ -1,6 +1,10 @@
-EXTRA_DIST = glustereventsd.py __init__.py eventsapiconf.py.in eventtypes.py \
+noinst_PYTHON = $(top_srcdir)/events/eventskeygen.py
+EXTRA_DIST = glustereventsd.py __init__.py eventsapiconf.py.in \
handlers.py utils.py peer_eventsapi.py eventsconfig.json
+BUILT_SOURCES = eventtypes.py
+CLEANFILES = eventtypes.py
+
eventsdir = $(libexecdir)/glusterfs/events
eventspeerscriptdir = $(libexecdir)/glusterfs
eventsconfdir = $(sysconfdir)/glusterfs
@@ -10,6 +14,9 @@ events_PYTHON = __init__.py eventsapiconf.py eventtypes.py handlers.py utils.py
events_SCRIPTS = glustereventsd.py
eventspeerscript_SCRIPTS = peer_eventsapi.py
+eventtypes.py: $(top_srcdir)/events/eventskeygen.py
+ $(PYTHON) $(top_srcdir)/events/eventskeygen.py PY_HEADER
+
install-exec-hook:
$(mkdir_p) $(DESTDIR)$(sbindir)
rm -f $(DESTDIR)$(sbindir)/glustereventsd
diff --git a/events/src/eventtypes.py b/events/src/eventtypes.py
deleted file mode 100644
index b09e5bcff9a..00000000000
--- a/events/src/eventtypes.py
+++ /dev/null
@@ -1,11 +0,0 @@
-# -*- coding: utf-8 -*-
-all_events = [
- "EVENT_PEER_ATTACH",
- "EVENT_PEER_DETACH",
- "EVENT_VOLUME_CREATE",
- "EVENT_VOLUME_START",
- "EVENT_VOLUME_STOP",
- "EVENT_VOLUME_DELETE",
- "EVENT_VOLUME_SET",
- "EVENT_VOLUME_RESET",
-]