Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[projmgr] Add gpdsc project_files into *.cbuild.yml group files #1370

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
27 changes: 23 additions & 4 deletions tools/projmgr/src/ProjMgrWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2148,15 +2148,16 @@ bool ProjMgrWorker::ProcessGpdsc(ContextItem& context) {
}
bool validGpdsc;
RtePackage* gpdscPack = ProjMgrUtils::ReadGpdscFile(gpdscFile, validGpdsc);
const auto& contextGpdsc = context.gpdscs.at(gpdscFile);
if (!gpdscPack) {
ProjMgrLogger::Error(gpdscFile, "context '" + context.name + "' generator '" + context.gpdscs.at(gpdscFile).generator +
"' from component '" + context.gpdscs.at(gpdscFile).component + "': reading gpdsc failed");
ProjMgrLogger::Error(gpdscFile, "context '" + context.name + "' generator '" + contextGpdsc.generator +
"' from component '" + contextGpdsc.component + "': reading gpdsc failed");
CheckRteErrors();
return false;
} else {
if (!validGpdsc) {
ProjMgrLogger::Warn(gpdscFile, "context '" + context.name + "' generator '" + context.gpdscs.at(gpdscFile).generator +
"' from component '" + context.gpdscs.at(gpdscFile).component + "': gpdsc validation failed");
ProjMgrLogger::Warn(gpdscFile, "context '" + context.name + "' generator '" + contextGpdsc.generator +
"' from component '" + contextGpdsc.component + "': gpdsc validation failed");
}
info->SetGpdscPack(gpdscPack);
}
Expand All @@ -2179,6 +2180,24 @@ bool ProjMgrWorker::ProcessGpdsc(ContextItem& context) {
}
}
}
// gpdsc <project_files> section
const RteFileContainer* genFiles = info->GetProjectFiles();
if (genFiles) {
GroupNode group;
for (auto file : genFiles->GetChildren()) {
if (file->GetTag() == "file") {
FileNode fileNode;
string filename = file->GetOriginalAbsolutePath();
fileNode.file = RteFsUtils::RelativePath(filename, context.directories.cprj);
fileNode.category = file->GetAttribute("category");
group.files.push_back(fileNode);
}
}
if (!group.files.empty()) {
group.group = contextGpdsc.generator + " Common Sources";
context.groups.push_back(group);
}
}
}
if (!gpdscInfos.empty()) {
// Update target with gpdsc model
Expand Down
2 changes: 1 addition & 1 deletion tools/projmgr/src/ProjMgrYamlEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ void ProjMgrYamlCbuild::SetFilesNode(YAML::Node node, const ContextItem* context
for (const auto& file : files) {
YAML::Node fileNode;
SetNodeValue(fileNode[YAML_FILE], file.file);
SetNodeValue(fileNode[YAML_CATEGORY], RteFsUtils::FileCategoryFromExtension(file.file));
SetNodeValue(fileNode[YAML_CATEGORY], file.category.empty() ? RteFsUtils::FileCategoryFromExtension(file.file) : file.category);
SetControlsNode(fileNode, context, file.build);
node.push_back(fileNode);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<package xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" schemaVersion="1.0" xs:noNamespaceSchemaLocation="PACK.xsd">
<vendor>ARM</vendor>
<name>RteTestGenerator</name>
<description>RteTest generated pack description</description>
<url>project-path</url>
<releases>
<release version="1.0.0">
</release>
</releases>
<generators>
<generator id="RteTestGeneratorIdentifier" Gvendor="ARM" Gtool="RteTest Script" Gversion="1.0.0">
<description>RteTest Generator Test Environment</description>
<select Dname="RteTestGen_ARMCM0" Dvendor="ARM:82"/>
<command host="win">Generator/script.bat</command>
<workingDir>$PRTE/Device/RteTestGen_ARMCM0</workingDir>
<project_files>
<file category="source" name="Src/main.c"/>
<file category="header" name="Inc/device.h"/>
</project_files>
</generator>
</generators>
<conditions>
<condition id="RteTest">
<description>Condition to include RteTest core</description>
<require Dname="RteTestGen_ARMCM*"/>
<require Cclass="RteTest" Cgroup="CORE"/>
</condition>
</conditions>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
build:
generated-by: csolution version 0.0.0+g32c58528
solution: ../data/TestGenerator/test-gpdsc-project-files.csolution.yml
project: ../data/TestGenerator/test-gpdsc-project-files.cproject.yml
context: test-gpdsc-project-files.Debug+CM0
compiler: AC6
device: RteTestGen_ARMCM0
device-pack: ARM::[email protected]
processor:
core: Cortex-M0
packs:
- pack: ARM::[email protected]
path: ${CMSIS_PACK_ROOT}/ARM/RteTestGenerator/0.1.0
- pack: ARM::[email protected]
path: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0
define:
- _RTE_
add-path:
- ../data/TestGenerator/RTE/_Debug_CM0
output-dirs:
intdir: tmp/test-gpdsc-project-files/CM0/Debug
outdir: out/test-gpdsc-project-files/CM0/Debug
rtedir: ../data/TestGenerator/RTE
output:
- type: elf
file: test-gpdsc-project-files.axf
components:
- component: ARM::Device:RteTest Generated Component:[email protected]
condition: RteDevice
from-pack: ARM::[email protected]
selected-by: Device:RteTest Generated Component:RteTest
generator:
id: RteTestGeneratorIdentifier
from-pack: ARM::[email protected]
- component: ARM::RteTest:[email protected]
condition: Cortex-M Device
from-pack: ARM::[email protected]
selected-by: RteTest:CORE
generators:
- generator: RteTestGeneratorIdentifier
from-pack: ARM::[email protected]
path: ../data/TestGenerator/GpdscWithProjectFiles/RteTestGeneratorIdentifier
gpdsc: ../data/TestGenerator/GpdscWithProjectFiles/RteTestGeneratorIdentifier/RteTestGen_ARMCM0/RteTest.gpdsc
command:
win:
file: ${CMSIS_PACK_ROOT}/ARM/RteTestGenerator/0.1.0/Generator with spaces/script.bat
arguments:
- RteTestGen_ARMCM0
- ../../test-gpdsc-project-files.Debug+CM0.cprj
- ${CMSIS_PACK_ROOT}/ARM/RteTestGenerator/0.1.0
- ../../../../output/tmp/test-gpdsc-project-files/CM0/Debug/test-gpdsc-project-files.Debug+CM0.cbuild-gen.yml
- /foo=bar
linux:
file: ${CMSIS_PACK_ROOT}/ARM/RteTestGenerator/0.1.0/Generator with spaces/script.sh
arguments:
- RteTestGen_ARMCM0
- ../../test-gpdsc-project-files.Debug+CM0.cprj
- ${CMSIS_PACK_ROOT}/ARM/RteTestGenerator/0.1.0
- ../../../../output/tmp/test-gpdsc-project-files/CM0/Debug/test-gpdsc-project-files.Debug+CM0.cbuild-gen.yml
- --foo=bar
mac:
file: ${CMSIS_PACK_ROOT}/ARM/RteTestGenerator/0.1.0/Generator with spaces/script.sh
arguments:
- RteTestGen_ARMCM0
- ../../test-gpdsc-project-files.Debug+CM0.cprj
- ${CMSIS_PACK_ROOT}/ARM/RteTestGenerator/0.1.0
- ../../../../output/tmp/test-gpdsc-project-files/CM0/Debug/test-gpdsc-project-files.Debug+CM0.cbuild-gen.yml
- --foo=bar
linker:
script: ../data/TestGenerator/RTE/Device/RteTestGen_ARMCM0/ac6_linker_script.sct.src
regions: ../data/TestGenerator/RTE/Device/RteTestGen_ARMCM0/regions_RteTestGen_ARMCM0.h
groups:
- group: RteTestGeneratorIdentifier Common Sources
files:
- file: ../data/TestGenerator/GpdscWithProjectFiles/RteTestGeneratorIdentifier/RteTestGen_ARMCM0/Src/main.c
category: source
- file: ../data/TestGenerator/GpdscWithProjectFiles/RteTestGeneratorIdentifier/RteTestGen_ARMCM0/Inc/device.h
category: header
constructed-files:
- file: ../data/TestGenerator/RTE/_Debug_CM0/RTE_Components.h
category: header
licenses:
- license: <unknown>
packs:
- pack: ARM::[email protected]
components:
- component: ARM::Device:RteTest Generated Component:[email protected]
- license: <unknown>
license-agreement: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Doc/license.txt
packs:
- pack: ARM::[email protected]
components:
- component: ::RteTest:CORE(API)
- component: ARM::RteTest:[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/cproject.schema.json

project:
components:
- component: Device:RteTest Generated Component:RteTest
- component: RteTest:CORE
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/csolution.schema.json

solution:
target-types:
- type: CM0
device: RteTestGen_ARMCM0

build-types:
- type: Debug
compiler: AC6

projects:
- project: ./test-gpdsc-project-files.cproject.yml

generators:
base-dir: GpdscWithProjectFiles
15 changes: 15 additions & 0 deletions tools/projmgr/test/src/ProjMgrUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5167,6 +5167,21 @@ TEST_F(ProjMgrUnitTests, RunProjMgr_GpdscWithoutComponents) {
EXPECT_EQ(0, RunProjMgr(6, argv, 0));
}

TEST_F(ProjMgrUnitTests, RunProjMgr_GpdscWithProjectFiles) {
char* argv[7];
const string& csolution = testinput_folder + "/TestGenerator/test-gpdsc-project-files.csolution.yml";
argv[1] = (char*)"convert";
argv[2] = (char*)"--solution";
argv[3] = (char*)csolution.c_str();
argv[4] = (char*)"-o";
argv[5] = (char*)testoutput_folder.c_str();
EXPECT_EQ(0, RunProjMgr(6, argv, 0));

// Check generated cbuild YML
ProjMgrTestEnv::CompareFile(testoutput_folder + "/test-gpdsc-project-files.Debug+CM0.cbuild.yml",
testinput_folder + "/TestGenerator/ref/test-gpdsc-project-files.Debug+CM0.cbuild.yml");
}

TEST_F(ProjMgrUnitTests, RunProjMgr_ValidateContextSpecificPacksMissing) {
char* argv[4];
StdStreamRedirect streamRedirect;
Expand Down
Loading