aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-06-04 13:31:17 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-06-07 10:04:53 -0400
commit08e77f6f601736df1a53c33c4e13bc3fb2e98af4 (patch)
tree4c5eec35df3480b730fb03069916609b8997672f
parent1249a287b9ca730966f753d378086520b76db43f (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--Makefile6
-rw-r--r--plugin_python.c6
2 files changed, 10 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index ad2d708..a1096f2 100644
--- a/Makefile
+++ b/Makefile
@@ -487,15 +487,17 @@ python-gui: ctracecmd.so ctracecmdgui.so
487PHONY += python-plugin 487PHONY += python-plugin
488python-plugin: plugin_python.so python 488python-plugin: plugin_python.so python
489 489
490CFLAGS_plugin_python.o += $(PYTHON_DIR_SQ)
491
490do_compile_python_plugin_obj = \ 492do_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
494do_python_plugin_build = \ 496do_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
498plugin_python.o: %.o : $(src)/%.c 500plugin_python.o: %.o : $(src)/%.c trace_python_dir
499 $(Q)$(do_compile_python_plugin_obj) 501 $(Q)$(do_compile_python_plugin_obj)
500 502
501plugin_python.so: %.so: %.o 503plugin_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
5static const char pyload[] = 9static 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"