canfestival/canfestival.py
changeset 957 463d4b2b058d
parent 948 89fead207c35
child 960 d72a866cf9b0
equal deleted inserted replaced
956:c838c50f8946 957:463d4b2b058d
   398     XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
   398     XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
   399     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   399     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   400       <xsd:element name="CanFestivalInstance">
   400       <xsd:element name="CanFestivalInstance">
   401         <xsd:complexType>
   401         <xsd:complexType>
   402           <xsd:attribute name="CAN_Driver" type="xsd:string" use="optional" default="%(CAN_Driver)s"/>
   402           <xsd:attribute name="CAN_Driver" type="xsd:string" use="optional" default="%(CAN_Driver)s"/>
   403           <xsd:attribute name="Debug_mode" type="xsd:boolean" use="optional" default="false"/>
       
   404         </xsd:complexType>
   403         </xsd:complexType>
   405       </xsd:element>
   404       </xsd:element>
   406     </xsd:schema>
   405     </xsd:schema>
   407     """ % DEFAULT_SETTINGS
   406     """ % DEFAULT_SETTINGS
   408     
   407     
   417                         DLL_LIST= getattr(local_canfestival_config,"DLL_LIST",None)
   416                         DLL_LIST= getattr(local_canfestival_config,"DLL_LIST",None)
   418                         if DLL_LIST is not None:
   417                         if DLL_LIST is not None:
   419                             child["type"] = DLL_LIST  
   418                             child["type"] = DLL_LIST  
   420         return infos
   419         return infos
   421     
   420     
   422     def GetCanDriver(self):
   421     def CTNGenerate_C(self, buildpath, locations):
   423         can_driver = self.CanFestivalInstance.getCAN_Driver()
   422         can_driver = self.CanFestivalInstance.getCAN_Driver()
   424         if sys.platform == 'win32':
       
   425             if self.CanFestivalInstance.getDebug_mode() and os.path.isfile(os.path.join("%s"%(can_driver + '_DEBUG.dll'))):
       
   426                 can_driver += '_DEBUG.dll'
       
   427             else:
       
   428                 can_driver += '.dll'
       
   429         return can_driver
       
   430     
       
   431     def CTNGenerate_C(self, buildpath, locations):
       
   432         
   423         
   433         format_dict = {"locstr" : "_".join(map(str,self.GetCurrentLocation())),
   424         format_dict = {"locstr" : "_".join(map(str,self.GetCurrentLocation())),
   434                        "candriver" : self.GetCanDriver(),
   425                        "candriver" : can_driver,
   435                        "nodes_includes" : "",
   426                        "nodes_includes" : "",
   436                        "board_decls" : "",
   427                        "board_decls" : "",
   437                        "nodes_init" : "",
   428                        "nodes_init" : "",
   438                        "nodes_open" : "",
   429                        "nodes_open" : "",
   439                        "nodes_stop" : "",
   430                        "nodes_stop" : "",
   520         cf_main = open(filename).read() % format_dict
   511         cf_main = open(filename).read() % format_dict
   521         cf_main_path = os.path.join(buildpath, "CF_%(locstr)s.c"%format_dict)
   512         cf_main_path = os.path.join(buildpath, "CF_%(locstr)s.c"%format_dict)
   522         f = open(cf_main_path,'w')
   513         f = open(cf_main_path,'w')
   523         f.write(cf_main)
   514         f.write(cf_main)
   524         f.close()
   515         f.close()
   525         
   516 
   526         return [(cf_main_path, local_canfestival_config.getCFLAGS(CanFestivalPath))],local_canfestival_config.getLDFLAGS(CanFestivalPath), True
   517         res = [(cf_main_path, local_canfestival_config.getCFLAGS(CanFestivalPath))],local_canfestival_config.getLDFLAGS(CanFestivalPath), True
   527 
   518 
   528 
   519         can_drv_ext = self.GetCTRoot().GetBuilder().extension
       
   520         can_driver_path = os.path.join(CanFestivalPath,"drivers",can_driver,"libcanfestival_"+can_driver+can_drv_ext)
       
   521         if os.path.exists(can_driver_path):
       
   522             res += ((can_driver+can_drv_ext, file(can_driver_path,"rb")),)
       
   523 
       
   524         return res
       
   525