diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2010-06-04 13:31:17 -0400 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2010-06-07 10:04:53 -0400 |
| commit | 08e77f6f601736df1a53c33c4e13bc3fb2e98af4 (patch) | |
| tree | 4c5eec35df3480b730fb03069916609b8997672f | |
| parent | 1249a287b9ca730966f753d378086520b76db43f (diff) | |
trace-cmd: Add PLYTHON_DIR to search path for the python plugins
Automate the loading of the PYTHON_DIR to tell the plugins where to
load the trace-cmd specific modules.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
| -rw-r--r-- | Makefile | 6 | ||||
| -rw-r--r-- | plugin_python.c | 6 |
2 files changed, 10 insertions, 2 deletions
| @@ -487,15 +487,17 @@ python-gui: ctracecmd.so ctracecmdgui.so | |||
| 487 | PHONY += python-plugin | 487 | PHONY += python-plugin |
| 488 | python-plugin: plugin_python.so python | 488 | python-plugin: plugin_python.so python |
| 489 | 489 | ||
| 490 | CFLAGS_plugin_python.o += $(PYTHON_DIR_SQ) | ||
| 491 | |||
| 490 | do_compile_python_plugin_obj = \ | 492 | do_compile_python_plugin_obj = \ |
| 491 | ($(print_plugin_obj_compile) \ | 493 | ($(print_plugin_obj_compile) \ |
| 492 | $(CC) -c $(CFLAGS) $(PYTHON_INCLUDES) -fPIC -o $@ $<) | 494 | $(CC) -c $(CFLAGS) $(CFLAGS_$@) $(PYTHON_INCLUDES) -fPIC -o $@ $<) |
| 493 | 495 | ||
| 494 | do_python_plugin_build = \ | 496 | do_python_plugin_build = \ |
| 495 | ($(print_plugin_build) \ | 497 | ($(print_plugin_build) \ |
| 496 | $(CC) -shared $(PYTHON_LDFLAGS) -o $@ $<) | 498 | $(CC) -shared $(PYTHON_LDFLAGS) -o $@ $<) |
| 497 | 499 | ||
| 498 | plugin_python.o: %.o : $(src)/%.c | 500 | plugin_python.o: %.o : $(src)/%.c trace_python_dir |
| 499 | $(Q)$(do_compile_python_plugin_obj) | 501 | $(Q)$(do_compile_python_plugin_obj) |
| 500 | 502 | ||
| 501 | plugin_python.so: %.so: %.o | 503 | plugin_python.so: %.so: %.o |
diff --git a/plugin_python.c b/plugin_python.c index dada5dc..0f52bb3 100644 --- a/plugin_python.c +++ b/plugin_python.c | |||
| @@ -2,7 +2,13 @@ | |||
| 2 | #include <stdio.h> | 2 | #include <stdio.h> |
| 3 | #include "trace-cmd.h" | 3 | #include "trace-cmd.h" |
| 4 | 4 | ||
| 5 | #ifndef PYTHON_DIR | ||
| 6 | #define PYTHON_DIR . | ||
| 7 | #endif | ||
| 8 | |||
| 5 | static const char pyload[] = | 9 | static const char pyload[] = |
| 10 | "import sys\n" | ||
| 11 | "sys.path.append(\"" MAKE_STR(PYTHON_DIR) "\")\n" | ||
| 6 | "import imp, tracecmd, ctracecmd\n" | 12 | "import imp, tracecmd, ctracecmd\n" |
| 7 | "fn = r'%s'\n" | 13 | "fn = r'%s'\n" |
| 8 | "file = open(fn, 'r')\n" | 14 | "file = open(fn, 'r')\n" |
