summaryrefslogtreecommitdiffstats
path: root/events/eventskeygen.py
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/eventskeygen.py
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/eventskeygen.py')
-rw-r--r--events/eventskeygen.py49
1 files changed, 27 insertions, 22 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")