summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--events/eventskeygen.py49
-rw-r--r--events/src/Makefile.am9
-rw-r--r--events/src/eventtypes.py11
-rw-r--r--libglusterfs/src/Makefile.am10
-rw-r--r--libglusterfs/src/eventtypes.h24
6 files changed, 46 insertions, 59 deletions
diff --git a/.gitignore b/.gitignore
index 695daea6497..0563392f167 100644
--- a/.gitignore
+++ b/.gitignore
@@ -108,3 +108,5 @@ xlators/experimental/jbr-server/src/jbr-cg.c
events/src/eventsapiconf.py
libglusterfs/src/events.h
extras/systemd/glustereventsd.service
+events/src/eventtypes.py
+libglusterfs/src/eventtypes.h
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",
-]
diff --git a/libglusterfs/src/Makefile.am b/libglusterfs/src/Makefile.am
index 1d1c9d1a3ce..1fdd5a70fa4 100644
--- a/libglusterfs/src/Makefile.am
+++ b/libglusterfs/src/Makefile.am
@@ -1,4 +1,4 @@
-noinst_PYTHON = generator.py gen-defaults.py
+noinst_PYTHON = generator.py gen-defaults.py $(top_srcdir)/events/eventskeygen.py
libglusterfs_la_CFLAGS = $(GF_CFLAGS) $(GF_DARWIN_LIBGLUSTERFS_CFLAGS) \
-DDATADIR=\"$(localstatedir)\"
@@ -72,9 +72,13 @@ libglusterfs_la_SOURCES += $(CONTRIBDIR)/uuid/clear.c \
endif
if BUILD_EVENTS
+BUILT_SOURCES += eventtypes.h
libglusterfs_la_SOURCES += events.c
libglusterfs_la_HEADERS += events.h eventtypes.h
+
+eventtypes.h: $(top_srcdir)/events/eventskeygen.py
+ $(PYTHON) $(top_srcdir)/events/eventskeygen.py C_HEADER
endif
libgfchangelog_HEADERS = changelog.h
@@ -104,3 +108,7 @@ CLEANFILES += *.gcda *.gcno *_xunit.xml
noinst_PROGRAMS =
TESTS =
endif
+
+if BUILD_EVENTS
+CLEANFILES += eventtypes.h
+endif
diff --git a/libglusterfs/src/eventtypes.h b/libglusterfs/src/eventtypes.h
deleted file mode 100644
index 20c4b02ebab..00000000000
--- a/libglusterfs/src/eventtypes.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef __EVENTTYPES_H__
-#define __EVENTTYPES_H__
-
-typedef enum {
- EVENT_SEND_OK,
- EVENT_ERROR_INVALID_INPUTS,
- EVENT_ERROR_SOCKET,
- EVENT_ERROR_CONNECT,
- EVENT_ERROR_SEND,
-} event_errors_t;
-
-typedef enum {
- EVENT_PEER_ATTACH,
- EVENT_PEER_DETACH,
- EVENT_VOLUME_CREATE,
- EVENT_VOLUME_START,
- EVENT_VOLUME_STOP,
- EVENT_VOLUME_DELETE,
- EVENT_VOLUME_SET,
- EVENT_VOLUME_RESET,
- EVENT_LAST
-} eventtypes_t;
-
-#endif /* __EVENTTYPES_H__ */