From 418dda84ed97fdfd1aa555372244ac4aa2efc8d9 Mon Sep 17 00:00:00 2001 From: Daniel Brondani Date: Tue, 18 Aug 2026 16:21:07 +0200 Subject: [PATCH 1/2] Add compiler aliases to solution toolchain configuration Parse and validate compiler-alias entries from csolution files, then propagate them to contexts and Tcompiler attributes --- tools/projmgr/include/ProjMgrParser.h | 1 + tools/projmgr/include/ProjMgrWorker.h | 1 + tools/projmgr/include/ProjMgrYamlParser.h | 1 + tools/projmgr/schemas/common.schema.json | 3 ++- tools/projmgr/src/ProjMgrWorker.cpp | 13 +++++++++++++ tools/projmgr/src/ProjMgrYamlParser.cpp | 2 ++ .../test/data/TestSolution/test.csolution.yml | 1 + .../test/src/ProjMgrWorkerUnitTests.cpp | 16 ++++++++++++++++ .../test/src/ProjMgrYamlParserUnitTest.cpp | 18 ++++++++++++++++++ 9 files changed, 55 insertions(+), 1 deletion(-) diff --git a/tools/projmgr/include/ProjMgrParser.h b/tools/projmgr/include/ProjMgrParser.h index 7e1feaa7d..e8a2acaa5 100644 --- a/tools/projmgr/include/ProjMgrParser.h +++ b/tools/projmgr/include/ProjMgrParser.h @@ -642,6 +642,7 @@ struct CsolutionItem { std::string directory; std::string createdFor; DirectoriesItem directories; + std::vector compilerAlias; std::vector selectableCompilers; BuildTypes buildTypes; TargetTypes targetTypes; diff --git a/tools/projmgr/include/ProjMgrWorker.h b/tools/projmgr/include/ProjMgrWorker.h index 7a914dc75..cfd739728 100644 --- a/tools/projmgr/include/ProjMgrWorker.h +++ b/tools/projmgr/include/ProjMgrWorker.h @@ -541,6 +541,7 @@ struct ContextItem { StrVec unusedPacks; std::vector> componentRequirements; std::string compiler; + std::vector compilerAlias; ToolchainItem toolchain; std::map targetAttributes; std::map packages; diff --git a/tools/projmgr/include/ProjMgrYamlParser.h b/tools/projmgr/include/ProjMgrYamlParser.h index a2ab3abb3..1682357c9 100644 --- a/tools/projmgr/include/ProjMgrYamlParser.h +++ b/tools/projmgr/include/ProjMgrYamlParser.h @@ -72,6 +72,7 @@ static constexpr const char* YAML_CURRENT_GENERATOR = "current-generator"; static constexpr const char* YAML_CONSUMES = "consumes"; static constexpr const char* YAML_COMMAND = "command"; static constexpr const char* YAML_COMPILER = "compiler"; +static constexpr const char* YAML_COMPILER_ALIAS = "compiler-alias"; static constexpr const char* YAML_COMPONENT = "component"; static constexpr const char* YAML_COMPONENTS = "components"; static constexpr const char* YAML_CONDITION = "condition"; diff --git a/tools/projmgr/schemas/common.schema.json b/tools/projmgr/schemas/common.schema.json index 123d81ef7..6a65563da 100644 --- a/tools/projmgr/schemas/common.schema.json +++ b/tools/projmgr/schemas/common.schema.json @@ -1187,7 +1187,8 @@ "type": "null", "description": "Enables use of cdefault.yml file for compiler controls." }, - "compiler": { "$ref": "#/definitions/CompilerType" }, + "compiler": { "$ref": "#/definitions/CompilerType" }, + "compiler-alias": { "$ref": "#/definitions/CompilersType" }, "created-by": { "title": "created-by:\nDocumentation: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-Input-Format/#solution", "$ref": "#/definitions/CreatedInfoType", diff --git a/tools/projmgr/src/ProjMgrWorker.cpp b/tools/projmgr/src/ProjMgrWorker.cpp index d060f2fed..d9c3361a8 100644 --- a/tools/projmgr/src/ProjMgrWorker.cpp +++ b/tools/projmgr/src/ProjMgrWorker.cpp @@ -178,6 +178,7 @@ void ProjMgrWorker::AddContext(ContextDesc& descriptor, const TypePair& type, Co const string& buildType = (!type.build.empty() ? "." : "") + type.build; const string& targetType = (!type.target.empty() ? "+" : "") + type.target; context.name = context.cproject->name + buildType + targetType; + context.compilerAlias = context.csolution->compilerAlias; context.precedences = false; // default directories @@ -1944,6 +1945,18 @@ bool ProjMgrWorker::ProcessToolchain(ContextItem& context) { } else { context.targetAttributes["Tcompiler"] = context.toolchain.name; } + + // compiler alias + set compilers = { context.targetAttributes["Tcompiler"] }; + for (const auto& compilerAlias : context.compilerAlias) { + const string canonicalAlias = compilerAlias == "AC6" ? "ARMCC" : compilerAlias; + if (compilers.insert(canonicalAlias).second) { + context.targetAttributes["Tcompiler"] += '|' + canonicalAlias; + } + if (compilerAlias == "AC6") { + context.targetAttributes["Toptions"] = compilerAlias; + } + } return true; } diff --git a/tools/projmgr/src/ProjMgrYamlParser.cpp b/tools/projmgr/src/ProjMgrYamlParser.cpp index 14237e430..0488cc1f2 100644 --- a/tools/projmgr/src/ProjMgrYamlParser.cpp +++ b/tools/projmgr/src/ProjMgrYamlParser.cpp @@ -86,6 +86,7 @@ bool ProjMgrYamlParser::ParseCsolution(const string& input, const YAML::Node& solutionNode = root[YAML_SOLUTION]; ParseString(solutionNode, YAML_DESCRIPTION, csolution.description); ParseString(solutionNode, YAML_CREATED_FOR, csolution.createdFor); + ParseVectorOrString(solutionNode, YAML_COMPILER_ALIAS, csolution.compilerAlias); if (!ParseContexts(solutionNode, csolution)) { return false; } @@ -1227,6 +1228,7 @@ const set solutionKeys = { YAML_PACKS, YAML_PROCESSOR, YAML_COMPILER, + YAML_COMPILER_ALIAS, YAML_SELECT_COMPILER, YAML_OPTIMIZE, YAML_DEBUG, diff --git a/tools/projmgr/test/data/TestSolution/test.csolution.yml b/tools/projmgr/test/data/TestSolution/test.csolution.yml index db6d60188..ace2908bc 100644 --- a/tools/projmgr/test/data/TestSolution/test.csolution.yml +++ b/tools/projmgr/test/data/TestSolution/test.csolution.yml @@ -2,6 +2,7 @@ solution: description: test description string + compiler-alias: CLANG target-types: - type: CM0 device: RteTest_ARMCM0 diff --git a/tools/projmgr/test/src/ProjMgrWorkerUnitTests.cpp b/tools/projmgr/test/src/ProjMgrWorkerUnitTests.cpp index 1616e2f7f..9ee7f6006 100644 --- a/tools/projmgr/test/src/ProjMgrWorkerUnitTests.cpp +++ b/tools/projmgr/test/src/ProjMgrWorkerUnitTests.cpp @@ -51,14 +51,18 @@ TEST_F(ProjMgrWorkerUnitTests, ProcessToolchain) { ContextDesc descriptor; const string& filename = testinput_folder + "/TestProject/test.cproject.yml"; EXPECT_TRUE(parser.ParseCproject(filename, true)); + parser.GetCsolution().compilerAlias = { "AC6", "CLANG" }; EXPECT_TRUE(AddContexts(parser, descriptor, filename)); map* contexts; GetContexts(contexts); ContextItem context = contexts->begin()->second; + EXPECT_EQ(context.compilerAlias, (vector{ "AC6", "CLANG" })); EXPECT_TRUE(ProcessPrecedences(context)); EXPECT_TRUE(ProcessToolchain(context)); EXPECT_EQ(expected.name, context.toolchain.name); EXPECT_EQ(expected.version, context.toolchain.version); + EXPECT_EQ(context.targetAttributes["Tcompiler"], "ARMCC|CLANG"); + EXPECT_EQ(context.targetAttributes["Toptions"], "AC6"); } TEST_F(ProjMgrWorkerUnitTests, ProcessToolchainNoToolchainRegistered) { @@ -114,6 +118,18 @@ TEST_F(ProjMgrWorkerUnitTests, ProcessToolchainOptions) { } } +TEST_F(ProjMgrWorkerUnitTests, ProcessToolchainDeduplicatesCanonicalAliases) { + ContextItem context; + CsolutionItem csolution; + context.csolution = &csolution; + context.compiler = "AC6"; + context.compilerAlias = { "ARMCC", "AC6", "CLANG", "CLANG" }; + + EXPECT_TRUE(ProcessToolchain(context)); + EXPECT_EQ(context.targetAttributes["Tcompiler"], "ARMCC|CLANG"); + EXPECT_EQ(context.targetAttributes["Toptions"], "AC6"); +} + TEST_F(ProjMgrWorkerUnitTests, ProcessDevice) { map expected = { {"Dclock", "10000000"}, diff --git a/tools/projmgr/test/src/ProjMgrYamlParserUnitTest.cpp b/tools/projmgr/test/src/ProjMgrYamlParserUnitTest.cpp index 6a407d388..41c703105 100644 --- a/tools/projmgr/test/src/ProjMgrYamlParserUnitTest.cpp +++ b/tools/projmgr/test/src/ProjMgrYamlParserUnitTest.cpp @@ -33,6 +33,24 @@ TEST_F(ProjMgrYamlParserUnitTests, ParseCbuildSet) { EXPECT_FALSE(ParseCbuildSet("unkownfile.cbuild-set.yml", buildSetItem, true)); } +TEST_F(ProjMgrYamlParserUnitTests, ParseCompilerAlias) { + const string csolutionFile = testinput_folder + "/TestSolution/test.csolution.yml"; + CsolutionItem csolution; + + EXPECT_TRUE(ParseCsolution(csolutionFile, csolution, true, false)); + ASSERT_EQ(csolution.compilerAlias.size(), 1); + EXPECT_EQ(csolution.compilerAlias.front(), "CLANG"); + + YAML::Node solutionNode; + solutionNode[YAML_COMPILER_ALIAS].push_back("AC6"); + solutionNode[YAML_COMPILER_ALIAS].push_back("GCC"); + vector compilerAliases; + ParseVectorOrString(solutionNode, YAML_COMPILER_ALIAS, compilerAliases); + ASSERT_EQ(compilerAliases.size(), 2); + EXPECT_EQ(compilerAliases[0], "AC6"); + EXPECT_EQ(compilerAliases[1], "GCC"); +} + TEST_F(ProjMgrYamlParserUnitTests, ValidateCbuildSet) { string cbuildSetFile = testinput_folder + "/TestSolution/invalid_keys_test.cbuild-set.yml"; YAML::Node root = YAML::LoadFile(cbuildSetFile); From cfcab1156d5e94e6527270d4a18ad15c1efdc1c5 Mon Sep 17 00:00:00 2001 From: Daniel Brondani Date: Tue, 18 Aug 2026 17:12:00 +0200 Subject: [PATCH 2/2] Restrict the schema to disallow versions for compiler-alias --- tools/projmgr/schemas/common.schema.json | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tools/projmgr/schemas/common.schema.json b/tools/projmgr/schemas/common.schema.json index 6a65563da..eac3b9572 100644 --- a/tools/projmgr/schemas/common.schema.json +++ b/tools/projmgr/schemas/common.schema.json @@ -190,6 +190,10 @@ "pattern": "^(GCC|CLANG|AC6|IAR|CLANG_TI|XC)(@(>=)?([0-9]+\\.[0-9]+\\.[0-9]+((\\+|\\-)[a-zA-Z0-9_\\.\\+-]+)?))?$", "description": "Compiler toolchain to be used, optionally with version, for example AC6@6.23.0." }, + "CompilerAliasType": { + "type": "string", + "pattern": "^(GCC|CLANG|AC6|IAR|CLANG_TI|XC)$" + }, "ConsumesProvidesType": { "oneOf": [ {"type": "string" }, @@ -222,6 +226,18 @@ ], "description": "Include node for a list of compilers." }, + "CompilerAliasesType": { + "oneOf": [ + { + "type": "array", + "uniqueItems": true, + "minItems": 1, + "items": { "$ref": "#/definitions/CompilerAliasType" } + }, + { "$ref": "#/definitions/CompilerAliasType" } + ], + "description": "List of compiler aliases." + }, "ArrayOfBuildContextWithProjectName": { "type": "array", "uniqueItems": true, @@ -1188,7 +1204,7 @@ "description": "Enables use of cdefault.yml file for compiler controls." }, "compiler": { "$ref": "#/definitions/CompilerType" }, - "compiler-alias": { "$ref": "#/definitions/CompilersType" }, + "compiler-alias": { "$ref": "#/definitions/CompilerAliasesType" }, "created-by": { "title": "created-by:\nDocumentation: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-Input-Format/#solution", "$ref": "#/definitions/CreatedInfoType",