Merge pull request #2691 from ARMmbed/no_custom_targets

Removed custom targets from config system
pull/2686/head
Bogdan Marinescu 2016-09-14 14:41:31 +03:00 committed by GitHub
commit 7669d7f8f5
40 changed files with 395 additions and 435 deletions

View File

@ -223,24 +223,6 @@ For example, an application may want to remove features with extra space or runt
}
```
## Custom targets
Application configuration can optionally define application-specific targets. These are mbed targets that are needed just to compile this specific application, so it doesn't make sense to add them to the list of official mbed targets; on the contrary, since they're part of `mbed_app.json`, they're versioned together with the application and only known by the application. Application-specific targets are defined with the key `custom_targets` in the `mbed_app.json` file and have the same syntax as a regular target definition, for example:
```
{
"custom_targets": {
"k64f_myapp": {
"inherits": ["K64F"],
"extra_labels_add": ["CUSTOM_K64F_LIB"]
}
}
}
```
This will define a new target named `k64f_myapp` that inherits from the `K64F` mbed target, but with an extra label defined, which will change the way the build system looks for sources in the tree.
# Configuration data precedence
The order in which the various bits of configurations are considered is this:

View File

@ -341,7 +341,7 @@ class Config(object):
__allowed_keys = {
"library": set(["name", "config", "target_overrides", "macros",
"__config_path"]),
"application": set(["config", "custom_targets", "target_overrides",
"application": set(["config", "target_overrides",
"macros", "__config_path"])
}
@ -363,11 +363,9 @@ class Config(object):
app_config - location of a chosen mbed_app.json file
NOTE: Construction of a Config object will look for the application
configuration file in top_level_dirs. If found once, it'll parse it and
check if it has a custom_targets function. If it does, it'll update the
list of targets as needed. If more than one config file is found, an
exception is raised. top_level_dirs may be None (in this case,
the constructor will not search for a configuration file)
configuration file in top_level_dirs. If found once, it'll parse it.
top_level_dirs may be None (in this case, the constructor will not
search for a configuration file).
"""
app_config_location = app_config
if app_config_location is None:
@ -396,7 +394,6 @@ class Config(object):
self.__mbed_app_config_name))
# Update the list of targets with the ones defined in the application
# config, if applicable
Target.add_py_targets(self.app_config_data.get("custom_targets", {}))
self.lib_config_data = {}
# Make sure that each config is processed only once
self.processed_configs = {}

View File

@ -66,10 +66,6 @@ class Target(object):
# need to be computed differently than regular attributes
cumulative_attributes = ['extra_labels', 'macros', 'device_has', 'features']
# List of targets that were added dynamically using "add_py_targets" (see
# below)
__py_targets = set()
# Default location of the 'targets.json' file
__targets_json_location_default = os.path.join(
os.path.dirname(os.path.abspath(__file__)), '..', 'hal', 'targets.json')
@ -226,26 +222,6 @@ class Target(object):
self.__dict__[attrname] = result
return result
@staticmethod
def add_py_targets(new_targets):
"""Add one or more new target(s) represented as a Python dictionary
in 'new_targets'. It is an error to add a target with a name that
already exists.
"""
crt_data = Target.get_json_target_data()
for target_key, target_value in new_targets.items():
if crt_data.has_key(target_key):
raise Exception(
"Attempt to add target '%s' that already exists"
% target_key)
# Add target data to the internal target dictionary
crt_data[target_key] = target_value
# Create the new target and add it to the relevant data structures
new_target = Target(target_key)
TARGETS.append(new_target)
TARGET_MAP[target_key] = new_target
TARGET_NAMES.append(target_key)
@staticmethod
@cached
def get_target(target_name):

View File

@ -39,13 +39,17 @@ def test_tree(full_name, name):
if "test_data" in sys.modules:
del sys.modules["test_data"]
import test_data
# If the test defines custom targets, they must exist in a file called
# "targets.json" in the test's directory.
if os.path.isfile(os.path.join(full_name, "targets.json")):
set_targets_json_location(os.path.join(full_name, "targets.json"))
else: # uset the regular set of targets
set_targets_json_location()
for target, expected in test_data.expected_results.items():
sys.stdout.write("%s:'%s'(%s) " % (name, expected["desc"], target))
sys.stdout.flush()
err_msg = None
try:
# Use 'set_targets_json_location' to remove the previous custom targets from the target list
set_targets_json_location(Target._Target__targets_json_location)
cfg, macros, features = get_config(full_name, target, "GCC_ARM")
macros = Config.config_macros_to_macros(macros)
except ConfigException as e:

View File

@ -1,43 +0,0 @@
{
"custom_targets": {
"b1": {
"inherits": ["Target"],
"core": "Cortex-M0",
"config": {
"base1_1": "v_base1_1_b1",
"base1_2": "v_base1_2_b1",
"base1_3": "v_base1_3_b1"
}
},
"d1": {
"inherits": ["b1"],
"config": {
"derived1": "v_derived1_d1",
"derived2": "v_derived2_d1"
},
"overrides": {
"base1_1": "v_base1_1_d1",
"base1_2": "v_base1_2_d1"
}
},
"b2": {
"config": {
"base2_1": "v_base2_1_b2",
"base2_2": "v_base2_2_b2"
}
},
"f": {
"inherits": ["b2", "d1"],
"config": {
"f1_1": "v_f1_1_f",
"f1_2": "v_f1_2_f"
},
"overrides": {
"base2_1": "v_base2_1_f",
"base1_1": "v_base1_1_f",
"derived2": "v_derived2_f",
"f1_1": "v_f1_1_f_override"
}
}
}
}

View File

@ -0,0 +1,42 @@
{
"b1": {
"extra_labels": [],
"default_lib": "std",
"core": "Cortex-M0",
"config": {
"base1_1": "v_base1_1_b1",
"base1_2": "v_base1_2_b1",
"base1_3": "v_base1_3_b1"
}
},
"d1": {
"inherits": ["b1"],
"config": {
"derived1": "v_derived1_d1",
"derived2": "v_derived2_d1"
},
"overrides": {
"base1_1": "v_base1_1_d1",
"base1_2": "v_base1_2_d1"
}
},
"b2": {
"config": {
"base2_1": "v_base2_1_b2",
"base2_2": "v_base2_2_b2"
}
},
"f": {
"inherits": ["b2", "d1"],
"config": {
"f1_1": "v_f1_1_f",
"f1_2": "v_f1_2_f"
},
"overrides": {
"base2_1": "v_base2_1_f",
"base1_1": "v_base1_1_f",
"derived2": "v_derived2_f",
"f1_1": "v_f1_1_f_override"
}
}
}

View File

@ -1,47 +0,0 @@
{
"custom_targets": {
"b1": {
"inherits": ["Target"],
"core": "Cortex-M0",
"config": {
"base1_1": "v_base1_1_b1",
"base1_2": "v_base1_2_b1",
"base1_3": "v_base1_3_b1"
}
},
"d1": {
"inherits": ["b1"],
"config": {
"derived1": "v_derived1_d1",
"derived2": "v_derived2_d1"
},
"overrides": {
"base1_1": "v_base1_1_d1",
"base1_2": "v_base1_2_d1"
}
},
"b2": {
"inherits": ["b1"],
"config": {
"base2_1": "v_base2_1_b2",
"base2_2": "v_base2_2_b2"
},
"overrides": {
"base1_2": "v_base1_2_b2"
}
},
"f": {
"inherits": ["d1", "b2"],
"config": {
"f1_1": "v_f1_1_f",
"f1_2": "v_f1_2_f"
},
"overrides": {
"base2_1": "v_base2_1_f",
"base1_1": "v_base1_1_f",
"derived2": "v_derived2_f",
"f1_1": "v_f1_1_f_override"
}
}
}
}

View File

@ -0,0 +1,46 @@
{
"b1": {
"extra_labels": [],
"default_lib": "std",
"core": "Cortex-M0",
"config": {
"base1_1": "v_base1_1_b1",
"base1_2": "v_base1_2_b1",
"base1_3": "v_base1_3_b1"
}
},
"d1": {
"inherits": ["b1"],
"config": {
"derived1": "v_derived1_d1",
"derived2": "v_derived2_d1"
},
"overrides": {
"base1_1": "v_base1_1_d1",
"base1_2": "v_base1_2_d1"
}
},
"b2": {
"inherits": ["b1"],
"config": {
"base2_1": "v_base2_1_b2",
"base2_2": "v_base2_2_b2"
},
"overrides": {
"base1_2": "v_base1_2_b2"
}
},
"f": {
"inherits": ["d1", "b2"],
"config": {
"f1_1": "v_f1_1_f",
"f1_2": "v_f1_2_f"
},
"overrides": {
"base2_1": "v_base2_1_f",
"base1_1": "v_base1_1_f",
"derived2": "v_derived2_f",
"f1_1": "v_f1_1_f_override"
}
}
}

View File

@ -1,46 +0,0 @@
{
"custom_targets": {
"b1": {
"inherits": ["Target"],
"core": "Cortex-M0",
"config": {
"base1_1": "v_base1_1_b1",
"base1_2": "v_base1_2_b1",
"base1_3": "v_base1_3_b1"
}
},
"d1": {
"inherits": ["b1"],
"config": {
"derived1": "v_derived1_d1",
"derived2": "v_derived2_d1"
},
"overrides": {
"base1_1": "v_base1_1_d1",
"base1_2": "v_base1_2_d1"
}
},
"b2": {
"config": {
"base2_1": "v_base2_1_b2",
"base2_2": "v_base2_2_b2"
},
"overrides": {
"base1_1": "v_base1_1_b2"
}
},
"f": {
"inherits": ["b2", "d1"],
"config": {
"f1_1": "v_f1_1_f",
"f1_2": "v_f1_2_f"
},
"overrides": {
"base2_1": "v_base2_1_f",
"base1_1": "v_base1_1_f",
"derived2": "v_derived2_f",
"f1_1": "v_f1_1_f_override"
}
}
}
}

View File

@ -0,0 +1,45 @@
{
"b1": {
"extra_labels": [],
"default_lib": "std",
"core": "Cortex-M0",
"config": {
"base1_1": "v_base1_1_b1",
"base1_2": "v_base1_2_b1",
"base1_3": "v_base1_3_b1"
}
},
"d1": {
"inherits": ["b1"],
"config": {
"derived1": "v_derived1_d1",
"derived2": "v_derived2_d1"
},
"overrides": {
"base1_1": "v_base1_1_d1",
"base1_2": "v_base1_2_d1"
}
},
"b2": {
"config": {
"base2_1": "v_base2_1_b2",
"base2_2": "v_base2_2_b2"
},
"overrides": {
"base1_1": "v_base1_1_b2"
}
},
"f": {
"inherits": ["b2", "d1"],
"config": {
"f1_1": "v_f1_1_f",
"f1_2": "v_f1_2_f"
},
"overrides": {
"base2_1": "v_base2_1_f",
"base1_1": "v_base1_1_f",
"derived2": "v_derived2_f",
"f1_1": "v_f1_1_f_override"
}
}
}

View File

@ -1,46 +0,0 @@
{
"custom_targets": {
"b1": {
"inherits": ["Target"],
"core": "Cortex-M0",
"config": {
"base1_1": "v_base1_1_b1",
"base1_2": "v_base1_2_b1",
"base1_3": "v_base1_3_b1"
}
},
"d1": {
"inherits": ["b1"],
"config": {
"derived1": "v_derived1_d1",
"derived2": "v_derived2_d1"
},
"overrides": {
"base1_1": "v_base1_1_d1",
"base1_2": "v_base1_2_d1"
}
},
"b2": {
"inherits": ["Target"],
"core": "Cortex-M0",
"config": {
"base2_1": "v_base2_1_b2",
"base2_2": "v_base2_2_b2",
"base1_1": "v_base1_1_b2"
}
},
"f": {
"inherits": ["b2", "d1"],
"config": {
"f1_1": "v_f1_1_f",
"f1_2": "v_f1_2_f"
},
"overrides": {
"base2_1": "v_base2_1_f",
"base1_1": "v_base1_1_f",
"derived2": "v_derived2_f",
"f1_1": "v_f1_1_f_override"
}
}
}
}

View File

@ -0,0 +1,46 @@
{
"b1": {
"extra_labels": [],
"default_lib": "std",
"core": "Cortex-M0",
"config": {
"base1_1": "v_base1_1_b1",
"base1_2": "v_base1_2_b1",
"base1_3": "v_base1_3_b1"
}
},
"d1": {
"inherits": ["b1"],
"config": {
"derived1": "v_derived1_d1",
"derived2": "v_derived2_d1"
},
"overrides": {
"base1_1": "v_base1_1_d1",
"base1_2": "v_base1_2_d1"
}
},
"b2": {
"extra_labels": [],
"default_lib": "std",
"core": "Cortex-M0",
"config": {
"base2_1": "v_base2_1_b2",
"base2_2": "v_base2_2_b2",
"base1_1": "v_base1_1_b2"
}
},
"f": {
"inherits": ["b2", "d1"],
"config": {
"f1_1": "v_f1_1_f",
"f1_2": "v_f1_2_f"
},
"overrides": {
"base2_1": "v_base2_1_f",
"base1_1": "v_base1_1_f",
"derived2": "v_derived2_f",
"f1_1": "v_f1_1_f_override"
}
}
}

View File

@ -1,21 +1,4 @@
{
"custom_targets": {
"base": {
"inherits": ["Target"],
"core": "Cortex-M0"
},
"b1": {
"inherits": ["base"],
"extra_labels_add": ["b1_label"]
},
"b2": {
"inherits": ["base"],
"extra_labels_add": ["b2_label"]
},
"both": {
"inherits": ["b1", "b2"]
}
},
"config": {
"app1": "v_app1",
"app2": "v_app2"

View File

@ -0,0 +1,18 @@
{
"base": {
"extra_labels": [],
"default_lib": "std",
"core": "Cortex-M0"
},
"b1": {
"inherits": ["base"],
"extra_labels_add": ["b1_label"]
},
"b2": {
"inherits": ["base"],
"extra_labels_add": ["b2_label"]
},
"both": {
"inherits": ["b1", "b2"]
}
}

View File

@ -1,21 +1,4 @@
{
"custom_targets": {
"base": {
"inherits": ["Target"],
"core": "Cortex-M0"
},
"b1": {
"inherits": ["base"],
"extra_labels_add": ["b1_label"]
},
"b2": {
"inherits": ["base"],
"extra_labels_add": ["b2_label"]
},
"both": {
"inherits": ["b1", "b2"]
}
},
"config": {
"app1": "v_app1",
"app2": "v_app2"

View File

@ -0,0 +1,18 @@
{
"base": {
"extra_labels": [],
"default_lib": "std",
"core": "Cortex-M0"
},
"b1": {
"inherits": ["base"],
"extra_labels_add": ["b1_label"]
},
"b2": {
"inherits": ["base"],
"extra_labels_add": ["b2_label"]
},
"both": {
"inherits": ["b1", "b2"]
}
}

View File

@ -1,21 +1,4 @@
{
"custom_targets": {
"base": {
"inherits": ["Target"],
"core": "Cortex-M0"
},
"b1": {
"inherits": ["base"],
"extra_labels_add": ["b1_label"]
},
"b2": {
"inherits": ["base"],
"extra_labels_add": ["b2_label"]
},
"both": {
"inherits": ["b1", "b2"]
}
},
"config": {
"app1": "v_app1",
"app2": "v_app2"

View File

@ -0,0 +1,18 @@
{
"base": {
"extra_labels": [],
"default_lib": "std",
"core": "Cortex-M0"
},
"b1": {
"inherits": ["base"],
"extra_labels_add": ["b1_label"]
},
"b2": {
"inherits": ["base"],
"extra_labels_add": ["b2_label"]
},
"both": {
"inherits": ["b1", "b2"]
}
}

View File

@ -1,38 +1,4 @@
{
"custom_targets": {
"base": {
"inherits": ["Target"],
"core": "Cortex-M0",
"config": {
"par1": "v_par1_base",
"par2": "v_par2_base",
"par3": "v_par3_base"
}
},
"b1": {
"inherits": ["base"],
"extra_labels_add": ["b1_label"],
"overrides": {
"par1": "v_par1_b1"
}
},
"b2": {
"inherits": ["base"],
"extra_labels_add": ["b2_label"],
"overrides": {
"par2": "v_par2_b2"
}
},
"both": {
"inherits": ["b1", "b2"],
"config": {
"par4": "v_par4_both"
},
"overrides": {
"par3": "v_par3_both"
}
}
},
"config": {
"app1": "v_app1",
"app2": "v_app2"

View File

@ -0,0 +1,35 @@
{
"base": {
"extra_labels": [],
"default_lib": "std",
"core": "Cortex-M0",
"config": {
"par1": "v_par1_base",
"par2": "v_par2_base",
"par3": "v_par3_base"
}
},
"b1": {
"inherits": ["base"],
"extra_labels_add": ["b1_label"],
"overrides": {
"par1": "v_par1_b1"
}
},
"b2": {
"inherits": ["base"],
"extra_labels_add": ["b2_label"],
"overrides": {
"par2": "v_par2_b2"
}
},
"both": {
"inherits": ["b1", "b2"],
"config": {
"par4": "v_par4_both"
},
"overrides": {
"par3": "v_par3_both"
}
}
}

View File

@ -1,21 +1,4 @@
{
"custom_targets": {
"base": {
"inherits": ["Target"],
"core": "Cortex-M0"
},
"b1": {
"inherits": ["base"],
"extra_labels_add": ["b1_label"]
},
"b2": {
"inherits": ["base"],
"extra_labels_add": ["b2_label"]
},
"both": {
"inherits": ["b1", "b2"]
}
},
"config": {
"app1": "v_app1",
"app2": "v_app2"

View File

@ -0,0 +1,18 @@
{
"base": {
"extra_labels": [],
"default_lib": "std",
"core": "Cortex-M0"
},
"b1": {
"inherits": ["base"],
"extra_labels_add": ["b1_label"]
},
"b2": {
"inherits": ["base"],
"extra_labels_add": ["b2_label"]
},
"both": {
"inherits": ["b1", "b2"]
}
}

View File

@ -1,38 +1,4 @@
{
"custom_targets": {
"base": {
"inherits": ["Target"],
"core": "Cortex-M0",
"config": {
"par1": "v_par1_base",
"par2": "v_par2_base",
"par3": "v_par3_base"
}
},
"b1": {
"inherits": ["base"],
"extra_labels_add": ["b1_label"],
"overrides": {
"par1": "v_par1_b1"
}
},
"b2": {
"inherits": ["base"],
"extra_labels_add": ["b2_label"],
"overrides": {
"par2": "v_par2_b2"
}
},
"both": {
"inherits": ["b1", "b2"],
"config": {
"par4": "v_par4_both"
},
"overrides": {
"par3": "v_par3_both"
}
}
},
"config": {
"app1": "v_app1",
"app2": "v_app2"

View File

@ -0,0 +1,35 @@
{
"base": {
"extra_labels": [],
"default_lib": "std",
"core": "Cortex-M0",
"config": {
"par1": "v_par1_base",
"par2": "v_par2_base",
"par3": "v_par3_base"
}
},
"b1": {
"inherits": ["base"],
"extra_labels_add": ["b1_label"],
"overrides": {
"par1": "v_par1_b1"
}
},
"b2": {
"inherits": ["base"],
"extra_labels_add": ["b2_label"],
"overrides": {
"par2": "v_par2_b2"
}
},
"both": {
"inherits": ["b1", "b2"],
"config": {
"par4": "v_par4_both"
},
"overrides": {
"par3": "v_par3_both"
}
}
}

View File

@ -1,12 +1,4 @@
{
"custom_targets": {
"test_target": {
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
}
},
"target_overrides": {
"test_target": {
"lib1.p1": "v_p1_lib1_app",

View File

@ -0,0 +1,8 @@
{
"test_target": {
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
}
}

View File

@ -1,11 +1,3 @@
{
"custom_targets": {
"test_target": {
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
}
},
"macros": ["APP1=10", "APP2", "LIB2_1=5"]
}

View File

@ -0,0 +1,8 @@
{
"test_target": {
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
}
}

View File

@ -1,12 +1,4 @@
{
"custom_targets": {
"test_target": {
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
}
},
"target_overrides": {
"*": {
"target.features": ["IPV4", "IPV6"]

View File

@ -0,0 +1,8 @@
{
"test_target": {
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
}
}

View File

@ -1,12 +1,4 @@
{
"custom_targets": {
"test_target": {
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
}
},
"target_overrides": {
"*": {
"target.features_add": ["IPV6"]

View File

@ -0,0 +1,8 @@
{
"test_target": {
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
}
}

View File

@ -1,12 +1,4 @@
{
"custom_targets": {
"test_target": {
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
}
},
"target_overrides": {
"*": {
"target.features_add": ["IPV4"]

View File

@ -0,0 +1,8 @@
{
"test_target": {
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
}
}

View File

@ -1,12 +1,4 @@
{
"custom_targets": {
"test_target": {
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
}
},
"target_overrides": {
"*": {
"target.features_add": ["IPV4"],

View File

@ -0,0 +1,8 @@
{
"test_target": {
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
}
}

View File

@ -1,10 +0,0 @@
{
"custom_targets": {
"test_target": {
"core": "Cortex-M0",
"extra_labels": [],
"features": ["IPV4"],
"default_lib": "std"
}
}
}

View File

@ -0,0 +1,8 @@
{
"test_target": {
"core": "Cortex-M0",
"extra_labels": [],
"features": ["IPV4"],
"default_lib": "std"
}
}

View File

@ -1,12 +1,4 @@
{
"custom_targets": {
"test_target": {
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
}
},
"target_overrides": {
"*": {
"target.features_add": ["UVISOR"],

View File

@ -0,0 +1,8 @@
{
"test_target": {
"core": "Cortex-M0",
"extra_labels": [],
"features": [],
"default_lib": "std"
}
}