ProjectController.py
changeset 1746 45d6f5fba016
parent 1745 f9d32913bad4
child 1749 d73b64672238
equal deleted inserted replaced
1745:f9d32913bad4 1746:45d6f5fba016
   560                 return True
   560                 return True
   561         return False
   561         return False
   562 
   562 
   563     def GetLibrariesTypes(self):
   563     def GetLibrariesTypes(self):
   564         self.LoadLibraries()
   564         self.LoadLibraries()
   565         return [ lib.GetTypes() for lib in self.Libraries ]
   565         return [lib.GetTypes() for lib in self.Libraries]
   566 
   566 
   567     def GetLibrariesSTCode(self):
   567     def GetLibrariesSTCode(self):
   568         return "\n".join([ lib.GetSTCode() for lib in self.Libraries ])
   568         return "\n".join([lib.GetSTCode() for lib in self.Libraries])
   569 
   569 
   570     def GetLibrariesCCode(self, buildpath):
   570     def GetLibrariesCCode(self, buildpath):
   571         if len(self.Libraries) == 0:
   571         if len(self.Libraries) == 0:
   572             return [], [], ()
   572             return [], [], ()
   573         self.GetIECProgramsAndVariables()
   573         self.GetIECProgramsAndVariables()
   786 
   786 
   787             self.logger.write_error(_("Error : IEC to C compiler returned %d\n") % status)
   787             self.logger.write_error(_("Error : IEC to C compiler returned %d\n") % status)
   788             return False
   788             return False
   789 
   789 
   790         # Now extract C files of stdout
   790         # Now extract C files of stdout
   791         C_files = [ fname for fname in result.splitlines() if fname[-2:] == ".c" or fname[-2:] == ".C" ]
   791         C_files = [fname for fname in result.splitlines() if fname[-2:] == ".c" or fname[-2:] == ".C"]
   792         # remove those that are not to be compiled because included by others
   792         # remove those that are not to be compiled because included by others
   793         C_files.remove("POUS.c")
   793         C_files.remove("POUS.c")
   794         if not C_files:
   794         if not C_files:
   795             self.logger.write_error(_("Error : At least one configuration and one resource must be declared in PLC !\n"))
   795             self.logger.write_error(_("Error : At least one configuration and one resource must be declared in PLC !\n"))
   796             return False
   796             return False
   797         # transform those base names to full names with path
   797         # transform those base names to full names with path
   798         C_files = map(lambda filename: os.path.join(buildpath, filename), C_files)
   798         C_files = map(lambda filename: os.path.join(buildpath, filename), C_files)
   799 
   799 
   800         # prepend beremiz include to configuration header
   800         # prepend beremiz include to configuration header
   801         H_files = [ fname for fname in result.splitlines() if fname[-2:] == ".h" or fname[-2:] == ".H" ]
   801         H_files = [fname for fname in result.splitlines() if fname[-2:] == ".h" or fname[-2:] == ".H"]
   802         H_files.remove("LOCATED_VARIABLES.h")
   802         H_files.remove("LOCATED_VARIABLES.h")
   803         H_files = map(lambda filename: os.path.join(buildpath, filename), H_files)
   803         H_files = map(lambda filename: os.path.join(buildpath, filename), H_files)
   804         for H_file in H_files:
   804         for H_file in H_files:
   805             with file(H_file, 'r') as original: data = original.read()
   805             with file(H_file, 'r') as original: data = original.read()
   806             with file(H_file, 'w') as modified: modified.write('#include "beremiz.h"\n' + data)
   806             with file(H_file, 'w') as modified: modified.write('#include "beremiz.h"\n' + data)
   854         @param locations: ignored
   854         @param locations: ignored
   855         @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
   855         @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
   856         """
   856         """
   857 
   857 
   858         return ([(C_file_name, self.plcCFLAGS)
   858         return ([(C_file_name, self.plcCFLAGS)
   859                 for C_file_name in self.PLCGeneratedCFiles ],
   859                 for C_file_name in self.PLCGeneratedCFiles],
   860                "",  # no ldflags
   860                "",  # no ldflags
   861                False)  # do not expose retreive/publish calls
   861                False)  # do not expose retreive/publish calls
   862 
   862 
   863     def ResetIECProgramsAndVariables(self):
   863     def ResetIECProgramsAndVariables(self):
   864         """
   864         """