|
17 | 17 |
|
18 | 18 | from copy import deepcopy
|
19 | 19 | import os
|
20 |
| -from os.path import dirname, abspath, exists, join |
| 20 | +from os.path import dirname, abspath, exists, join, isabs |
21 | 21 | import sys
|
22 | 22 | from collections import namedtuple
|
23 | 23 | from os.path import splitext, relpath
|
|
30 | 30 | from tools.targets import CUMULATIVE_ATTRIBUTES, TARGET_MAP, \
|
31 | 31 | generate_py_target, get_resolution_order
|
32 | 32 |
|
| 33 | +PATH_OVERRIDES = set(["target.bootloader_img"]) |
| 34 | +BOOTLOADER_OVERRIDES = set(["target.bootloader_img", "target.restrict_size", |
| 35 | + "target.mbed_app_start", "target.mbed_app_size"]) |
| 36 | + |
33 | 37 | # Base class for all configuration exceptions
|
34 | 38 | class ConfigException(Exception):
|
35 | 39 | """Config system only exception. Makes it easier to distinguish config
|
@@ -84,6 +88,8 @@ def get_full_name(name, unit_name, unit_kind, label=None,
|
84 | 88 | else:
|
85 | 89 | prefix = unit_name + '.'
|
86 | 90 | return prefix + name
|
| 91 | + if name in BOOTLOADER_OVERRIDES: |
| 92 | + return name |
87 | 93 | # The name has a prefix, so check if it is valid
|
88 | 94 | if not allow_prefix:
|
89 | 95 | raise ConfigException("Invalid parameter name '%s' in '%s'" %
|
@@ -362,8 +368,6 @@ class Config(object):
|
362 | 368 | "artifact_name": str}
|
363 | 369 | }
|
364 | 370 |
|
365 |
| - __unused_overrides = set(["target.bootloader_img", "target.restrict_size", |
366 |
| - "target.mbed_app_start", "target.mbed_app_size"]) |
367 | 371 |
|
368 | 372 | # Allowed features in configurations
|
369 | 373 | __allowed_features = [
|
@@ -441,7 +445,7 @@ def __init__(self, tgt, top_level_dirs=None, app_config=None):
|
441 | 445 | self.target = tgt
|
442 | 446 | self.target = deepcopy(self.target)
|
443 | 447 | self.target_labels = self.target.labels
|
444 |
| - for override in self.__unused_overrides: |
| 448 | + for override in BOOTLOADER_OVERRIDES: |
445 | 449 | _, attr = override.split(".")
|
446 | 450 | setattr(self.target, attr, None)
|
447 | 451 |
|
@@ -491,7 +495,7 @@ def add_config_files(self, flist):
|
491 | 495 | @property
|
492 | 496 | def has_regions(self):
|
493 | 497 | """Does this config have regions defined?"""
|
494 |
| - for override in self.__unused_overrides: |
| 498 | + for override in BOOTLOADER_OVERRIDES: |
495 | 499 | _, attr = override.split(".")
|
496 | 500 | if getattr(self.target, attr, None):
|
497 | 501 | return True
|
@@ -552,8 +556,11 @@ def regions(self):
|
552 | 556 | def _generate_bootloader_build(self, rom_start, rom_size):
|
553 | 557 | start = rom_start
|
554 | 558 | if self.target.bootloader_img:
|
555 |
| - basedir = abspath(dirname(self.app_config_location)) |
556 |
| - filename = join(basedir, self.target.bootloader_img) |
| 559 | + if isabs(self.target.bootloader_img): |
| 560 | + filename = self.target.bootloader_img |
| 561 | + else: |
| 562 | + basedir = abspath(dirname(self.app_config_location)) |
| 563 | + filename = join(basedir, self.target.bootloader_img) |
557 | 564 | if not exists(filename):
|
558 | 565 | raise ConfigException("Bootloader %s not found" % filename)
|
559 | 566 | part = intelhex_offset(filename, offset=rom_start)
|
@@ -685,19 +692,22 @@ def _process_config_and_overrides(self, data, params, unit_name, unit_kind):
|
685 | 692 |
|
686 | 693 | # Consider the others as overrides
|
687 | 694 | for name, val in overrides.items():
|
688 |
| - if (name.startswith("target.") and |
689 |
| - (unit_kind is "application" or |
690 |
| - name in self.__unused_overrides)): |
691 |
| - _, attribute = name.split(".") |
692 |
| - setattr(self.target, attribute, val) |
693 |
| - continue |
| 695 | + if (name in PATH_OVERRIDES and "__config_path" in data): |
| 696 | + val = os.path.join( |
| 697 | + os.path.dirname(data["__config_path"]), val) |
694 | 698 |
|
695 | 699 | # Get the full name of the parameter
|
696 | 700 | full_name = ConfigParameter.get_full_name(name, unit_name,
|
697 | 701 | unit_kind, label)
|
698 | 702 | if full_name in params:
|
699 | 703 | params[full_name].set_value(val, unit_name, unit_kind,
|
700 | 704 | label)
|
| 705 | + elif (name.startswith("target.") and |
| 706 | + (unit_kind is "application" or |
| 707 | + name in BOOTLOADER_OVERRIDES)): |
| 708 | + _, attribute = name.split(".") |
| 709 | + setattr(self.target, attribute, val) |
| 710 | + continue |
701 | 711 | else:
|
702 | 712 | self.config_errors.append(
|
703 | 713 | ConfigException(
|
@@ -750,7 +760,7 @@ def get_target_config_data(self):
|
750 | 760 | rel_names = [tgt for tgt, _ in
|
751 | 761 | get_resolution_order(self.target.json_data, tname,
|
752 | 762 | [])]
|
753 |
| - if full_name in self.__unused_overrides: |
| 763 | + if full_name in BOOTLOADER_OVERRIDES: |
754 | 764 | continue
|
755 | 765 | if (full_name not in params) or \
|
756 | 766 | (params[full_name].defined_by[7:] not in rel_names):
|
|
0 commit comments