plugger.py
changeset 75 9ad18a387a96
parent 74 8a726a62fbfc
child 77 7de69369373e
equal deleted inserted replaced
74:8a726a62fbfc 75:9ad18a387a96
   511 ###################################   ROOT    ######################################
   511 ###################################   ROOT    ######################################
   512 ####################################################################################
   512 ####################################################################################
   513 ####################################################################################
   513 ####################################################################################
   514 ####################################################################################
   514 ####################################################################################
   515 
   515 
   516 iec2c_path = os.path.join(base_folder, "matiec", "iec2c")
   516 if wx.Platform != '__WXMSW__':
       
   517     exe_ext=".exe"
       
   518 else:
       
   519     exe_ext=""
       
   520 
       
   521 iec2c_path = os.path.join(base_folder, "matiec", "iec2c"+exe_ext)
   517 ieclib_path = os.path.join(base_folder, "matiec", "lib")
   522 ieclib_path = os.path.join(base_folder, "matiec", "lib")
   518 
   523 
   519 # import for project creation timestamping
   524 # import for project creation timestamping
   520 from time import localtime
   525 from time import localtime
   521 from datetime import datetime
   526 from datetime import datetime
   578                 </xsd:element>
   583                 </xsd:element>
   579               </xsd:choice>
   584               </xsd:choice>
   580             </xsd:complexType>
   585             </xsd:complexType>
   581           </xsd:element>
   586           </xsd:element>
   582           <xsd:attribute name="Compiler" type="xsd:string" use="required" default="gcc"/>
   587           <xsd:attribute name="Compiler" type="xsd:string" use="required" default="gcc"/>
       
   588           <xsd:attribute name="CFLAGS" type="xsd:string" use="required" default=""/>
       
   589           <xsd:attribute name="Linker" type="xsd:string" use="required" default="ld"/>
       
   590           <xsd:attribute name="LDFLAGS" type="xsd:string" use="required" default=""/>
   583         </xsd:complexType>
   591         </xsd:complexType>
   584       </xsd:element>
   592       </xsd:element>
   585     </xsd:schema>
   593     </xsd:schema>
   586     """
   594     """
   587 
   595 
   871         # First element is necessarely root
   879         # First element is necessarely root
   872         LocationCFilesAndCFLAGS[0][1].insert(0,(main_path, self.CFLAGS))
   880         LocationCFilesAndCFLAGS[0][1].insert(0,(main_path, self.CFLAGS))
   873         
   881         
   874         # Compile the resulting code into object files.
   882         # Compile the resulting code into object files.
   875         compiler = self.BeremizRoot.getCompiler()
   883         compiler = self.BeremizRoot.getCompiler()
       
   884         _CFLAGS = self.BeremizRoot.getCFLAGS()
       
   885         linker = self.BeremizRoot.getLinker()
       
   886         _LDFLAGS = self.BeremizRoot.getLDFLAGS()
   876         obns = []
   887         obns = []
   877         objs = []
   888         objs = []
   878         for Location, CFilesAndCFLAGS, DoCalls in LocationCFilesAndCFLAGS:
   889         for Location, CFilesAndCFLAGS, DoCalls in LocationCFilesAndCFLAGS:
   879             if Location:
   890             if Location:
   880                 logger.write("Plugin : " + self.GetChildByIECLocation(Location).GetCurrentName() + " " + str(Location)+"\n")
   891                 logger.write("Plugin : " + self.GetChildByIECLocation(Location).GetCurrentName() + " " + str(Location)+"\n")
   885                 bn = os.path.basename(CFile)
   896                 bn = os.path.basename(CFile)
   886                 obn = os.path.splitext(bn)[0]+".o"
   897                 obn = os.path.splitext(bn)[0]+".o"
   887                 obns.append(obn)
   898                 obns.append(obn)
   888                 logger.write("   [CC]  "+bn+" -> "+obn+"\n")
   899                 logger.write("   [CC]  "+bn+" -> "+obn+"\n")
   889                 objectfilename = os.path.splitext(CFile)[0]+".o"
   900                 objectfilename = os.path.splitext(CFile)[0]+".o"
   890                 status, result, err_result = logger.LogCommand("%s -c %s -o %s %s"%(compiler, CFile, objectfilename, CFLAGS))
   901                 status, result, err_result = logger.LogCommand("%s -c %s -o %s %s %s"%(compiler, CFile, objectfilename, _CFLAGS, CFLAGS))
   891                 if status != 0:
   902                 if status != 0:
   892                     logger.write_error("Build failed\n")
   903                     logger.write_error("Build failed\n")
   893                     return False
   904                     return False
   894                 objs.append(objectfilename)
   905                 objs.append(objectfilename)
   895         # Link all the object files into one executable
   906         # Link all the object files into one executable
   897         exe = self.GetProjectName()
   908         exe = self.GetProjectName()
   898         if target_name == "Win32":
   909         if target_name == "Win32":
   899             exe += ".exe"
   910             exe += ".exe"
   900         exe_path = os.path.join(buildpath, exe)
   911         exe_path = os.path.join(buildpath, exe)
   901         logger.write("   [CC]  " + ' '.join(obns)+" -> " + exe + "\n")
   912         logger.write("   [CC]  " + ' '.join(obns)+" -> " + exe + "\n")
   902         status, result, err_result = logger.LogCommand("%s %s -o %s %s"%(compiler, " ".join(objs), exe_path, ' '.join(LDFLAGS)))
   913         status, result, err_result = logger.LogCommand("%s %s -o %s %s"%(linker, " ".join(objs), exe_path, ' '.join(LDFLAGS+[_LDFLAGS])))
   903         if status != 0:
   914         if status != 0:
   904             logger.write_error("Build failed\n")
   915             logger.write_error("Build failed\n")
   905             return False
   916             return False
   906         
   917         
   907         
   918