author | Edouard TISSERANT <edouard.tisserant@gmail.com> |
Fri, 25 Dec 2009 13:08:20 +0100 | |
changeset 533 | 25437efb7ae4 |
parent 425 | f390e9fdd2cf |
child 642 | cd7ccbbbf471 |
permissions | -rwxr-xr-x |
203 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
# |
|
4 |
#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
|
5 |
# |
|
6 |
#See COPYING file for copyrights details. |
|
7 |
# |
|
8 |
#This library is free software; you can redistribute it and/or |
|
9 |
#modify it under the terms of the GNU General Public |
|
10 |
#License as published by the Free Software Foundation; either |
|
11 |
#version 2.1 of the License, or (at your option) any later version. |
|
12 |
# |
|
13 |
#This library is distributed in the hope that it will be useful, |
|
14 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 |
#General Public License for more details. |
|
17 |
# |
|
18 |
#You should have received a copy of the GNU General Public |
|
19 |
#License along with this library; if not, write to the Free Software |
|
20 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
21 |
||
22 |
# Package initialisation |
|
23 |
#import targets |
|
24 |
||
25 |
""" |
|
26 |
Beremiz Targets |
|
27 |
||
28 |
- Target are python packages, containing at least one "XSD" file |
|
29 |
- Target class may inherit from a toolchain_(toolchainname) |
|
30 |
- The target folder's name must match to name define in the XSD for TargetType |
|
31 |
""" |
|
32 |
||
33 |
from os import listdir, path |
|
34 |
||
35 |
_base_path = path.split(__file__)[0] |
|
36 |
||
37 |
targets = [name for name in listdir(_base_path) if path.isdir(path.join(_base_path, name)) and name.upper() != "CVS" and not name.startswith("__")] |
|
38 |
toolchains = [name for name in listdir(_base_path) if not path.isdir(path.join(_base_path, name)) and name.upper() != "CVS" and name.endswith(".py") and not name.startswith("__") and not name.endswith(".pyc")] |
|
39 |
||
40 |
DictXSD_toolchain = {} |
|
41 |
DictXSD_target = {} |
|
42 |
||
43 |
targetchoices = "" |
|
44 |
||
45 |
# Get all xsd toolchains |
|
46 |
for toolchain in toolchains : |
|
47 |
toolchainname = path.splitext(toolchain)[0] |
|
48 |
xsdfilename = path.join(_base_path, "XSD_%s"%(toolchainname)) |
|
49 |
if path.isfile(xsdfilename): |
|
50 |
xsd_toolchain_string = "" |
|
51 |
for line in open(xsdfilename).readlines(): |
|
52 |
xsd_toolchain_string += line |
|
53 |
DictXSD_toolchain[toolchainname] = xsd_toolchain_string |
|
54 |
||
55 |
# Get all xsd targets |
|
56 |
for targetname in targets: |
|
57 |
xsdfilename = path.join(_base_path, targetname, "XSD") |
|
58 |
if path.isfile(xsdfilename): |
|
59 |
xsd_target_string = "" |
|
60 |
for line in open(xsdfilename).readlines(): |
|
61 |
xsd_target_string += line |
|
62 |
DictXSD_target[targetname] = xsd_target_string%DictXSD_toolchain |
|
63 |
||
64 |
for target in DictXSD_target.keys(): |
|
65 |
targetchoices += DictXSD_target[target] |
|
66 |
||
209
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
205
diff
changeset
|
67 |
def targetcode(target_name, code_name=None): |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
205
diff
changeset
|
68 |
if code_name is None: |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
205
diff
changeset
|
69 |
code_name="plc_%s_main.c"%target_name |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
205
diff
changeset
|
70 |
filename = path.join(path.split(__file__)[0], target_name, code_name) |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
205
diff
changeset
|
71 |
return open(filename).read() |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
205
diff
changeset
|
72 |
|
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
205
diff
changeset
|
73 |
def code(name): |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
205
diff
changeset
|
74 |
filename = path.join(path.split(__file__)[0],name + ".c") |
08dc3d064cb5
Moved template C code to targets dir. Cleaned up some forgotten print.
etisserant
parents:
205
diff
changeset
|
75 |
return open(filename).read() |
205
ee8d1f4528ef
move specific target runtimes to their targets directory
greg
parents:
203
diff
changeset
|
76 |
|
425 | 77 |
from toolchain_gcc import toolchain_gcc |
78 |
from toolchain_makefile import toolchain_makefile |