--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/targets/Makefile/XSD Thu Oct 22 11:28:11 2009 +0200
@@ -0,0 +1,6 @@
+
+ <xsd:element name="Makefile">
+ <xsd:complexType>
+ %(toolchain_makefile)s
+ </xsd:complexType>
+ </xsd:element>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/targets/Makefile/__init__.py Thu Oct 22 11:28:11 2009 +0200
@@ -0,0 +1,7 @@
+from .. import toolchain_makefile
+
+class Makefile_target(toolchain_makefile):
+ extension = ".ld"
+ DebugEnabled = False
+ def getBuilderLDFLAGS(self):
+ return toolchain_makefile.getBuilderLDFLAGS(self)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/targets/Makefile/plc_Makefile_main.c Thu Oct 22 11:28:11 2009 +0200
@@ -0,0 +1,93 @@
+/**
+ * Yagarto specific code
+ **/
+
+//#include <stdio.h>
+
+/* provided by POUS.C */
+extern int common_ticktime__;
+
+void Target_GetTime(IEC_TIME*);
+
+long AtomicCompareExchange(long* atomicvar,long compared, long exchange)
+{
+ return 0;
+}
+
+void PLC_GetTime(IEC_TIME *CURRENT_TIME)
+{
+ /* Call target GetTime function */
+ Target_GetTime(CURRENT_TIME);
+}
+
+void PLC_SetTimer(long long next, long long period)
+{
+}
+
+int startPLC(int argc,char **argv)
+{
+ if(__init(argc,argv) == 0)
+ return 0;
+ else
+ return 1;
+}
+
+int TryEnterDebugSection(void)
+{
+ return 0;
+}
+
+void LeaveDebugSection(void)
+{
+}
+
+int stopPLC(void)
+{
+ __cleanup();
+ return 0;
+}
+
+extern unsigned long __tick;
+/* from plc_debugger.c */
+int WaitDebugData(void)
+{
+ return 0;
+}
+
+/* Called by PLC thread when debug_publish finished
+ * This is supposed to unlock debugger thread in WaitDebugData*/
+void InitiateDebugTransfer(void)
+{
+}
+
+void suspendDebug(void)
+{
+}
+
+void resumeDebug(void)
+{
+}
+
+/* from plc_python.c */
+int WaitPythonCommands(void)
+{
+ return 0;
+}
+
+/* Called by PLC thread on each new python command*/
+void UnBlockPythonCommands(void)
+{
+}
+
+int TryLockPython(void)
+{
+ return 0;
+}
+
+void UnLockPython(void)
+{
+}
+
+void LockPython(void)
+{
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/targets/XSD_toolchain_makefile Thu Oct 22 11:28:11 2009 +0200
@@ -0,0 +1,6 @@
+
+ <xsd:attribute name="BuildPath" type="xsd:string" use="optional" default=""/>
+ <xsd:attribute name="Command" type="xsd:string" use="optional" default="make -C"/>
+ <xsd:attribute name="Arguments" type="xsd:string" use="optional" default="BEREMIZSRC=%(src)s BEREMIZCFLAGS=%(cflags)s USE_BEREMIZ=1 --quiet"/>
+ <xsd:attribute name="Rule" type="xsd:string" use="optional" default="all"/>
+
--- a/targets/__init__.py Thu Oct 22 11:27:30 2009 +0200
+++ b/targets/__init__.py Thu Oct 22 11:28:11 2009 +0200
@@ -74,4 +74,5 @@
filename = path.join(path.split(__file__)[0],name + ".c")
return open(filename).read()
-from toolchain_gcc import toolchain_gcc
\ No newline at end of file
+from toolchain_gcc import toolchain_gcc
+from toolchain_makefile import toolchain_makefile
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/targets/toolchain_makefile.py Thu Oct 22 11:28:11 2009 +0200
@@ -0,0 +1,42 @@
+import os, re, operator
+from wxPopen import ProcessLogger
+import hashlib, shutil
+from toolchain_gcc import toolchain_gcc
+
+includes_re = re.compile('\s*#include\s*["<]([^">]*)[">].*')
+
+class toolchain_makefile(toolchain_gcc):
+ """
+ This abstract class contains GCC specific code.
+ It cannot be used as this and should be inherited in a target specific
+ class such as target_linux or target_win32
+ """
+
+ def build(self):
+ srcfiles= []
+ cflags = []
+ for Location, CFilesAndCFLAGS, DoCalls in self.PluginsRootInstance.LocationCFilesAndCFLAGS:
+ # Get CFiles list to give it to makefile
+ for CFile, CFLAGS in CFilesAndCFLAGS:
+ CFileName = os.path.basename(CFile)
+ srcfiles.append(CFileName)
+ if CFLAGS not in cflags:
+ cflags.append(CFLAGS)
+
+ beremizcommand = {"src": ' '.join(srcfiles),
+ "cflags": ' '.join(cflags)
+ }
+
+ target = self.getTarget().getcontent()["value"]
+ command = target.getCommand().split(' ') +\
+ [target.getBuildPath()] +\
+ [arg % beremizcommand for arg in target.getArguments().split(' ')] +\
+ target.getRule().split(' ')
+
+ # Call Makefile to build PLC code and link it with target specific code
+ status, result, err_result = ProcessLogger(self.PluginsRootInstance.logger,
+ command).spin()
+ if status :
+ self.PluginsRootInstance.logger.write_error(_("C compilation of %s failed.\n"))
+ return False
+ return True