Skip to content
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

Merged
merged 3 commits into from Apr 4, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 18 additions & 14 deletions tools/export/cdt/__init__.py
Expand Up @@ -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

Expand All @@ -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
Copy link
Contributor

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?

Copy link
Contributor Author

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

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])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would write this differently, as I generally avoid using the next function:

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied your fix, thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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')
Expand All @@ -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

Expand Down
36 changes: 2 additions & 34 deletions tools/export/cdt/cdt_definitions.json
Expand Up @@ -41,47 +41,15 @@
},

"targets": {
"CY8CPROTO_062_4343W": {
"PSOC6_01": {
"generic": {
"gdbServerGdbPortNumber": 3334,
"gdbServerOther": "-p 3333
--no-deprecation-warning",
"corePortNumber": 3334
}
},

"CY8CMOD_062_4343W": {
"generic": {
"gdbServerGdbPortNumber": 3334,
"gdbServerOther": "-p 3333
--no-deprecation-warning",
"corePortNumber": 3334
}
},

"CYW943012P6EVB_01": {
"generic": {
"gdbServerGdbPortNumber": 3334,
"gdbServerOther": "-p 3333
--no-deprecation-warning",
"corePortNumber": 3334
}
},

"CY8CKIT_062_WIFI_BT": {
"generic": {
"gdbServerGdbPortNumber": 3334,
"gdbServerOther": "-p 3333
--no-deprecation-warning",
"corePortNumber": 3334
}
},

"CY8CKIT_062_BLE": {
"generic": {
"gdbServerGdbPortNumber": 3334,
"gdbServerOther": "-p 3333
--no-deprecation-warning",
"corePortNumber": 3334
}
},

"CY8CKIT_062_4343W": {
"PSOC6_02": {
"generic": {
"gdbServerGdbPortNumber": 3334,
"gdbServerOther": "-p 3333
--no-deprecation-warning",
Expand Down