2017-01-05 13:20:54 +00:00
|
|
|
import re
|
|
|
|
|
2017-07-28 19:49:35 +00:00
|
|
|
from os.path import join, exists
|
2016-08-24 17:54:34 +00:00
|
|
|
from os import makedirs
|
|
|
|
|
|
|
|
from tools.export.makefile import Makefile, GccArm, Armc5, IAR
|
|
|
|
|
|
|
|
class Eclipse(Makefile):
|
|
|
|
"""Generic Eclipse project. Intended to be subclassed by classes that
|
|
|
|
specify a type of Makefile.
|
|
|
|
"""
|
|
|
|
def generate(self):
|
|
|
|
"""Generate Makefile, .cproject & .project Eclipse project file,
|
|
|
|
py_ocd_settings launch file, and software link .p2f file
|
|
|
|
"""
|
|
|
|
super(Eclipse, self).generate()
|
2017-01-05 17:17:46 +00:00
|
|
|
starting_dot = re.compile(r'(^[.]/|^[.]$)')
|
2016-08-24 17:54:34 +00:00
|
|
|
ctx = {
|
|
|
|
'name': self.project_name,
|
2016-11-18 05:53:41 +00:00
|
|
|
'elf_location': join('BUILD',self.project_name)+'.elf',
|
2016-08-24 17:54:34 +00:00
|
|
|
'c_symbols': self.toolchain.get_symbols(),
|
|
|
|
'asm_symbols': self.toolchain.get_symbols(True),
|
|
|
|
'target': self.target,
|
2017-01-05 17:17:46 +00:00
|
|
|
'include_paths': [starting_dot.sub('%s/' % self.project_name, inc) for inc in self.resources.inc_dirs],
|
2016-09-08 15:08:58 +00:00
|
|
|
'load_exe': str(self.LOAD_EXE).lower()
|
2016-08-24 17:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if not exists(join(self.export_dir,'eclipse-extras')):
|
|
|
|
makedirs(join(self.export_dir,'eclipse-extras'))
|
|
|
|
|
|
|
|
|
2016-09-30 15:15:26 +00:00
|
|
|
self.gen_file('cdt/pyocd_settings.tmpl', ctx,
|
2017-07-28 20:19:52 +00:00
|
|
|
join('eclipse-extras',
|
|
|
|
'{target}_pyocd_{project}_settings.launch'.format(target=self.target,
|
|
|
|
project=self.project_name)))
|
2016-08-24 17:54:34 +00:00
|
|
|
self.gen_file('cdt/necessary_software.tmpl', ctx,
|
|
|
|
join('eclipse-extras','necessary_software.p2f'))
|
|
|
|
|
2016-10-17 19:51:28 +00:00
|
|
|
self.gen_file('cdt/.cproject.tmpl', ctx, '.cproject')
|
|
|
|
self.gen_file('cdt/.project.tmpl', ctx, '.project')
|
2016-08-24 17:54:34 +00:00
|
|
|
|
|
|
|
|
2016-09-08 15:08:58 +00:00
|
|
|
class EclipseGcc(Eclipse, GccArm):
|
|
|
|
LOAD_EXE = True
|
2016-10-17 19:35:26 +00:00
|
|
|
NAME = "Eclipse-GCC-ARM"
|
2016-08-24 17:54:34 +00:00
|
|
|
|
2016-09-08 15:08:58 +00:00
|
|
|
class EclipseArmc5(Eclipse, Armc5):
|
|
|
|
LOAD_EXE = False
|
2016-10-17 19:35:26 +00:00
|
|
|
NAME = "Eclipse-Armc5"
|
2016-08-24 17:54:34 +00:00
|
|
|
|
2016-09-08 15:08:58 +00:00
|
|
|
class EclipseIAR(Eclipse, IAR):
|
|
|
|
LOAD_EXE = True
|
2016-10-17 19:35:26 +00:00
|
|
|
NAME = "Eclipse-IAR"
|
2016-08-24 17:54:34 +00:00
|
|
|
|
|
|
|
|