diff --git a/tools/config/__init__.py b/tools/config/__init__.py index 747692eb35..16df46b8dd 100644 --- a/tools/config/__init__.py +++ b/tools/config/__init__.py @@ -543,7 +543,6 @@ class Config(object): # Check that we didn't already process this file if full_path in self.processed_configs: continue - self.processed_configs[full_path] = True # Read the library configuration and add a "__full_config_path" # attribute to it try: @@ -568,6 +567,13 @@ class Config(object): raise ConfigException("; ".join( self.format_validation_error(x, config_file) for x in errors)) + if ( + "requires" in self.app_config_data + and cfg["name"] not in self.app_config_data["requires"] + ): + continue + + self.processed_configs[full_path] = True cfg["__config_path"] = full_path diff --git a/tools/config/definitions.json b/tools/config/definitions.json index a6f71dcc61..e41fbbe4b8 100644 --- a/tools/config/definitions.json +++ b/tools/config/definitions.json @@ -6,6 +6,14 @@ "type": "string" } }, + "requires_definition": { + "descirption": "Required libraries", + "type": "array", + "items": { + "type": "string", + "pattern": "(^[\\w()_]+$|^[\\w()_]+=.+$)" + } + }, "macro_definition": { "description": "A list of extra macros that will be defined when compiling a project that includes this library.", "type": "array", diff --git a/tools/config/schema_app.json b/tools/config/schema_app.json index 981100ce59..dee7061c53 100644 --- a/tools/config/schema_app.json +++ b/tools/config/schema_app.json @@ -16,6 +16,9 @@ "macros": { "$ref": "definitions.json#/macro_definition" }, + "requires": { + "$ref": "definitions.json#/requires_definition" + }, "artifact_name": { "type": "string" } diff --git a/tools/config/schema_lib.json b/tools/config/schema_lib.json index b8556c961e..b4106c4952 100644 --- a/tools/config/schema_lib.json +++ b/tools/config/schema_lib.json @@ -13,6 +13,9 @@ "target_overrides": { "$ref": "definitions.json#/target_overrides_definition" }, + "requires": { + "$ref": "definitions.json#/requires_definition" + }, "macros": { "$ref": "definitions.json#/macro_definition" }