Warm tip: This article is reproduced from serverfault.com, please click

Compiling CoDeSys project using the command line

发布于 2021-01-27 08:32:54

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?

Questioner
jubnzv
Viewed
0
riQQ 2021-01-28 02:25:33

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