equal
deleted
inserted
replaced
36 |
36 |
37 from os import listdir, path |
37 from os import listdir, path |
38 import util.paths as paths |
38 import util.paths as paths |
39 |
39 |
40 _base_path = paths.AbsDir(__file__) |
40 _base_path = paths.AbsDir(__file__) |
|
41 |
|
42 |
41 def _GetLocalTargetClassFactory(name): |
43 def _GetLocalTargetClassFactory(name): |
42 return lambda:getattr(__import__(name,globals(),locals()), name+"_target") |
44 return lambda:getattr(__import__(name,globals(),locals()), name+"_target") |
43 |
45 |
44 targets = dict([(name, {"xsd":path.join(_base_path, name, "XSD"), |
46 targets = dict([(name, {"xsd":path.join(_base_path, name, "XSD"), |
45 "class":_GetLocalTargetClassFactory(name), |
47 "class":_GetLocalTargetClassFactory(name), |
52 and not name.startswith("__")]) |
54 and not name.startswith("__")]) |
53 |
55 |
54 toolchains = {"gcc": path.join(_base_path, "XSD_toolchain_gcc"), |
56 toolchains = {"gcc": path.join(_base_path, "XSD_toolchain_gcc"), |
55 "makefile": path.join(_base_path, "XSD_toolchain_makefile")} |
57 "makefile": path.join(_base_path, "XSD_toolchain_makefile")} |
56 |
58 |
|
59 |
57 def GetBuilder(targetname): |
60 def GetBuilder(targetname): |
58 return targets[targetname]["class"]() |
61 return targets[targetname]["class"]() |
|
62 |
59 |
63 |
60 def GetTargetChoices(): |
64 def GetTargetChoices(): |
61 DictXSD_toolchain = {} |
65 DictXSD_toolchain = {} |
62 targetchoices = "" |
66 targetchoices = "" |
63 |
67 |
72 xsd_string = open(nfo["xsd"]).read() |
76 xsd_string = open(nfo["xsd"]).read() |
73 targetchoices += xsd_string % DictXSD_toolchain |
77 targetchoices += xsd_string % DictXSD_toolchain |
74 |
78 |
75 return targetchoices |
79 return targetchoices |
76 |
80 |
|
81 |
77 def GetTargetCode(targetname): |
82 def GetTargetCode(targetname): |
78 codedesc = targets[targetname]["code"] |
83 codedesc = targets[targetname]["code"] |
79 code = "\n".join([open(fpath).read() for fname, fpath in sorted(codedesc.items())]) |
84 code = "\n".join([open(fpath).read() for fname, fpath in sorted(codedesc.items())]) |
80 return code |
85 return code |
81 |
86 |
|
87 |
82 def GetHeader(): |
88 def GetHeader(): |
83 filename = paths.AbsNeighbourFile(__file__,"beremiz.h") |
89 filename = paths.AbsNeighbourFile(__file__,"beremiz.h") |
84 return open(filename).read() |
90 return open(filename).read() |
85 |
91 |
|
92 |
86 def GetCode(name): |
93 def GetCode(name): |
87 filename = paths.AbsNeighbourFile(__file__,name) |
94 filename = paths.AbsNeighbourFile(__file__,name) |
88 return open(filename).read() |
95 return open(filename).read() |