--- a/plugger.py Mon Sep 24 17:05:07 2007 +0200
+++ b/plugger.py Mon Sep 24 17:06:36 2007 +0200
@@ -155,14 +155,14 @@
@return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
logger.write_warning(".".join(map(lambda x:str(x), self.GetCurrentLocation())) + " -> Nothing yo do\n")
def _Generate_C(self, buildpath, locations, logger):
# Generate plugins [(Cfiles, CFLAGS)], LDFLAGS
- PlugCFilesAndCFLAGS, PlugLDFLAGS = self.PlugGenerate_C(buildpath, locations, logger)
+ PlugCFilesAndCFLAGS, PlugLDFLAGS, DoCalls = self.PlugGenerate_C(buildpath, locations, logger) # if some files heve been generated put them in the list with their location
- LocationCFilesAndCFLAGS = [(self.GetCurrentLocation(), PlugCFilesAndCFLAGS)]
+ LocationCFilesAndCFLAGS = [(self.GetCurrentLocation(), PlugCFilesAndCFLAGS, DoCalls)] LocationCFilesAndCFLAGS = []
@@ -354,11 +354,11 @@
self.PluggedChilds[PlugInstance.PlugType].remove(PlugInstance)
# Forget it... (View have to refresh)
- def PlugRemoveChild(self, PlugName):
- PlugInstance = self.GetChildByName(PlugName)
+ #PlugInstance = self.GetChildByName(PlugName) # Ask to his parent to remove it
- PlugInstance.PlugParent._doRemoveChild(PlugInstance)
+ self.PlugParent._doRemoveChild(self) def PlugAddChild(self, PlugName, PlugType, logger):
@@ -587,12 +587,15 @@
def GetProjectPath(self):
+ def GetProjectName(self): + return os.path.split(self.ProjectPath)[1] for child in self.IterChilds():
childs.append(child.GetPlugInfos())
- return {"name" : "PLC (%s)"%os.path.split(self.ProjectPath)[1], "type" : None, "values" : childs}
+ return {"name" : "PLC (%s)"%self.GetProjectName(), "type" : None, "values" : childs} def NewProject(self, ProjectPath):
@@ -681,7 +684,7 @@
ex: [((0,0,4,5),'I','STRING','__IX_0_0_4_5'),...]
@return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
- return [(C_file_name, self.CFLAGS) for C_file_name in self.PLCGeneratedCFiles ] , ""
+ return [(C_file_name, self.CFLAGS) for C_file_name in self.PLCGeneratedCFiles ] , "", False return os.path.join(self.ProjectPath, "build")
@@ -795,21 +798,15 @@
#logger.write("LDFLAGS :\n"+pp.pformat(LDFLAGS)+"\n")
- locstrs = map(lambda x:"_".join(map(str,x)), [loc for loc in zip(*LocationCFilesAndCFLAGS)[0] if loc])
+ locstrs = map(lambda x:"_".join(map(str,x)), [loc for loc,Cfiles,DoCalls in LocationCFilesAndCFLAGS if loc and DoCalls]) plc_main = runtime.code("plc_common_main") % {
- "calls_prototypes":"".join(["""
-void __publish%(s)s();"""%{'s':locstr} for locstr in locstrs]),
- "retrive_calls":"".join(["""
- __retrive%(s)s();"""%{'s':locstr} for locstr in locstrs]),
- "publish_calls":"".join(["""
- __publish%(s)s();"""%{'s':locstr} for locstr in locstrs]),
- "init_calls":"".join(["""
- __init%(s)s();"""%{'s':locstr} for locstr in locstrs]),
- "cleanup_calls":"".join(["""
- __cleanup%(s)s();"""%{'s':locstr} for locstr in locstrs])}
+ "calls_prototypes":"".join( + ["void __init_%(s)s();\nvoid __cleanup_%(s)s();\nvoid __retrive_%(s)s();\nvoid __publish_%(s)s();"% + {'s':locstr} for locstr in locstrs]), + "retrive_calls":"".join([" __retrive_%(s)s();"%{'s':locstr} for locstr in locstrs]), + "publish_calls":"".join([" __publish_%(s)s();"%{'s':locstr} for locstr in locstrs]), + "init_calls":"".join([" __init_%(s)s();"%{'s':locstr} for locstr in locstrs]), + "cleanup_calls":"".join([" __cleanup_%(s)s();"%{'s':locstr} for locstr in locstrs])} target_name = self.BeremizRoot.TargetType.content["name"]
plc_main += runtime.code("plc_%s_main"%target_name)
@@ -822,7 +819,9 @@
# Compile the resulting code into object files.
compiler = self.BeremizRoot.getCompiler()
- for Location, CFilesAndCFLAGS in LocationCFilesAndCFLAGS:
+ for Location, CFilesAndCFLAGS, DoCalls in LocationCFilesAndCFLAGS: logger.write("Plugin : " + self.GetChildByIECLocation(Location).GetCurrentName() + " " + str(Location)+"\n")
@@ -830,13 +829,28 @@
for CFile, CFLAGS in CFilesAndCFLAGS:
bn = os.path.basename(CFile)
- logger.write(" [CC] "+bn+" -> "+os.path.splitext(bn)[0]+".o\n")
+ obn = os.path.splitext(bn)[0]+".o" + logger.write(" [CC] "+bn+" -> "+obn+"\n") objectfilename = os.path.splitext(CFile)[0]+".o"
status, result, err_result = logger.LogCommand("%s -c %s -o %s %s"%(compiler, CFile, objectfilename, CFLAGS))
logger.write_error("Build failed\n")
+ objs.append(objectfilename) + # Link all the object files into one executable + logger.write("Linking :\n") + exe = self.GetProjectName() + if target_name == "Win32": + exe_path = os.path.join(buildpath, exe) + logger.write(" [CC] " + ' '.join(obns)+" -> " + exe + "\n") + status, result, err_result = logger.LogCommand("%s %s -o %s %s"%(compiler, " ".join(objs), exe_path, ' '.join(LDFLAGS))) + logger.write_error("Build failed\n")