New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
eclipse_gcc_arm export improvement #10295
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,11 +18,11 @@ | |
import os | ||
import json | ||
from collections import namedtuple | ||
from tools.targets import TARGET_MAP | ||
from os.path import join, exists | ||
from os import makedirs, remove | ||
import shutil | ||
from copy import deepcopy | ||
from tools.targets import TARGET_MAP | ||
|
||
from tools.export.makefile import Makefile, GccArm, Armc5, IAR | ||
|
||
|
@@ -38,19 +38,23 @@ class Eclipse(Makefile): | |
"""Generic Eclipse project. Intended to be subclassed by classes that | ||
specify a type of Makefile. | ||
""" | ||
def get_target_config(self, ctx, configuration): | ||
def get_target_config(self, configuration): | ||
"""Retrieve info from cdt_definitions.json""" | ||
tgt = deepcopy(TARGET_MAP[self.target]) | ||
defaults = deepcopy(_CONFIGS_OPTIONS['default']) | ||
defaults = _CONFIGS_OPTIONS['default'] | ||
eclipse_config = deepcopy(defaults['generic']) | ||
if configuration in defaults: | ||
eclipse_config.update(defaults[configuration]) | ||
|
||
# Get target-specific options. Use resolution order and extra labels | ||
# to find alias for target. This allows to define options within inheritance path | ||
target_specific = _CONFIGS_OPTIONS['targets'] | ||
if tgt.name in target_specific: | ||
eclipse_config.update(target_specific[tgt.name]['generic']) | ||
if configuration in target_specific[tgt.name]: | ||
eclipse_config.update(target_specific[tgt.name][configuration]) | ||
aliases = self.toolchain.target.resolution_order_names \ | ||
+ self.toolchain.target.extra_labels | ||
target_alias = next((t for t in aliases if t in target_specific), None) | ||
if target_alias: | ||
eclipse_config.update(target_specific[target_alias]['generic']) | ||
if configuration in target_specific[target_alias]: | ||
eclipse_config.update(target_specific[target_alias][configuration]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would write this differently, as I generally avoid using the for target_alias in aliases:
if target_alias in target_specific:
eclipse_config.update(target_specific[target_alias]['generic'])
if configuration in target_specific[target_alias]:
eclipse_config.update(target_specific[target_alias][configuration])
return eclipse_config There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Applied your fix, thanks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You dropped (or mis-indented) the return, which makes the code apply all possible target specific settings from most specific to least specific, as opposed to what it used to do which is apply the first match or most specific match. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missed that. I added a break instead of return, because we still have to return defaults, even if specific settings does not exist. |
||
|
||
return eclipse_config | ||
|
||
|
@@ -63,7 +67,7 @@ def generate(self): | |
starting_dot = re.compile(r'(^[.]/|^[.]$)') | ||
ctx = { | ||
'name': self.project_name, | ||
'elf_location': join('BUILD',self.project_name)+'.elf', | ||
'elf_location': join('BUILD', self.project_name)+'.elf', | ||
'c_symbols': self.toolchain.get_symbols(), | ||
'asm_symbols': self.toolchain.get_symbols(True), | ||
'target': self.target, | ||
|
@@ -74,11 +78,11 @@ def generate(self): | |
launch_cfgs = {} | ||
for launch_name in supported_launches: | ||
launch = deepcopy(ctx) | ||
launch.update({'device': self.get_target_config(ctx, launch_name)}) | ||
launch.update({'device': self.get_target_config(launch_name)}) | ||
launch_cfgs[launch_name] = launch | ||
|
||
if not exists(join(self.export_dir,'eclipse-extras')): | ||
makedirs(join(self.export_dir,'eclipse-extras')) | ||
if not exists(join(self.export_dir, 'eclipse-extras')): | ||
makedirs(join(self.export_dir, 'eclipse-extras')) | ||
|
||
for launch_name, ctx in launch_cfgs.items(): | ||
# Generate launch configurations for former GNU ARM Eclipse plug-in | ||
|
@@ -95,7 +99,7 @@ def generate(self): | |
conf=launch_name))) | ||
|
||
self.gen_file('cdt/necessary_software.tmpl', ctx, | ||
join('eclipse-extras','necessary_software.p2f')) | ||
join('eclipse-extras', 'necessary_software.p2f')) | ||
|
||
self.gen_file('cdt/.cproject.tmpl', ctx, '.cproject') | ||
self.gen_file('cdt/.project.tmpl', ctx, '.project') | ||
|
@@ -119,7 +123,7 @@ class EclipseArmc5(Eclipse, Armc5): | |
def is_target_supported(cls, target_name): | ||
target = TARGET_MAP[target_name] | ||
if int(target.build_tools_metadata["version"]) > 0: | ||
return "ARMC5" in target.supported_toolchains; | ||
return "ARMC5" in target.supported_toolchains | ||
else: | ||
return True | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this different from
self.toolchain.target.labels
? Is that something that you could use instead?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is different a bit, but it is also ok, so I switched to
self.toolchain.target.labels