Merge pull request #951 from GustavWi/iar_mbed

IAR folder structure in project when exporting.
pull/952/head
Martin Kojtal 2015-03-06 08:11:29 +01:00
commit f8bd7a37d2
45 changed files with 115 additions and 221 deletions

View File

@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
""" """
from exporters import Exporter from exporters import Exporter
import re
class IAREmbeddedWorkbench(Exporter): class IAREmbeddedWorkbench(Exporter):
NAME = 'IAR' NAME = 'IAR'
@ -69,14 +69,15 @@ class IAREmbeddedWorkbench(Exporter):
] ]
def generate(self): def generate(self):
sources = [] sources = []
sources += self.resources.c_sources sources += self.resources.c_sources
sources += self.resources.cpp_sources sources += self.resources.cpp_sources
sources += self.resources.s_sources sources += self.resources.s_sources
# binaries = ""
# if resources.bin_files is not None: iar_files = IAR_FOLDER("","",[])
# binaries = resources.bin_files for source in sources:
iar_files.insert_file(source)
ctx = { ctx = {
'name': self.program_name, 'name': self.program_name,
'include_paths': self.resources.inc_dirs, 'include_paths': self.resources.inc_dirs,
@ -84,9 +85,74 @@ class IAREmbeddedWorkbench(Exporter):
'object_files': self.resources.objects, 'object_files': self.resources.objects,
'libraries': self.resources.libraries, 'libraries': self.resources.libraries,
'symbols': self.get_symbols(), 'symbols': self.get_symbols(),
'source_files': sources, 'source_files': iar_files.__str__(),
'binary_files': self.resources.bin_files, 'binary_files': self.resources.bin_files,
} }
self.gen_file('iar_%s.ewp.tmpl' % self.target.lower(), ctx, '%s.ewp' % self.program_name) self.gen_file('iar_%s.ewp.tmpl' % self.target.lower(), ctx, '%s.ewp' % self.program_name)
self.gen_file('iar.eww.tmpl', ctx, '%s.eww' % self.program_name) self.gen_file('iar.eww.tmpl', ctx, '%s.eww' % self.program_name)
self.gen_file('iar_%s.ewd.tmpl' % self.target.lower(), ctx, '%s.ewd' % self.program_name) self.gen_file('iar_%s.ewd.tmpl' % self.target.lower(), ctx, '%s.ewd' % self.program_name)
class IAR_FOLDER:
#input:
#folder_level : folder path to current folder
#folder_name : name of current folder
#source_files : list of source_files (all must be in same directory)
def __init__(self, folder_level, folder_name, source_files):
self.folder_level = folder_level
self.folder_name = folder_name
self.source_files = source_files
self.sub_folders = {};
def __str__(self):
group_start = ""
group_end = ""
if self.folder_name != "":
group_start = "<group>\n<name>%s</name>\n" %(self.folder_name)
group_end = "</group>\n"
str_content = group_start
#Add files in current folder
if self.source_files:
for src in self.source_files:
str_content += "<file>\n<name>$PROJ_DIR$\\%s</name>\n</file>\n" % src
##Add sub folders
if self.sub_folders:
for folder_name in self.sub_folders.iterkeys():
str_content += self.sub_folders[folder_name].__str__()
str_content += group_end
return str_content
def insert_file(self, source_input):
if self.source_files:
dir_sources = IAR_FOLDER.get_directory(self.source_files[0]) ##All source_files in a IAR_FOLDER must be in same directory.
if not self.folder_level == dir_sources: ## Check if sources are already at their deepest level.
_reg_exp = r"^" + re.escape(self.folder_level) + r"[/\\]?([^/\\]+)"
folder_name = re.match( _reg_exp, dir_sources).group(1)
self.sub_folders[folder_name] = IAR_FOLDER(self.folder_level + "\\" + folder_name, folder_name, self.source_files)
self.source_files = []
dir_input = IAR_FOLDER.get_directory(source_input)
if dir_input == self.folder_level:
self.source_files.append(source_input)
else:
_reg_exp = r"^" + re.escape(self.folder_level) + r"[/\\]?([^/\\]+)"
folder_name = re.match( _reg_exp, dir_input).group(1)
if self.sub_folders.has_key(folder_name):
self.sub_folders[folder_name].insert_file(source_input)
else:
if self.folder_level == "": #Top level exception
self.sub_folders[folder_name] = IAR_FOLDER(folder_name, folder_name, [source_input])
else:
self.sub_folders[folder_name] = IAR_FOLDER(self.folder_level + "\\" + folder_name, folder_name, [source_input])
@staticmethod
def get_directory(file_path):
dir_Match = re.match( r'(.*)[/\\][^/\\]+', file_path)
if dir_Match is not None:
return dir_Match.group(1)
else:
return ""

View File

@ -950,11 +950,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -1823,11 +1823,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -950,11 +950,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -950,11 +950,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -948,11 +948,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -948,11 +948,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -948,11 +948,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -948,11 +948,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -948,11 +948,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -948,11 +948,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -948,11 +948,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -948,11 +948,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -948,11 +948,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -948,11 +948,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -953,11 +953,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -948,11 +948,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -1823,11 +1823,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -948,11 +948,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -948,11 +948,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -948,11 +948,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -948,11 +948,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -948,11 +948,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -1893,11 +1893,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -1893,11 +1893,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -1893,11 +1893,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -950,11 +950,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -950,11 +950,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -950,11 +950,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -1893,11 +1893,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -1893,11 +1893,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -1893,11 +1893,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -1893,11 +1893,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -948,11 +948,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -1893,11 +1893,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -1893,11 +1893,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -1893,11 +1893,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -1893,11 +1893,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -1893,11 +1893,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -1893,11 +1893,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -1893,11 +1893,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -950,11 +950,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -948,11 +948,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>

View File

@ -1823,11 +1823,7 @@
<data/> <data/>
</settings> </settings>
</configuration> </configuration>
{% for files in source_files %} {{source_files}}
<file>
<name>$PROJ_DIR$\{{files}}</name>
</file>
{% endfor %}
</project> </project>