39 |
39 |
40 _base_path = paths.AbsDir(__file__) |
40 _base_path = paths.AbsDir(__file__) |
41 def _GetLocalTargetClassFactory(name): |
41 def _GetLocalTargetClassFactory(name): |
42 return lambda:getattr(__import__(name,globals(),locals()), name+"_target") |
42 return lambda:getattr(__import__(name,globals(),locals()), name+"_target") |
43 |
43 |
44 targets = dict([(name, {"xsd":path.join(_base_path, name, "XSD"), |
44 targets = dict([(name, {"xsd":path.join(_base_path, name, "XSD"), |
45 "class":_GetLocalTargetClassFactory(name), |
45 "class":_GetLocalTargetClassFactory(name), |
46 "code": { fname: path.join(_base_path, name, fname) |
46 "code": { fname: path.join(_base_path, name, fname) |
47 for fname in listdir(path.join(_base_path, name)) |
47 for fname in listdir(path.join(_base_path, name)) |
48 if fname.startswith("plc_%s_main"%name) and |
48 if fname.startswith("plc_%s_main"%name) and |
49 fname.endswith(".c")}}) |
49 fname.endswith(".c")}}) |
50 for name in listdir(_base_path) |
50 for name in listdir(_base_path) |
51 if path.isdir(path.join(_base_path, name)) |
51 if path.isdir(path.join(_base_path, name)) |
52 and not name.startswith("__")]) |
52 and not name.startswith("__")]) |
53 |
53 |
54 toolchains = {"gcc": path.join(_base_path, "XSD_toolchain_gcc"), |
54 toolchains = {"gcc": path.join(_base_path, "XSD_toolchain_gcc"), |
55 "makefile": path.join(_base_path, "XSD_toolchain_makefile")} |
55 "makefile": path.join(_base_path, "XSD_toolchain_makefile")} |
56 |
56 |
65 for toolchainname,xsdfilename in toolchains.iteritems() : |
65 for toolchainname,xsdfilename in toolchains.iteritems() : |
66 if path.isfile(xsdfilename): |
66 if path.isfile(xsdfilename): |
67 DictXSD_toolchain["toolchain_"+toolchainname] = \ |
67 DictXSD_toolchain["toolchain_"+toolchainname] = \ |
68 open(xsdfilename).read() |
68 open(xsdfilename).read() |
69 |
69 |
70 # Get all xsd targets |
70 # Get all xsd targets |
71 for targetname,nfo in targets.iteritems(): |
71 for targetname,nfo in targets.iteritems(): |
72 xsd_string = open(nfo["xsd"]).read() |
72 xsd_string = open(nfo["xsd"]).read() |
73 targetchoices += xsd_string%DictXSD_toolchain |
73 targetchoices += xsd_string%DictXSD_toolchain |
74 |
74 |
75 return targetchoices |
75 return targetchoices |