798 #logger.write("LDFLAGS :\n"+pp.pformat(LDFLAGS)+"\n") |
798 #logger.write("LDFLAGS :\n"+pp.pformat(LDFLAGS)+"\n") |
799 |
799 |
800 # Generate main |
800 # Generate main |
801 locstrs = map(lambda x:"_".join(map(str,x)), [loc for loc,Cfiles,DoCalls in LocationCFilesAndCFLAGS if loc and DoCalls]) |
801 locstrs = map(lambda x:"_".join(map(str,x)), [loc for loc,Cfiles,DoCalls in LocationCFilesAndCFLAGS if loc and DoCalls]) |
802 plc_main = runtime.code("plc_common_main") % { |
802 plc_main = runtime.code("plc_common_main") % { |
803 "calls_prototypes":"".join( |
803 "calls_prototypes":"\n".join( |
804 ["void __init_%(s)s();\nvoid __cleanup_%(s)s();\nvoid __retrive_%(s)s();\nvoid __publish_%(s)s();"% |
804 ["int __init_%(s)s(int argc,char **argv);\nvoid __cleanup_%(s)s();\nvoid __retrive_%(s)s();\nvoid __publish_%(s)s();"% |
805 {'s':locstr} for locstr in locstrs]), |
805 {'s':locstr} for locstr in locstrs]), |
806 "retrive_calls":"".join([" __retrive_%(s)s();"%{'s':locstr} for locstr in locstrs]), |
806 "retrive_calls":" \n".join(["__retrive_%(s)s();"%{'s':locstr} for locstr in locstrs]), |
807 "publish_calls":"".join([" __publish_%(s)s();"%{'s':locstr} for locstr in locstrs]), |
807 "publish_calls":" \n".join(["__publish_%(s)s();"%{'s':locstr} for locstr in locstrs]), |
808 "init_calls":"".join([" __init_%(s)s();"%{'s':locstr} for locstr in locstrs]), |
808 "init_calls":" \n".join(["init_level++; if(res = __init_%(s)s(argc,argv)) return res;"%{'s':locstr} for locstr in locstrs]), |
809 "cleanup_calls":"".join([" __cleanup_%(s)s();"%{'s':locstr} for locstr in locstrs])} |
809 "cleanup_calls":" \n".join(["if(init_level-- > 0) __cleanup_%(s)s();"%{'s':locstr} for locstr in locstrs])} |
810 target_name = self.BeremizRoot.TargetType.content["name"] |
810 target_name = self.BeremizRoot.TargetType.content["name"] |
811 plc_main += runtime.code("plc_%s_main"%target_name) |
811 plc_main += runtime.code("plc_%s_main"%target_name) |
812 |
812 |
813 main_path = os.path.join(buildpath, "main.c" ) |
813 main_path = os.path.join(buildpath, "main.c" ) |
814 f = open(main_path,'w') |
814 f = open(main_path,'w') |