0

Is it possible to run the CoDeSys compiler to build my project without running the IDE, using only the command line interface?

May be there are other options, for example, some scripts, that can launch the IDE, start the build process, collect the output and exit?

I am interested in this in the context of automatic testing of my project on the CI server. I am using git on the local network, and I would like to run the build after new commits automatically, on the CI side. After the build I would like to get the output of the compiler and check if there are no any errors.

Any ideas? Is it possible in CoDeSys?

jubnzv
  • 1,526
  • 2
  • 8
  • 20
  • 1
    Have you tried using [Script Engine](https://help.codesys.com/api-content/2/codesys/3.5.13.0/en/_cds_access_cds_func_in_python_scripts/)? – Guiorgy Jan 27 '21 at 13:19
  • Yes, I tried. Unfortunately, there is no library function to build the project. May be this is possible through UI automation. But I hope someone has a better solution, because, I think, this is a very common task. – jubnzv Jan 27 '21 at 14:18

1 Answers1

3

The Script Engine does support this:

Execute
start /b /wait "C:\Program Files (x86)\CODESYS V3.5 SP16\CODESYS\Common\CODESYS.exe" --profile="CODESYS V3.5 SP16" --runscript="build.py" --noUI

See https://help.codesys.com/webapp/_cds_commandline;product=codesys;version=3.5.16.0#option-runscript-execute-script

build.py

import scriptengine

project = projects.open(r"CodesysProject.project", primary = True)
application = project.active_application
application.generate_code()
messages = system.get_messages("97f48d64-a2a3-4856-b640-75c046e37ea9")
// check messages

See https://help.codesys.com/webapp/ScriptApplication;product=ScriptEngine;version=3.5.16.0

riQQ
  • 9,878
  • 7
  • 49
  • 66