Make ArmPackManager cache a static variable (to avoid reading index.json for each target).

pull/3172/head
Sarah Marsh 2016-10-31 17:42:36 -05:00
parent b9bac0516b
commit d8fc362c11
2 changed files with 4 additions and 4 deletions

View File

@ -30,6 +30,7 @@ class DeviceCMSIS():
"""CMSIS Device class
Encapsulates target information retrieved by arm-pack-manager"""
cache = Cache(True, False)
def __init__(self, target):
target_info = self.check_supported(target)
if not target_info:
@ -48,17 +49,16 @@ class DeviceCMSIS():
@staticmethod
def check_supported(target):
cache = Cache(True, False)
t = TARGET_MAP[target]
try:
cpu_name = t.device_name
target_info = cache.index[cpu_name]
target_info = DeviceCMSIS.cache.index[cpu_name]
# Target does not have device name or pdsc file
except:
try:
# Try to find the core as a generic CMSIS target
cpu_name = DeviceCMSIS.cpu_cmsis(t.core)
target_info = cache.index[cpu_name]
target_info = DeviceCMSIS.index[cpu_name]
except:
return False
target_info["_cpu_name"] = cpu_name

View File

@ -234,7 +234,7 @@ def main():
# Export to selected toolchain
exporter, toolchain_name = get_exporter_toolchain(options.ide)
if options.mcu not in exporter.TARGETS:
args_error(parser, "%s not supported by %s")
args_error(parser, "%s not supported by %s"%(options.mcu,options.ide))
profile = extract_profile(parser, options, toolchain_name)
export(options.mcu, options.ide, build=options.build,
src=options.source_dir, macros=options.macros,