Search code examples
plccodesys

Compiling CoDeSys project using the command line


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?


Solution

  • 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