Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tools/projmgr/include/ProjMgrParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ struct CsolutionItem {
std::string directory;
std::string createdFor;
DirectoriesItem directories;
std::vector<std::string> compilerAlias;
std::vector<std::string> selectableCompilers;
BuildTypes buildTypes;
TargetTypes targetTypes;
Expand Down
1 change: 1 addition & 0 deletions tools/projmgr/include/ProjMgrWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ struct ContextItem {
StrVec unusedPacks;
std::vector<std::pair<ComponentItem, std::string>> componentRequirements;
std::string compiler;
std::vector<std::string> compilerAlias;
ToolchainItem toolchain;
std::map<std::string, std::string> targetAttributes;
std::map<std::string, RtePackage*> packages;
Expand Down
1 change: 1 addition & 0 deletions tools/projmgr/include/ProjMgrYamlParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
19 changes: 18 additions & 1 deletion tools/projmgr/schemas/common.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1187,7 +1203,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/CompilerAliasesType" },
"created-by": {
"title": "created-by:\nDocumentation: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-Input-Format/#solution",
"$ref": "#/definitions/CreatedInfoType",
Expand Down
13 changes: 13 additions & 0 deletions tools/projmgr/src/ProjMgrWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1944,6 +1945,18 @@ bool ProjMgrWorker::ProcessToolchain(ContextItem& context) {
} else {
context.targetAttributes["Tcompiler"] = context.toolchain.name;
}

// compiler alias
set<string> 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;
}
}
Comment thread
brondani marked this conversation as resolved.
return true;
}

Expand Down
2 changes: 2 additions & 0 deletions tools/projmgr/src/ProjMgrYamlParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -1227,6 +1228,7 @@ const set<string> solutionKeys = {
YAML_PACKS,
YAML_PROCESSOR,
YAML_COMPILER,
YAML_COMPILER_ALIAS,
YAML_SELECT_COMPILER,
YAML_OPTIMIZE,
YAML_DEBUG,
Expand Down
1 change: 1 addition & 0 deletions tools/projmgr/test/data/TestSolution/test.csolution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

solution:
description: test description string
compiler-alias: CLANG
target-types:
- type: CM0
device: RteTest_ARMCM0
Expand Down
16 changes: 16 additions & 0 deletions tools/projmgr/test/src/ProjMgrWorkerUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, ContextItem>* contexts;
GetContexts(contexts);
ContextItem context = contexts->begin()->second;
EXPECT_EQ(context.compilerAlias, (vector<string>{ "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) {
Expand Down Expand Up @@ -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<string, string> expected = {
{"Dclock", "10000000"},
Expand Down
18 changes: 18 additions & 0 deletions tools/projmgr/test/src/ProjMgrYamlParserUnitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> 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);
Expand Down
Loading