summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2012-12-11 10:47:21 +0200
committerYakov Goldberg <yakov.g@samsung.com>2012-12-11 13:48:14 +0200
commitfdd7be27e03a4d549a2de1778f6d554f8053ca4d (patch)
treeca6f36c64ec7803138e2e3f27133410be23c8efe
parenta38de8eb3eb758887c3a4176bce5968dfc991c58 (diff)
Command line options added to JS generator
-I to include search path for headers -L to include search path for libraries -l to include libs -D to define macros Signed-off-by: Yakov Goldberg <yakov.g@samsung.com>
-rw-r--r--eo_js/README15
-rwxr-xr-xeo_js/eo_js_gen.py57
2 files changed, 54 insertions, 18 deletions
diff --git a/eo_js/README b/eo_js/README
index 3a783e0..e013ce7 100644
--- a/eo_js/README
+++ b/eo_js/README
@@ -11,18 +11,27 @@ module, which can be used with V8-based js-engine - elev8.
11 11
121. Generating js module for classes defined in XMLs: 121. Generating js module for classes defined in XMLs:
13 a. > python eo_js_gen.py --dir=XML_FOLDER --outdir=OUTDIR 13 a. > python eo_js_gen.py --dir=XML_FOLDER --outdir=OUTDIR
14 --module=MODULE_NAME --include=INCLUDE_DIR 14 --module=MODULE_NAME --xmldir=INCLUDE_XML_DIR -lname -I/include
15 -DSOME_PATH=\"/path\"
15 16
16 In case if some class is needed 17 In case if some class is needed
17 (usually parent class, which is not in the tree being analyzed), 18 (usually parent class, which is not in the tree being analyzed),
18 include XMLs are searched in python system paths. 19 include XMLs are searched in python system paths.
19 If include file wasn't found, explicit --include=INCLUDE_DIR dir is needed 20 If include file wasn't found, explicit --xmldir=INCLUDE_DIR dir is needed
20 21
21 Files to be generated: 22 Files to be generated:
22 - *.cc, *.h will be created for each *.xml 23 - *.cc, *.h will be created for each *.xml
24 - _module.cc with EoRegisterModule()
25 if you need to call any functions on module load,
26 add them in this func.
27 - Makefile
23 b. Compiling module: 28 b. Compiling module:
24 > not yet. 29 You can edit generated Makefile, if you need to add some additional flags
30 > make
31 - modul_name.so will be genratade
32
25 following files are needed to compile 33 following files are needed to compile
34 main.cc
26 elm.h 35 elm.h
27 CElmObject.cc 36 CElmObject.cc
28 CElmObject.h 37 CElmObject.h
diff --git a/eo_js/eo_js_gen.py b/eo_js/eo_js_gen.py
index 6840ccc..a5a054c 100755
--- a/eo_js/eo_js_gen.py
+++ b/eo_js/eo_js_gen.py
@@ -15,10 +15,21 @@ def verbose_true(mes):
15def verbose_false(mes): 15def verbose_false(mes):
16 pass 16 pass
17 17
18def makefile_file_generate(module_name, args, c_files, outdir): 18def makefile_file_generate(args, c_files, outdir):
19 module_name = args.module
19 pkg = args.pkg 20 pkg = args.pkg
21 incl_paths = ["."]
22 incl_paths += args.include_paths
20 libs = args.libraries 23 libs = args.libraries
21 incl = args.includedirs 24 lib_paths = args.library_paths
25 cpp_defines = args.cpp_defines
26
27 if cpp_defines is not None:
28 lst_tmp = []
29 for d in cpp_defines:
30 lst_tmp.append(d.replace("\"", "\\\""))
31 cpp_defines = list(lst_tmp)
32 del lst_tmp
22 33
23 makefile_file = "Makefile" 34 makefile_file = "Makefile"
24 default_c_files = ['main.cc', 'CElmObject.cc', '_eobase.cc', '_module.cc'] 35 default_c_files = ['main.cc', 'CElmObject.cc', '_eobase.cc', '_module.cc']
@@ -38,14 +49,19 @@ def makefile_file_generate(module_name, args, c_files, outdir):
38 49
39 lines.append("") 50 lines.append("")
40 lines.append("lib_CFLAGS = \\") 51 lines.append("lib_CFLAGS = \\")
41 lines.append("-I. \\") 52 # lines.append("-I. \\")
42 lines.append("-DPACKAGE_DATA_DIR=\\\"/tmp\\\" \\") 53 #lines.append("-DPACKAGE_DATA_DIR=\\\"/tmp\\\" \\")
43 lines.append("-DPACKAGE_TMP_DIR=\\\"/tmp\\\" \\") 54 #lines.append("-DPACKAGE_TMP_DIR=\\\"/tmp\\\" \\")
55
56 for i in incl_paths:
57 lines.append("-I%s \\"%i)
58
44 for l in pkg.split(): 59 for l in pkg.split():
45 lines.append("`pkg-config --cflags %s` \\"%l) 60 lines.append("`pkg-config --cflags %s` \\"%l)
46 if incl is not None: 61
47 for i in incl: 62 if cpp_defines is not None:
48 lines.append("-I%s \\"%i) 63 for d in cpp_defines:
64 lines.append("-D%s \\"%d)
49 lines[-1] = lines[-1][:-2] 65 lines[-1] = lines[-1][:-2]
50 66
51 lines.append("") 67 lines.append("")
@@ -53,6 +69,10 @@ def makefile_file_generate(module_name, args, c_files, outdir):
53 for l in pkg.split(): 69 for l in pkg.split():
54 lines.append("`pkg-config --libs %s` \\"%l) 70 lines.append("`pkg-config --libs %s` \\"%l)
55 71
72 if lib_paths is not None:
73 for l in lib_paths:
74 lines.append("-L%s \\"%l)
75
56 if libs is not None: 76 if libs is not None:
57 for l in libs: 77 for l in libs:
58 lines.append("-l%s \\"%l) 78 lines.append("-l%s \\"%l)
@@ -91,7 +111,7 @@ def main():
91 action="store_true", dest="verbose", default=False, 111 action="store_true", dest="verbose", default=False,
92 help="Print status messages to stdout. Default: False") 112 help="Print status messages to stdout. Default: False")
93 113
94 parser.add_argument("-i", "--include", dest="xmldir", default=sys.path, 114 parser.add_argument("-X", "--xmldir", dest="xmldir", default=sys.path,
95 action="append", help="Include eobase directory") 115 action="append", help="Include eobase directory")
96 116
97 parser.add_argument("--pkg", dest="pkg", default = "elementary eo", 117 parser.add_argument("--pkg", dest="pkg", default = "elementary eo",
@@ -100,11 +120,18 @@ def main():
100 parser.add_argument("-m", "--module", dest="module", 120 parser.add_argument("-m", "--module", dest="module",
101 action="store", help="Name of module to generate") 121 action="store", help="Name of module to generate")
102 122
103 parser.add_argument("-I", "--some", dest="includedirs", 123 parser.add_argument("-I", "--include", dest="include_paths",
104 action="append", help="Include paths") 124 action="append", help="Pre-processor include path")
125
126 parser.add_argument("-l", "--library", dest="libraries",
127 action="append", help="Libraries of this unit")
128
129 parser.add_argument("-L", "--library-path", dest="library_paths",
130 action="append", help="Directories to search for libraries")
131
132 parser.add_argument("-D", "--define", dest="cpp_defines",
133 action="append", help="Pre-processor define")
105 134
106 parser.add_argument("-l", "--lib", dest="libraries",
107 action="append", help="Libraries to compile with")
108 135
109 args = parser.parse_args() 136 args = parser.parse_args()
110 137
@@ -147,7 +174,7 @@ def main():
147 for n, o in xp.objects.items(): 174 for n, o in xp.objects.items():
148 c_files.append(o.V.c_file.name) 175 c_files.append(o.V.c_file.name)
149 176
150 makefile_file_generate(args.module, args, c_files, outdir) 177 makefile_file_generate(args, c_files, outdir)
151 178
152 del xp 179 del xp
153 180