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 |
|
|
67 |
from toolchain_gcc import toolchain_gcc |