summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2012-12-10 18:08:42 +0200
committerYakov Goldberg <yakov.g@samsung.com>2012-12-10 18:15:42 +0200
commita38de8eb3eb758887c3a4176bce5968dfc991c58 (patch)
treea94d0fc2d40ca934e58610d17442674f8e7b216b
parentc7d1b4f6c4f955397259a40436f6c13dda4894b8 (diff)
makefile generation added fo JS module
Signed-off-by: Yakov Goldberg <yakov.g@samsung.com>
-rwxr-xr-xeo_js/eo_js_gen.py76
-rw-r--r--eoparser/xmlparser.py33
2 files changed, 109 insertions, 0 deletions
diff --git a/eo_js/eo_js_gen.py b/eo_js/eo_js_gen.py
index 700c9a7..6840ccc 100755
--- a/eo_js/eo_js_gen.py
+++ b/eo_js/eo_js_gen.py
@@ -15,6 +15,70 @@ 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):
19 pkg = args.pkg
20 libs = args.libraries
21 incl = args.includedirs
22
23 makefile_file = "Makefile"
24 default_c_files = ['main.cc', 'CElmObject.cc', '_eobase.cc', '_module.cc']
25 c_files = default_c_files + c_files
26
27 lines = []
28 lines.append("CC=g++")
29 lines.append("all: lib%s.so"%module_name)
30 lines.append("\n")
31 lines.append("lib_SOURCES = \\")
32 for f in c_files:
33 lines.append("%s \\"%f)
34 lines[-1] = lines[-1][:-2]
35
36 lines.append("")
37 lines.append("lib_OBJECTS = $(lib_SOURCES:.cc=.o)")
38
39 lines.append("")
40 lines.append("lib_CFLAGS = \\")
41 lines.append("-I. \\")
42 lines.append("-DPACKAGE_DATA_DIR=\\\"/tmp\\\" \\")
43 lines.append("-DPACKAGE_TMP_DIR=\\\"/tmp\\\" \\")
44 for l in pkg.split():
45 lines.append("`pkg-config --cflags %s` \\"%l)
46 if incl is not None:
47 for i in incl:
48 lines.append("-I%s \\"%i)
49 lines[-1] = lines[-1][:-2]
50
51 lines.append("")
52 lines.append("lib_LDFLAGS = \\")
53 for l in pkg.split():
54 lines.append("`pkg-config --libs %s` \\"%l)
55
56 if libs is not None:
57 for l in libs:
58 lines.append("-l%s \\"%l)
59 lines[-1] = lines[-1][:-2]
60
61 lines.append("")
62 lines.append("lib%s.so: $(lib_OBJECTS)"%module_name)
63 lines.append("\t$(CC) -shared -Wl,-soname,$@ -o $@ $^ $(lib_LDFLAGS)")
64
65 lines.append("")
66 lines.append("%.o : %.cc $(libjse_HEADERS)")
67 lines.append("\t$(CC) -fPIC $(lib_CFLAGS) -c $< -o $@")
68
69 lines.append("")
70 lines.append("clean:")
71 lines.append("\trm -f *~ *.o *.so")
72
73
74 f = open(os.path.join(outdir, makefile_file), 'w')
75 for l in lines:
76 f.write(l + "\n")
77 f.close()
78
79
80
81
18def main(): 82def main():
19 parser = ArgumentParser() 83 parser = ArgumentParser()
20 parser.add_argument("-d", "--dir", dest="directory", 84 parser.add_argument("-d", "--dir", dest="directory",
@@ -36,6 +100,12 @@ def main():
36 parser.add_argument("-m", "--module", dest="module", 100 parser.add_argument("-m", "--module", dest="module",
37 action="store", help="Name of module to generate") 101 action="store", help="Name of module to generate")
38 102
103 parser.add_argument("-I", "--some", dest="includedirs",
104 action="append", help="Include paths")
105
106 parser.add_argument("-l", "--lib", dest="libraries",
107 action="append", help="Libraries to compile with")
108
39 args = parser.parse_args() 109 args = parser.parse_args()
40 110
41 verbose_print = verbose_true if args.verbose is True else verbose_false 111 verbose_print = verbose_true if args.verbose is True else verbose_false
@@ -73,6 +143,12 @@ def main():
73 xp.module_parse(args.module, xml_files, incl_dirs) 143 xp.module_parse(args.module, xml_files, incl_dirs)
74 xp.js_code_generate(outdir) 144 xp.js_code_generate(outdir)
75 145
146 c_files = []
147 for n, o in xp.objects.items():
148 c_files.append(o.V.c_file.name)
149
150 makefile_file_generate(args.module, args, c_files, outdir)
151
76 del xp 152 del xp
77 153
78if __name__ == "__main__": 154if __name__ == "__main__":
diff --git a/eoparser/xmlparser.py b/eoparser/xmlparser.py
index 80b60cd..045429b 100644
--- a/eoparser/xmlparser.py
+++ b/eoparser/xmlparser.py
@@ -1678,8 +1678,41 @@ class XMLparser(object):
1678 if o.instantiateable == "False": 1678 if o.instantiateable == "False":
1679 o.V.c_file.tmpl = "" 1679 o.V.c_file.tmpl = ""
1680 1680
1681 class_name_header_name = []
1681 #saving files 1682 #saving files
1682 for n, o in self.objects.items(): 1683 for n, o in self.objects.items():
1683 o.V.js_cc_file_to_dir_save(outdir) 1684 o.V.js_cc_file_to_dir_save(outdir)
1684 o.V.js_h_file_to_dir_save(outdir) 1685 o.V.js_h_file_to_dir_save(outdir)
1686 if o.eo_type == const.CLASS_TYPE_REGULAR:
1687 class_name_header_name.append((o.kl_id, o.V.h_file.name))
1688
1689 #generating separate file to add calls to Initialize for each class
1690 lines = []
1691 lines.append("/*This file was autogenerated to provide init on module load.")
1692 lines.append("Additional code can be added here, but it will be droppeded on next generation.*/\n\n")
1693 lines.append("#include <v8.h>\n")
1694 lines.append("using namespace v8;\n")
1695
1696 lines.append("#include \"elm.h\"\n")
1697
1698 for kl, h in class_name_header_name:
1699 lines.append("#include \"%s\""%h)
1700
1701 lines.append("\nnamespace elm {\n")
1702
1703 lines.append("/* elm_init() must be called from here. */")
1704 lines.append("void EoRegisterModule(Handle<Object> target)")
1705 lines.append("{")
1706
1707 for kl, h in class_name_header_name:
1708 lines.append(" %s::Initialize(target);"%kl)
1709 lines.append("}")
1710
1711 lines.append("}") #namespace elm end
1712
1713 f = open(os.path.join(outdir, "_module.cc"), 'w')
1714 for l in lines:
1715 f.write(l + "\n")
1716 f.close()
1717
1685 1718