targets/__init__.py
changeset 1456 e723c1dd6faa
parent 1430 754fa90c8b27
child 1457 ff7cfce737ca
equal deleted inserted replaced
1453:f31353cac197 1456:e723c1dd6faa
    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.c"%name)}})
    42                 for name in listdir(_base_path) 
    44                 for name in listdir(_base_path) 
    43                     if path.isdir(path.join(_base_path, name)) 
    45                     if path.isdir(path.join(_base_path, name)) 
    44                        and not name.startswith("__")])
    46                        and not name.startswith("__")])
    45 
    47 
    46 toolchains = {"gcc":  path.join(_base_path, "XSD_toolchain_gcc"),
    48 toolchains = {"gcc":  path.join(_base_path, "XSD_toolchain_gcc"),
    65         targetchoices +=  xsd_string%DictXSD_toolchain
    67         targetchoices +=  xsd_string%DictXSD_toolchain
    66 
    68 
    67     return targetchoices
    69     return targetchoices
    68 
    70 
    69 def GetTargetCode(targetname):
    71 def GetTargetCode(targetname):
    70     return open(targets[targetname]["code"]).read()
    72     codedesc = targets[targetname]["code"]
       
    73     code = "\n".join([open(fpath).read() for fname, fpath in sorted(codedesc.items())])
       
    74     return code
    71 
    75 
    72 def GetHeader():
    76 def GetHeader():
    73     filename = path.join(path.split(__file__)[0],"beremiz.h")
    77     filename = path.join(path.split(__file__)[0],"beremiz.h")
    74     return open(filename).read()
    78     return open(filename).read()
    75 
    79