Skip to content

Fix issue2183 #2186

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

Merged
merged 2 commits into from
Jul 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tools/export/exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ class OldLibrariesException(Exception): pass

class FailedBuildException(Exception) : pass

# Exporter descriptor for TARGETS
# TARGETS as class attribute for backward compatibility (allows: if in Exporter.TARGETS)
class ExporterTargetsProperty(object):
def __init__(self, func):
self.func = func
def __get__(self, inst, cls):
return self.func(cls)

class Exporter(object):
TEMPLATE_DIR = dirname(__file__)
DOT_IN_RELATIVE_PATH = False
Expand Down
14 changes: 7 additions & 7 deletions tools/export/iar.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import os
from project_generator_definitions.definitions import ProGenDef

from tools.export.exporters import Exporter
from tools.export.exporters import Exporter, ExporterTargetsProperty
from tools.targets import TARGET_MAP, TARGET_NAMES

# If you wish to add a new target, add it to project_generator_definitions, and then
Expand All @@ -35,19 +35,19 @@ class IAREmbeddedWorkbench(Exporter):

MBED_CONFIG_HEADER_SUPPORTED = True

@property
def TARGETS(self):
if not hasattr(self, "_targets_supported"):
self._targets_supported = []
@ExporterTargetsProperty
def TARGETS(cls):
if not hasattr(cls, "_targets_supported"):
cls._targets_supported = []
for target in TARGET_NAMES:
try:
if (ProGenDef('iar').is_supported(str(TARGET_MAP[target])) or
ProGenDef('iar').is_supported(TARGET_MAP[target].progen['target'])):
self._targets_supported.append(target)
cls._targets_supported.append(target)
except AttributeError:
# target is not supported yet
continue
return self._targets_supported
return cls._targets_supported

def generate(self, progen_build=False):
""" Generates the project files """
Expand Down
14 changes: 7 additions & 7 deletions tools/export/uvision4.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from os.path import basename, join, dirname
from project_generator_definitions.definitions import ProGenDef

from tools.export.exporters import Exporter
from tools.export.exporters import Exporter, ExporterTargetsProperty
from tools.targets import TARGET_MAP, TARGET_NAMES
from tools.settings import ARM_INC

Expand All @@ -36,19 +36,19 @@ class Uvision4(Exporter):

MBED_CONFIG_HEADER_SUPPORTED = True

@property
def TARGETS(self):
if not hasattr(self, "_targets_supported"):
self._targets_supported = []
@ExporterTargetsProperty
def TARGETS(cls):
if not hasattr(cls, "_targets_supported"):
cls._targets_supported = []
for target in TARGET_NAMES:
try:
if (ProGenDef('uvision').is_supported(str(TARGET_MAP[target])) or
ProGenDef('uvision').is_supported(TARGET_MAP[target].progen['target'])):
self._targets_supported.append(target)
cls._targets_supported.append(target)
except AttributeError:
# target is not supported yet
continue
return self._targets_supported
return cls._targets_supported

def get_toolchain(self):
return TARGET_MAP[self.target].default_toolchain
Expand Down
18 changes: 7 additions & 11 deletions tools/export/uvision5.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from os.path import basename, join, dirname
from project_generator_definitions.definitions import ProGenDef

from tools.export.exporters import Exporter
from tools.export.exporters import Exporter, ExporterTargetsProperty
from tools.targets import TARGET_MAP, TARGET_NAMES
from tools.settings import ARM_INC

Expand All @@ -36,23 +36,19 @@ class Uvision5(Exporter):

MBED_CONFIG_HEADER_SUPPORTED = True

# backward compatibility with our scripts
def __init__(self):
self._targets = []

@property
def TARGETS(self):
if not hasattr(self, "_targets_supported"):
self._targets_supported = []
@ExporterTargetsProperty
def TARGETS(cls):
if not hasattr(cls, "_targets_supported"):
cls._targets_supported = []
for target in TARGET_NAMES:
try:
if (ProGenDef('uvision5').is_supported(str(TARGET_MAP[target])) or
ProGenDef('uvision5').is_supported(TARGET_MAP[target].progen['target'])):
self._targets_supported.append(target)
cls._targets_supported.append(target)
except AttributeError:
# target is not supported yet
continue
return self._targets_supported
return cls._targets_supported

def get_toolchain(self):
return TARGET_MAP[self.target].default_toolchain
Expand Down