mirror of https://github.com/ARMmbed/mbed-os.git
Handle target overrides that have a path correctly
parent
c180324530
commit
dd3708c24c
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
import os
|
import os
|
||||||
from os.path import dirname, abspath, exists, join
|
from os.path import dirname, abspath, exists, join, isabs
|
||||||
import sys
|
import sys
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from os.path import splitext, relpath
|
from os.path import splitext, relpath
|
||||||
|
@ -30,6 +30,10 @@ from tools.arm_pack_manager import Cache
|
||||||
from tools.targets import CUMULATIVE_ATTRIBUTES, TARGET_MAP, \
|
from tools.targets import CUMULATIVE_ATTRIBUTES, TARGET_MAP, \
|
||||||
generate_py_target, get_resolution_order
|
generate_py_target, get_resolution_order
|
||||||
|
|
||||||
|
PATH_OVERRIDES = set(["target.bootloader_img"])
|
||||||
|
BOOTLOADER_OVERRIDES = set(["target.bootloader_img", "target.restrict_size",
|
||||||
|
"target.mbed_app_start", "target.mbed_app_size"])
|
||||||
|
|
||||||
# Base class for all configuration exceptions
|
# Base class for all configuration exceptions
|
||||||
class ConfigException(Exception):
|
class ConfigException(Exception):
|
||||||
"""Config system only exception. Makes it easier to distinguish config
|
"""Config system only exception. Makes it easier to distinguish config
|
||||||
|
@ -84,6 +88,8 @@ class ConfigParameter(object):
|
||||||
else:
|
else:
|
||||||
prefix = unit_name + '.'
|
prefix = unit_name + '.'
|
||||||
return prefix + name
|
return prefix + name
|
||||||
|
if name in BOOTLOADER_OVERRIDES:
|
||||||
|
return name
|
||||||
# The name has a prefix, so check if it is valid
|
# The name has a prefix, so check if it is valid
|
||||||
if not allow_prefix:
|
if not allow_prefix:
|
||||||
raise ConfigException("Invalid parameter name '%s' in '%s'" %
|
raise ConfigException("Invalid parameter name '%s' in '%s'" %
|
||||||
|
@ -362,8 +368,6 @@ class Config(object):
|
||||||
"artifact_name": str}
|
"artifact_name": str}
|
||||||
}
|
}
|
||||||
|
|
||||||
__unused_overrides = set(["target.bootloader_img", "target.restrict_size",
|
|
||||||
"target.mbed_app_start", "target.mbed_app_size"])
|
|
||||||
|
|
||||||
# Allowed features in configurations
|
# Allowed features in configurations
|
||||||
__allowed_features = [
|
__allowed_features = [
|
||||||
|
@ -441,7 +445,7 @@ class Config(object):
|
||||||
self.target = tgt
|
self.target = tgt
|
||||||
self.target = deepcopy(self.target)
|
self.target = deepcopy(self.target)
|
||||||
self.target_labels = self.target.labels
|
self.target_labels = self.target.labels
|
||||||
for override in self.__unused_overrides:
|
for override in BOOTLOADER_OVERRIDES:
|
||||||
_, attr = override.split(".")
|
_, attr = override.split(".")
|
||||||
setattr(self.target, attr, None)
|
setattr(self.target, attr, None)
|
||||||
|
|
||||||
|
@ -491,7 +495,7 @@ class Config(object):
|
||||||
@property
|
@property
|
||||||
def has_regions(self):
|
def has_regions(self):
|
||||||
"""Does this config have regions defined?"""
|
"""Does this config have regions defined?"""
|
||||||
for override in self.__unused_overrides:
|
for override in BOOTLOADER_OVERRIDES:
|
||||||
_, attr = override.split(".")
|
_, attr = override.split(".")
|
||||||
if getattr(self.target, attr, None):
|
if getattr(self.target, attr, None):
|
||||||
return True
|
return True
|
||||||
|
@ -552,6 +556,9 @@ class Config(object):
|
||||||
def _generate_bootloader_build(self, rom_start, rom_size):
|
def _generate_bootloader_build(self, rom_start, rom_size):
|
||||||
start = rom_start
|
start = rom_start
|
||||||
if self.target.bootloader_img:
|
if self.target.bootloader_img:
|
||||||
|
if isabs(self.target.bootloader_img):
|
||||||
|
filename = self.target.bootloader_img
|
||||||
|
else:
|
||||||
basedir = abspath(dirname(self.app_config_location))
|
basedir = abspath(dirname(self.app_config_location))
|
||||||
filename = join(basedir, self.target.bootloader_img)
|
filename = join(basedir, self.target.bootloader_img)
|
||||||
if not exists(filename):
|
if not exists(filename):
|
||||||
|
@ -685,12 +692,9 @@ class Config(object):
|
||||||
|
|
||||||
# Consider the others as overrides
|
# Consider the others as overrides
|
||||||
for name, val in overrides.items():
|
for name, val in overrides.items():
|
||||||
if (name.startswith("target.") and
|
if (name in PATH_OVERRIDES and "__config_path" in data):
|
||||||
(unit_kind is "application" or
|
val = os.path.join(
|
||||||
name in self.__unused_overrides)):
|
os.path.dirname(data["__config_path"]), val)
|
||||||
_, attribute = name.split(".")
|
|
||||||
setattr(self.target, attribute, val)
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Get the full name of the parameter
|
# Get the full name of the parameter
|
||||||
full_name = ConfigParameter.get_full_name(name, unit_name,
|
full_name = ConfigParameter.get_full_name(name, unit_name,
|
||||||
|
@ -698,6 +702,12 @@ class Config(object):
|
||||||
if full_name in params:
|
if full_name in params:
|
||||||
params[full_name].set_value(val, unit_name, unit_kind,
|
params[full_name].set_value(val, unit_name, unit_kind,
|
||||||
label)
|
label)
|
||||||
|
elif (name.startswith("target.") and
|
||||||
|
(unit_kind is "application" or
|
||||||
|
name in BOOTLOADER_OVERRIDES)):
|
||||||
|
_, attribute = name.split(".")
|
||||||
|
setattr(self.target, attribute, val)
|
||||||
|
continue
|
||||||
else:
|
else:
|
||||||
self.config_errors.append(
|
self.config_errors.append(
|
||||||
ConfigException(
|
ConfigException(
|
||||||
|
@ -750,7 +760,7 @@ class Config(object):
|
||||||
rel_names = [tgt for tgt, _ in
|
rel_names = [tgt for tgt, _ in
|
||||||
get_resolution_order(self.target.json_data, tname,
|
get_resolution_order(self.target.json_data, tname,
|
||||||
[])]
|
[])]
|
||||||
if full_name in self.__unused_overrides:
|
if full_name in BOOTLOADER_OVERRIDES:
|
||||||
continue
|
continue
|
||||||
if (full_name not in params) or \
|
if (full_name not in params) or \
|
||||||
(params[full_name].defined_by[7:] not in rel_names):
|
(params[full_name].defined_by[7:] not in rel_names):
|
||||||
|
|
Loading…
Reference in New Issue