Пример #1
0
 def get_target_config_data(self):
     # We consider the resolution order for our target and sort it by level reversed,
     # so that we first look at the top level target (the parent), then its direct children,
     # then the children's children and so on, until we reach self.target
     # TODO: this might not work so well in some multiple inheritance scenarios
     # At each step, look at two keys of the target data:
     #   - config_parameters: used to define new configuration parameters
     #   - config_overrides: used to override already defined configuration parameters
     params, json_data = {}, Target.get_json_target_data()
     resolution_order = [e[0] for e in sorted(Target.get_target(self.target).resolution_order, key = lambda e: e[1], reverse = True)]
     for tname in resolution_order:
         # Read the target data directly from its description
         t = json_data[tname]
         # Process definitions first
         self._process_config_parameters(t.get("config", {}), params, tname, "target")
         # Then process overrides
         for name, v in t.get("overrides", {}).items():
             full_name = ConfigParameter.get_full_name(name, tname, "target")
             # If the parameter name is not defined or if there isn't a path from this target to the target where the
             # parameter was defined in the target inheritance tree, raise an error
             # We need to use 'defined_by[7:]' to remove the "target:" prefix from defined_by
             if (not full_name in params) or (not params[full_name].defined_by[7:] in Target.get_target(tname).resolution_order_names):
                 raise ConfigException("Attempt to override undefined parameter '%s' in '%s'" % (name, ConfigParameter.get_display_name(tname, "target")))
             # Otherwise update the value of the parameter
             params[full_name].set_value(v, tname, "target")
     return params
Пример #2
0
def check_extra_labels(dict):
    """Check that extra_labels does not contain any Target names

    is a generator for errors
    """
    for label in (dict.get("extra_labels", []) +
                  dict.get("extra_labels_add", [])):
        if label in Target.get_json_target_data():
            yield "%s is not allowed in extra_labels" % label
Пример #3
0
def check_extra_labels(dict):
    """Check that extra_labels does not contain any Target names

    is a generator for errors
    """
    for label in (dict.get("extra_labels", []) +
                  dict.get("extra_labels_add", [])):
        if label in Target.get_json_target_data():
            yield "%s is not allowed in extra_labels" % label
Пример #4
0
def orphans_cmd():
    """Find and print all orphan targets"""
    orphans = Target.get_json_target_data().keys()
    for tgt in TARGET_MAP.values():
        for name in tgt.resolution_order_names:
            if name in orphans:
                orphans.remove(name)
    if orphans:
        print dump_all([orphans], default_flow_style=False)
    return len(orphans)
Пример #5
0
def orphans_cmd():
    """Find and print all orphan targets"""
    orphans = Target.get_json_target_data().keys()
    for tgt in TARGET_MAP.values():
        for name in tgt.resolution_order_names:
            if name in orphans:
                orphans.remove(name)
    if orphans:
        print dump_all([orphans], default_flow_style=False)
    return len(orphans)
Пример #6
0
                src_paths=[mbed_os_dir],
                build_dir=config_header_dir,
                target=target_name,
                toolchain_name=toolchain_name,
                build_profile=[profile_data],
                app_config=app_config_path)
            # each toolchain must then scan the mbed dir to pick up more configs

            resources = Resources(notifier).scan_with_toolchain(
                src_paths=[mbed_os_dir],
                toolchain=profile_toolchain,
                exclude=True,
                mbedignore_path=mbedignore_file)

            is_custom_target = os.path.dirname(
                Target.get_json_target_data()[target_name]
                ["_from_file"]) == custom_target_dir
            if is_custom_target:
                # Add the directory of the custom target
                resources.add_directory(
                    os.path.join(custom_target_dir, "TARGET_" + target_name))

                # Filter out duplicate files (if a target overrides e.g. system_clock.c)
                dupe_objects, dupe_headers = resources._collect_duplicates(
                    dict(), dict())
                duplicates = {**dupe_objects, **dupe_headers}
                for filename, dupe_paths in duplicates.items():
                    if len(dupe_paths) <= 1:
                        # Not really a duplicate
                        continue

                    print(