--- a/codesys-ide/scripts/buildtest.py +++ b/codesys-ide/scripts/buildtest.py @@ -3,6 +3,10 @@ # disable prompts, as those are enabled in UI mode by default system.prompt_handling = PromptHandling.None + +# compile category GUID +CompileCategory = Guid("{97F48D64-A2A3-4856-B640-75C046E37EA9}") + def createtest(filename): destination = filename + ".app" @@ -16,13 +20,14 @@ prg_runtest = proj.find('PRG_RUNTEST') if len(prg_runtest) == 0: proj.close() + print("warning: no POU PRG_RUNTEST found. Will not create a test application.") return None # delete existing testdev device existing = proj.find('testdev') if len(existing) > 0: existing[0].remove() - + # add device proj.add('testdev', devId) apps = proj.find('Application', True) @@ -33,11 +38,26 @@ # add task to call PRG_RUNTEST task = tc.create_task('Task') task.pous.add('PRG_RUNTEST') - + helper.install_missing_libraries(proj, librarymanager) # proj.save() print("create bootapp '%s'" % destination) - proj.active_application.create_boot_application(destination) + try: + proj.active_application.create_boot_application(destination) + except: + print("Error: Creation of bootapplication failed") + # Get message objects which contain all the data + severities = { + Severity.FatalError : "Fatal error", Severity.Error : "Error", + Severity.Warning : "Warning", Severity.Information : "Information", + Severity.Text : "Text" + } + msgs = system.get_message_objects(CompileCategory, Severity.FatalError|Severity.Error) + for msg in msgs: + sev = severities[msg.severity] + print("{} {}{}: {}".format(sev, msg.prefix, msg.number, msg.text)) + return None + print("done." % destination) proj.close() return destination @@ -48,7 +68,7 @@ def doit(self, filename): artifacts = list() helper.install_requirements(filename, librarymanager) - + if filename.endswith(".library"): print("\n\n*** Create test application for: %s" % filename) proj = projects.open(filename)