summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2012-12-11 13:47:18 +0200
committerYakov Goldberg <yakov.g@samsung.com>2012-12-11 13:48:21 +0200
commit301f4ea677ca7eced80fac38dc0d7393de59a27b (patch)
tree2dcbd1e0e98451f3142e706d7afb1a48d8968888
parentfdd7be27e03a4d549a2de1778f6d554f8053ca4d (diff)
Command line options added for Py generator
-I to include search path for headers -L to include search path for libraries -l to include libs Signed-off-by: Yakov Goldberg <yakov.g@samsung.com>
-rw-r--r--eo_py/README2
-rwxr-xr-xeo_py/eo_py_gen.py46
2 files changed, 41 insertions, 7 deletions
diff --git a/eo_py/README b/eo_py/README
index e5698ae..96c7865 100644
--- a/eo_py/README
+++ b/eo_py/README
@@ -11,7 +11,7 @@ python module.
11 11
121. Generating python module for classes defined in XMLs: 121. Generating python module for classes defined in XMLs:
13 a. > python eo_py_gen.py --dir=XML_FOLDER --outdir=OUTDIR --pkg="lib1 lib2" 13 a. > python eo_py_gen.py --dir=XML_FOLDER --outdir=OUTDIR --pkg="lib1 lib2"
14 --module=MODULE_NAME --include=INCLUDE_DIR 14 --module=MODULE_NAME --xmldir=INCLUDE_XML_DIR -lname -I/include
15 In case if some class is needed (usually parent class, which is not in the tree being analyzed), 15 In case if some class is needed (usually parent class, which is not in the tree being analyzed),
16 include XMLs are searched in python system paths. 16 include XMLs are searched in python system paths.
17 If include file wasn't found, explicit --include=INCLUDE_DIR dir is needed 17 If include file wasn't found, explicit --include=INCLUDE_DIR dir is needed
diff --git a/eo_py/eo_py_gen.py b/eo_py/eo_py_gen.py
index 1dfad4f..bcb60be 100755
--- a/eo_py/eo_py_gen.py
+++ b/eo_py/eo_py_gen.py
@@ -12,7 +12,13 @@ def verbose_false(mes):
12 pass 12 pass
13 13
14 14
15def setup_file_generate(module_name, pkg, outdir): 15def setup_file_generate(args, outdir):
16 module_name = args.module
17 pkg = args.pkg
18 incl_paths = args.include_paths
19 libs = args.libraries
20 lib_paths = args.library_paths
21
16 module_file = module_name + ".pyx" 22 module_file = module_name + ".pyx"
17 23
18 lines = [] 24 lines = []
@@ -31,9 +37,28 @@ def setup_file_generate(module_name, pkg, outdir):
31 lines.append("(e_compile_args, e_link_args) = pkgconfig(\"%s\")"%pkg) 37 lines.append("(e_compile_args, e_link_args) = pkgconfig(\"%s\")"%pkg)
32 lines.append("") 38 lines.append("")
33 39
34 lines.append("e_include_dirs = [\".\"]") 40 include_dirs = ["\".\""]
35 lines.append("e_library_dirs = []") 41 if incl_paths is not None:
36 lines.append("e_libraries = []") 42 for i in incl_paths:
43 include_dirs.append("\"%s\""%i)
44 lines.append("e_include_dirs = [%s]"%', '.join(include_dirs))
45 del include_dirs
46
47 lib_dirs = []
48 if lib_paths is not None:
49 for i in lib_paths:
50 lib_dirs.append("\"%s\""%i)
51 lines.append("e_library_dirs = [%s]"%', '.join(lib_dirs))
52 del lib_dirs
53
54 lib_names = []
55 if libs is not None:
56 for i in libs:
57 lib_names.append("\"%s\""%i)
58 lines.append("e_libraries = [%s]"%', '.join(lib_names))
59 del lib_names
60
61
37 lines.append("") 62 lines.append("")
38 63
39 lines.append("setup(") 64 lines.append("setup(")
@@ -66,7 +91,7 @@ def main():
66 action="store_true", dest="verbose", default=False, 91 action="store_true", dest="verbose", default=False,
67 help="Print status messages to stdout. Default: False") 92 help="Print status messages to stdout. Default: False")
68 93
69 parser.add_argument("-i", "--include", dest="xmldir", default=sys.path, 94 parser.add_argument("-X", "--xmldir", dest="xmldir", default=sys.path,
70 action="append", help="Include eobase directory") 95 action="append", help="Include eobase directory")
71 96
72 parser.add_argument("--pkg", dest="pkg", default = "eo", 97 parser.add_argument("--pkg", dest="pkg", default = "eo",
@@ -75,6 +100,15 @@ def main():
75 parser.add_argument("-m", "--module", dest="module", 100 parser.add_argument("-m", "--module", dest="module",
76 action="store", help="Name of module to generate") 101 action="store", help="Name of module to generate")
77 102
103 parser.add_argument("-I", "--include", dest="include_paths",
104 action="append", help="Pre-processor include path")
105
106 parser.add_argument("-l", "--library", dest="libraries",
107 action="append", help="Libraries of this unit")
108
109 parser.add_argument("-L", "--library-path", dest="library_paths",
110 action="append", help="Directories to search for libraries")
111
78 args = parser.parse_args() 112 args = parser.parse_args()
79 113
80 verbose_print = verbose_true if args.verbose is True else verbose_false 114 verbose_print = verbose_true if args.verbose is True else verbose_false
@@ -114,7 +148,7 @@ def main():
114 xp.module_parse(args.module, xml_files, incl_dirs) 148 xp.module_parse(args.module, xml_files, incl_dirs)
115 xp.py_code_generate(args.module ,outdir) 149 xp.py_code_generate(args.module ,outdir)
116 150
117 setup_file_generate(args.module, args.pkg, outdir) 151 setup_file_generate(args, outdir)
118 152
119 #Looking for "eodefault.pxd" module. Needed to include 153 #Looking for "eodefault.pxd" module. Needed to include
120 for d in incl_dirs: 154 for d in incl_dirs: