36 def _GetLocalTargetClassFactory(name): |
36 def _GetLocalTargetClassFactory(name): |
37 return lambda:getattr(__import__(name,globals(),locals()), name+"_target") |
37 return lambda:getattr(__import__(name,globals(),locals()), name+"_target") |
38 |
38 |
39 targets = dict([(name, {"xsd":path.join(_base_path, name, "XSD"), |
39 targets = dict([(name, {"xsd":path.join(_base_path, name, "XSD"), |
40 "class":_GetLocalTargetClassFactory(name), |
40 "class":_GetLocalTargetClassFactory(name), |
41 "code": path.join(path.split(__file__)[0],name,"plc_%s_main.c"%name)}) |
41 "code": { fname: path.join(_base_path, name, fname) |
|
42 for fname in listdir(path.join(_base_path, name)) |
|
43 if fname.startswith("plc_%s_main"%name) and |
|
44 fname.endswith(".c")}}) |
42 for name in listdir(_base_path) |
45 for name in listdir(_base_path) |
43 if path.isdir(path.join(_base_path, name)) |
46 if path.isdir(path.join(_base_path, name)) |
44 and not name.startswith("__")]) |
47 and not name.startswith("__")]) |
45 |
48 |
46 toolchains = {"gcc": path.join(_base_path, "XSD_toolchain_gcc"), |
49 toolchains = {"gcc": path.join(_base_path, "XSD_toolchain_gcc"), |
65 targetchoices += xsd_string%DictXSD_toolchain |
68 targetchoices += xsd_string%DictXSD_toolchain |
66 |
69 |
67 return targetchoices |
70 return targetchoices |
68 |
71 |
69 def GetTargetCode(targetname): |
72 def GetTargetCode(targetname): |
70 return open(targets[targetname]["code"]).read() |
73 codedesc = targets[targetname]["code"] |
|
74 code = "\n".join([open(fpath).read() for fname, fpath in sorted(codedesc.items())]) |
|
75 return code |
71 |
76 |
72 def GetHeader(): |
77 def GetHeader(): |
73 filename = path.join(path.split(__file__)[0],"beremiz.h") |
78 filename = path.join(path.split(__file__)[0],"beremiz.h") |
74 return open(filename).read() |
79 return open(filename).read() |
75 |
80 |