Clone of official tools
export/cdt/__init__.py@47:21ae3e5a7128, 2021-02-04 (annotated)
- Committer:
- Anders Blomdell
- Date:
- Thu Feb 04 17:17:13 2021 +0100
- Revision:
- 47:21ae3e5a7128
- Parent:
- 43:2a7da56ebd24
Add a few normpath calls
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
The Other Jimmy |
35:da9c89f8be7d | 1 | import re |
The Other Jimmy |
35:da9c89f8be7d | 2 | |
theotherjimmy |
40:7d3fa6b99b2b | 3 | from os.path import join, exists |
theotherjimmy |
43:2a7da56ebd24 | 4 | from os import makedirs, remove |
theotherjimmy |
43:2a7da56ebd24 | 5 | import shutil |
The Other Jimmy |
31:8ea194f6145b | 6 | |
The Other Jimmy |
31:8ea194f6145b | 7 | from tools.export.makefile import Makefile, GccArm, Armc5, IAR |
The Other Jimmy |
31:8ea194f6145b | 8 | |
The Other Jimmy |
31:8ea194f6145b | 9 | class Eclipse(Makefile): |
The Other Jimmy |
31:8ea194f6145b | 10 | """Generic Eclipse project. Intended to be subclassed by classes that |
The Other Jimmy |
31:8ea194f6145b | 11 | specify a type of Makefile. |
The Other Jimmy |
31:8ea194f6145b | 12 | """ |
The Other Jimmy |
31:8ea194f6145b | 13 | def generate(self): |
The Other Jimmy |
31:8ea194f6145b | 14 | """Generate Makefile, .cproject & .project Eclipse project file, |
The Other Jimmy |
31:8ea194f6145b | 15 | py_ocd_settings launch file, and software link .p2f file |
The Other Jimmy |
31:8ea194f6145b | 16 | """ |
The Other Jimmy |
31:8ea194f6145b | 17 | super(Eclipse, self).generate() |
The Other Jimmy |
35:da9c89f8be7d | 18 | starting_dot = re.compile(r'(^[.]/|^[.]$)') |
The Other Jimmy |
31:8ea194f6145b | 19 | ctx = { |
The Other Jimmy |
31:8ea194f6145b | 20 | 'name': self.project_name, |
The Other Jimmy |
31:8ea194f6145b | 21 | 'elf_location': join('BUILD',self.project_name)+'.elf', |
The Other Jimmy |
31:8ea194f6145b | 22 | 'c_symbols': self.toolchain.get_symbols(), |
The Other Jimmy |
31:8ea194f6145b | 23 | 'asm_symbols': self.toolchain.get_symbols(True), |
The Other Jimmy |
31:8ea194f6145b | 24 | 'target': self.target, |
The Other Jimmy |
35:da9c89f8be7d | 25 | 'include_paths': [starting_dot.sub('%s/' % self.project_name, inc) for inc in self.resources.inc_dirs], |
The Other Jimmy |
31:8ea194f6145b | 26 | 'load_exe': str(self.LOAD_EXE).lower() |
The Other Jimmy |
31:8ea194f6145b | 27 | } |
The Other Jimmy |
31:8ea194f6145b | 28 | |
The Other Jimmy |
31:8ea194f6145b | 29 | if not exists(join(self.export_dir,'eclipse-extras')): |
The Other Jimmy |
31:8ea194f6145b | 30 | makedirs(join(self.export_dir,'eclipse-extras')) |
The Other Jimmy |
31:8ea194f6145b | 31 | |
The Other Jimmy |
31:8ea194f6145b | 32 | |
The Other Jimmy |
31:8ea194f6145b | 33 | self.gen_file('cdt/pyocd_settings.tmpl', ctx, |
theotherjimmy |
40:7d3fa6b99b2b | 34 | join('eclipse-extras', |
theotherjimmy |
40:7d3fa6b99b2b | 35 | '{target}_pyocd_{project}_settings.launch'.format(target=self.target, |
theotherjimmy |
40:7d3fa6b99b2b | 36 | project=self.project_name))) |
The Other Jimmy |
31:8ea194f6145b | 37 | self.gen_file('cdt/necessary_software.tmpl', ctx, |
The Other Jimmy |
31:8ea194f6145b | 38 | join('eclipse-extras','necessary_software.p2f')) |
The Other Jimmy |
31:8ea194f6145b | 39 | |
The Other Jimmy |
31:8ea194f6145b | 40 | self.gen_file('cdt/.cproject.tmpl', ctx, '.cproject') |
The Other Jimmy |
31:8ea194f6145b | 41 | self.gen_file('cdt/.project.tmpl', ctx, '.project') |
The Other Jimmy |
31:8ea194f6145b | 42 | |
theotherjimmy |
43:2a7da56ebd24 | 43 | @staticmethod |
theotherjimmy |
43:2a7da56ebd24 | 44 | def clean(project_name): |
theotherjimmy |
43:2a7da56ebd24 | 45 | shutil.rmtree("eclipse-extras") |
theotherjimmy |
43:2a7da56ebd24 | 46 | remove(".cproject") |
theotherjimmy |
43:2a7da56ebd24 | 47 | remove(".project") |
theotherjimmy |
43:2a7da56ebd24 | 48 | |
The Other Jimmy |
31:8ea194f6145b | 49 | |
The Other Jimmy |
31:8ea194f6145b | 50 | class EclipseGcc(Eclipse, GccArm): |
The Other Jimmy |
31:8ea194f6145b | 51 | LOAD_EXE = True |
The Other Jimmy |
31:8ea194f6145b | 52 | NAME = "Eclipse-GCC-ARM" |
The Other Jimmy |
31:8ea194f6145b | 53 | |
The Other Jimmy |
31:8ea194f6145b | 54 | class EclipseArmc5(Eclipse, Armc5): |
The Other Jimmy |
31:8ea194f6145b | 55 | LOAD_EXE = False |
The Other Jimmy |
31:8ea194f6145b | 56 | NAME = "Eclipse-Armc5" |
The Other Jimmy |
31:8ea194f6145b | 57 | |
The Other Jimmy |
31:8ea194f6145b | 58 | class EclipseIAR(Eclipse, IAR): |
The Other Jimmy |
31:8ea194f6145b | 59 | LOAD_EXE = True |
The Other Jimmy |
31:8ea194f6145b | 60 | NAME = "Eclipse-IAR" |
The Other Jimmy |
31:8ea194f6145b | 61 | |
The Other Jimmy |
31:8ea194f6145b | 62 |