Skip to content

Commit 7669d7f

Browse files
authored
Merge pull request #2691 from ARMmbed/no_custom_targets
Removed custom targets from config system
2 parents 21a2123 + 8852b2e commit 7669d7f

40 files changed

+395
-435
lines changed

docs/config_system.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -223,24 +223,6 @@ For example, an application may want to remove features with extra space or runt
223223
}
224224
```
225225

226-
## Custom targets
227-
228-
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:
229-
230-
231-
```
232-
{
233-
"custom_targets": {
234-
"k64f_myapp": {
235-
"inherits": ["K64F"],
236-
"extra_labels_add": ["CUSTOM_K64F_LIB"]
237-
}
238-
}
239-
}
240-
```
241-
242-
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.
243-
244226
# Configuration data precedence
245227

246228
The order in which the various bits of configurations are considered is this:

tools/config.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ class Config(object):
341341
__allowed_keys = {
342342
"library": set(["name", "config", "target_overrides", "macros",
343343
"__config_path"]),
344-
"application": set(["config", "custom_targets", "target_overrides",
344+
"application": set(["config", "target_overrides",
345345
"macros", "__config_path"])
346346
}
347347

@@ -363,11 +363,9 @@ def __init__(self, target, top_level_dirs=None, app_config=None):
363363
app_config - location of a chosen mbed_app.json file
364364
365365
NOTE: Construction of a Config object will look for the application
366-
configuration file in top_level_dirs. If found once, it'll parse it and
367-
check if it has a custom_targets function. If it does, it'll update the
368-
list of targets as needed. If more than one config file is found, an
369-
exception is raised. top_level_dirs may be None (in this case,
370-
the constructor will not search for a configuration file)
366+
configuration file in top_level_dirs. If found once, it'll parse it.
367+
top_level_dirs may be None (in this case, the constructor will not
368+
search for a configuration file).
371369
"""
372370
app_config_location = app_config
373371
if app_config_location is None:
@@ -396,7 +394,6 @@ def __init__(self, target, top_level_dirs=None, app_config=None):
396394
self.__mbed_app_config_name))
397395
# Update the list of targets with the ones defined in the application
398396
# config, if applicable
399-
Target.add_py_targets(self.app_config_data.get("custom_targets", {}))
400397
self.lib_config_data = {}
401398
# Make sure that each config is processed only once
402399
self.processed_configs = {}

tools/targets.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ class Target(object):
6666
# need to be computed differently than regular attributes
6767
cumulative_attributes = ['extra_labels', 'macros', 'device_has', 'features']
6868

69-
# List of targets that were added dynamically using "add_py_targets" (see
70-
# below)
71-
__py_targets = set()
72-
7369
# Default location of the 'targets.json' file
7470
__targets_json_location_default = os.path.join(
7571
os.path.dirname(os.path.abspath(__file__)), '..', 'hal', 'targets.json')
@@ -226,26 +222,6 @@ def __getattr__(self, attrname):
226222
self.__dict__[attrname] = result
227223
return result
228224

229-
@staticmethod
230-
def add_py_targets(new_targets):
231-
"""Add one or more new target(s) represented as a Python dictionary
232-
in 'new_targets'. It is an error to add a target with a name that
233-
already exists.
234-
"""
235-
crt_data = Target.get_json_target_data()
236-
for target_key, target_value in new_targets.items():
237-
if crt_data.has_key(target_key):
238-
raise Exception(
239-
"Attempt to add target '%s' that already exists"
240-
% target_key)
241-
# Add target data to the internal target dictionary
242-
crt_data[target_key] = target_value
243-
# Create the new target and add it to the relevant data structures
244-
new_target = Target(target_key)
245-
TARGETS.append(new_target)
246-
TARGET_MAP[target_key] = new_target
247-
TARGET_NAMES.append(target_key)
248-
249225
@staticmethod
250226
@cached
251227
def get_target(target_name):

tools/test/config_test/config_test.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,17 @@ def test_tree(full_name, name):
3939
if "test_data" in sys.modules:
4040
del sys.modules["test_data"]
4141
import test_data
42+
# If the test defines custom targets, they must exist in a file called
43+
# "targets.json" in the test's directory.
44+
if os.path.isfile(os.path.join(full_name, "targets.json")):
45+
set_targets_json_location(os.path.join(full_name, "targets.json"))
46+
else: # uset the regular set of targets
47+
set_targets_json_location()
4248
for target, expected in test_data.expected_results.items():
4349
sys.stdout.write("%s:'%s'(%s) " % (name, expected["desc"], target))
4450
sys.stdout.flush()
4551
err_msg = None
4652
try:
47-
# Use 'set_targets_json_location' to remove the previous custom targets from the target list
48-
set_targets_json_location(Target._Target__targets_json_location)
4953
cfg, macros, features = get_config(full_name, target, "GCC_ARM")
5054
macros = Config.config_macros_to_macros(macros)
5155
except ConfigException as e:

tools/test/config_test/test01/mbed_app.json

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"b1": {
3+
"extra_labels": [],
4+
"default_lib": "std",
5+
"core": "Cortex-M0",
6+
"config": {
7+
"base1_1": "v_base1_1_b1",
8+
"base1_2": "v_base1_2_b1",
9+
"base1_3": "v_base1_3_b1"
10+
}
11+
},
12+
"d1": {
13+
"inherits": ["b1"],
14+
"config": {
15+
"derived1": "v_derived1_d1",
16+
"derived2": "v_derived2_d1"
17+
},
18+
"overrides": {
19+
"base1_1": "v_base1_1_d1",
20+
"base1_2": "v_base1_2_d1"
21+
}
22+
},
23+
"b2": {
24+
"config": {
25+
"base2_1": "v_base2_1_b2",
26+
"base2_2": "v_base2_2_b2"
27+
}
28+
},
29+
"f": {
30+
"inherits": ["b2", "d1"],
31+
"config": {
32+
"f1_1": "v_f1_1_f",
33+
"f1_2": "v_f1_2_f"
34+
},
35+
"overrides": {
36+
"base2_1": "v_base2_1_f",
37+
"base1_1": "v_base1_1_f",
38+
"derived2": "v_derived2_f",
39+
"f1_1": "v_f1_1_f_override"
40+
}
41+
}
42+
}

tools/test/config_test/test02/mbed_app.json

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"b1": {
3+
"extra_labels": [],
4+
"default_lib": "std",
5+
"core": "Cortex-M0",
6+
"config": {
7+
"base1_1": "v_base1_1_b1",
8+
"base1_2": "v_base1_2_b1",
9+
"base1_3": "v_base1_3_b1"
10+
}
11+
},
12+
"d1": {
13+
"inherits": ["b1"],
14+
"config": {
15+
"derived1": "v_derived1_d1",
16+
"derived2": "v_derived2_d1"
17+
},
18+
"overrides": {
19+
"base1_1": "v_base1_1_d1",
20+
"base1_2": "v_base1_2_d1"
21+
}
22+
},
23+
"b2": {
24+
"inherits": ["b1"],
25+
"config": {
26+
"base2_1": "v_base2_1_b2",
27+
"base2_2": "v_base2_2_b2"
28+
},
29+
"overrides": {
30+
"base1_2": "v_base1_2_b2"
31+
}
32+
},
33+
"f": {
34+
"inherits": ["d1", "b2"],
35+
"config": {
36+
"f1_1": "v_f1_1_f",
37+
"f1_2": "v_f1_2_f"
38+
},
39+
"overrides": {
40+
"base2_1": "v_base2_1_f",
41+
"base1_1": "v_base1_1_f",
42+
"derived2": "v_derived2_f",
43+
"f1_1": "v_f1_1_f_override"
44+
}
45+
}
46+
}

tools/test/config_test/test03/mbed_app.json

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"b1": {
3+
"extra_labels": [],
4+
"default_lib": "std",
5+
"core": "Cortex-M0",
6+
"config": {
7+
"base1_1": "v_base1_1_b1",
8+
"base1_2": "v_base1_2_b1",
9+
"base1_3": "v_base1_3_b1"
10+
}
11+
},
12+
"d1": {
13+
"inherits": ["b1"],
14+
"config": {
15+
"derived1": "v_derived1_d1",
16+
"derived2": "v_derived2_d1"
17+
},
18+
"overrides": {
19+
"base1_1": "v_base1_1_d1",
20+
"base1_2": "v_base1_2_d1"
21+
}
22+
},
23+
"b2": {
24+
"config": {
25+
"base2_1": "v_base2_1_b2",
26+
"base2_2": "v_base2_2_b2"
27+
},
28+
"overrides": {
29+
"base1_1": "v_base1_1_b2"
30+
}
31+
},
32+
"f": {
33+
"inherits": ["b2", "d1"],
34+
"config": {
35+
"f1_1": "v_f1_1_f",
36+
"f1_2": "v_f1_2_f"
37+
},
38+
"overrides": {
39+
"base2_1": "v_base2_1_f",
40+
"base1_1": "v_base1_1_f",
41+
"derived2": "v_derived2_f",
42+
"f1_1": "v_f1_1_f_override"
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)