Skip to content

Commit

Permalink
[projmgr] Add apis section
Browse files Browse the repository at this point in the history
  • Loading branch information
grasci-arm authored Sep 12, 2024
1 parent a9e3834 commit ca002ac
Show file tree
Hide file tree
Showing 56 changed files with 521 additions and 74 deletions.
1 change: 1 addition & 0 deletions test/packs/ARM/RteTest/0.1.0/API/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// index.html
1 change: 1 addition & 0 deletions test/packs/ARM/RteTest/0.1.0/ARM.RteTest.pdsc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
<description>RteTest Test API 2.0.0</description>
<files>
<file category="header" name="API/IConfig.h"/>
<file category="doc" name="API/index.html"/>
</files>
</api>
</apis>
Expand Down
2 changes: 2 additions & 0 deletions tools/projmgr/include/ProjMgrWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,14 @@ struct ContextItem {
std::map<std::string, std::string> targetAttributes;
std::map<std::string, RtePackage*> packages;
std::map<std::string, SelectedComponentItem> components;
std::map<RteApi*, std::vector<std::string>> apis;
std::map<std::string, SelectedComponentItem> bootstrapComponents;
StrMap bootstrapMap;
std::vector<std::tuple<RteItem::ConditionResult, std::string, std::set<std::string>, std::set<std::string>>> validationResults;
std::map<std::string, std::map<std::string, RteFileInstance*>> configFiles;
std::map<std::string, std::string> plmStatus;
std::map<std::string, std::vector<ComponentFileItem>> componentFiles;
std::map<std::string, std::vector<ComponentFileItem>> apiFiles;
std::map<std::string, std::vector<ComponentFileItem>> generatorInputFiles;
std::vector<GroupNode> groups;
std::map<std::string, RteGenerator*> generators;
Expand Down
4 changes: 4 additions & 0 deletions tools/projmgr/include/ProjMgrYamlParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
/**
* @brief YAML key definitions
*/
static constexpr const char* YAML_APIS = "apis";
static constexpr const char* YAML_API = "api";
static constexpr const char* YAML_ADDPATH = "add-path";
static constexpr const char* YAML_ADDPATH_ASM = "add-path-asm";
static constexpr const char* YAML_ALWAYS = "always";
Expand Down Expand Up @@ -95,6 +97,8 @@ static constexpr const char* YAML_GROUP = "group";
static constexpr const char* YAML_GROUPS = "groups";
static constexpr const char* YAML_HOST = "host";
static constexpr const char* YAML_ID = "id";
static constexpr const char* YAML_IMPLEMENTED_BY = "implemented-by";
static constexpr const char* YAML_IMPLEMENTS = "implements";
static constexpr const char* YAML_INFO = "info";
static constexpr const char* YAML_INPUT = "input";
static constexpr const char* YAML_INSTANCES = "instances";
Expand Down
26 changes: 26 additions & 0 deletions tools/projmgr/schemas/common.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,7 @@
"output-dirs": { "$ref": "#/definitions/BuildOutputDirectoriesType" },
"output": { "$ref": "#/definitions/OutputFilesType" },
"components": { "$ref": "#/definitions/ResolvedComponentsType" },
"apis": { "$ref": "#/definitions/ResolvedApisType" },
"linker": { "$ref": "#/definitions/LinkerType" },
"groups": { "$ref": "#/definitions/BuildGroupsType" },
"generators": { "$ref": "#/definitions/GeneratorsType" },
Expand Down Expand Up @@ -1273,6 +1274,7 @@
"component": { "$ref": "#/definitions/ComponentID" },
"condition": { "$ref": "#/definitions/ConditionIDType" },
"selected-by": { "$ref": "#/definitions/ComponentID" },
"implements": { "$ref": "#/definitions/ComponentID" },
"rtedir": { "type": "string" },
"optimize": { "$ref": "#/definitions/OptimizeType" },
"debug": { "$ref": "#/definitions/DebugType" },
Expand All @@ -1293,6 +1295,30 @@
},
"additionalProperties": false
},
"ResolvedApisType": {
"type": "array",
"description": "List of API in their resolved state",
"uniqueItems": true,
"items": { "$ref": "#/definitions/ResolvedApiType" }
},
"ResolvedApiType": {
"type": "object",
"description": "API in its resolved state",
"properties": {
"api": { "$ref": "#/definitions/ComponentID" },
"condition": { "$ref": "#/definitions/ConditionIDType" },
"implemented-by": { "$ref": "#/definitions/ImplementedByType" },
"files": { "$ref": "#/definitions/FilesType" },
"from-pack": { "$ref": "#/definitions/PackID" }
},
"additionalProperties": false
},
"ImplementedByType": {
"oneOf": [
{ "type": "array", "items": { "$ref": "#/definitions/ComponentID" } },
{ "$ref": "#/definitions/ComponentID" }
]
},
"SetupsType": {
"type": "array",
"description": "List of setup nodes that collects various toolchain options",
Expand Down
14 changes: 7 additions & 7 deletions tools/projmgr/src/ProjMgrUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,26 +387,26 @@ bool ProjMgrUtils::HasAccessSequence(const string value) {
}

const string ProjMgrUtils::FormatPath(const string& original, const string& directory, bool useAbsolutePaths) {
string packRoot = ProjMgrKernel::Get()->GetCmsisPackRoot();
if (original.find("http") == 0) {
return original;
}
string path = original;
RteFsUtils::NormalizePath(path);
path = RteFsUtils::MakePathCanonical(path);
if (!useAbsolutePaths) {
string packRoot = ProjMgrKernel::Get()->GetCmsisPackRoot();
size_t index = path.find(packRoot);
if (index != string::npos) {
path.replace(index, packRoot.length(), "${CMSIS_PACK_ROOT}");
}
else {
} else {
string compilerRoot;
ProjMgrUtils::GetCompilerRoot(compilerRoot);
index = path.find(compilerRoot);
if (!compilerRoot.empty() && index != string::npos) {
path.replace(index, compilerRoot.length(), "${CMSIS_COMPILER_ROOT}");
}
else {
} else {
error_code ec;
const string relative = fs::relative(path, directory, ec).generic_string();
if (!relative.empty()) {
if (!relative.empty() && path == fs::path(directory).append(relative).lexically_normal().generic_string()) {
path = relative;
}
}
Expand Down
23 changes: 16 additions & 7 deletions tools/projmgr/src/ProjMgrWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2191,12 +2191,20 @@ bool ProjMgrWorker::ProcessComponentFiles(ContextItem& context) {
// component based API files
const auto& api = rteComponent->GetApi(context.rteActiveTarget, true);
if (api) {
const auto& apiFiles = api->GetFileContainer() ? api->GetFileContainer()->GetChildren() : Collection<RteItem*>();
for (const auto& apiFile : apiFiles) {
const auto& name = api->GetPackage()->GetAbsolutePackagePath() + apiFile->GetAttribute("name");
const auto& category = apiFile->GetAttribute("category");
if (category == "header") {
context.componentFiles[componentId].push_back({ name, "", "api" });
context.apis[api].push_back(componentId);
if (context.apis[api].size() == 1) {
const auto& apiId = api->ConstructComponentID(true);
const auto& apiFiles = api->GetFileContainer() ? api->GetFileContainer()->GetChildren() : Collection<RteItem*>();
for (const auto& apiFile : apiFiles) {
const auto& attr = apiFile->GetAttribute("attr");
const auto& category = apiFile->GetAttribute("category");
const auto& name = category == "doc" ? apiFile->GetDocFile() :
api->GetPackage()->GetAbsolutePackagePath() + apiFile->GetAttribute("name");
const auto& scope = apiFile->GetAttribute("scope");
const auto& language = apiFile->GetAttribute("language");
const auto& select = apiFile->GetAttribute("select");
const auto& version = apiFile->GetVersionString();
context.apiFiles[apiId].push_back({ name, attr, category, language, scope, version, select });
}
}
}
Expand All @@ -2212,8 +2220,9 @@ bool ProjMgrWorker::ProcessComponentFiles(ContextItem& context) {
if (attr == "config") {
continue;
}
const auto& name = rteComponent->GetPackage()->GetAbsolutePackagePath() + componentFile->GetAttribute("name");
const auto& category = componentFile->GetAttribute("category");
const auto& name = category == "doc" ? componentFile->GetDocFile() :
rteComponent->GetPackage()->GetAbsolutePackagePath() + componentFile->GetAttribute("name");
const auto& scope = componentFile->GetAttribute("scope");
const auto& language = componentFile->GetAttribute("language");
const auto& select = componentFile->GetAttribute("select");
Expand Down
57 changes: 41 additions & 16 deletions tools/projmgr/src/ProjMgrYamlEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ class ProjMgrYamlCbuild : public ProjMgrYamlBase {
void SetContextNode(YAML::Node node, const ContextItem* context, const string& generatorId, const string& generatorPack);
void SetComponentsNode(YAML::Node node, const ContextItem* context);
void SetComponentFilesNode(YAML::Node node, const ContextItem* context, const string& componentId);
void SetApisNode(YAML::Node node, const ContextItem* context);
void SetGeneratorsNode(YAML::Node node, const ContextItem* context);
void SetGeneratorFiles(YAML::Node node, const ContextItem* context, const string& componentId);
void SetFiles(YAML::Node node, const std::vector<ComponentFileItem>& files, const std::string& dir);
void SetConstructedFilesNode(YAML::Node node, const ContextItem* context);
void SetOutputDirsNode(YAML::Node node, const ContextItem* context);
void SetOutputNode(YAML::Node node, const ContextItem* context);
Expand Down Expand Up @@ -485,6 +486,7 @@ void ProjMgrYamlCbuild::SetContextNode(YAML::Node contextNode, const ContextItem
SetOutputDirsNode(contextNode[YAML_OUTPUTDIRS], context);
SetOutputNode(contextNode[YAML_OUTPUT], context);
SetComponentsNode(contextNode[YAML_COMPONENTS], context);
SetApisNode(contextNode[YAML_APIS], context);
SetGeneratorsNode(contextNode[YAML_GENERATORS], context);
SetLinkerNode(contextNode[YAML_LINKER], context);
SetGroupsNode(contextNode[YAML_GROUPS], context, context->groups);
Expand All @@ -504,6 +506,10 @@ void ProjMgrYamlCbuild::SetComponentsNode(YAML::Node node, const ContextItem* co
SetNodeValue(componentNode[YAML_CONDITION], rteComponent->GetConditionID());
SetNodeValue(componentNode[YAML_FROM_PACK], rteComponent->GetPackageID());
SetNodeValue(componentNode[YAML_SELECTED_BY], componentItem->component);
const auto& api = rteComponent->GetApi(context->rteActiveTarget, true);
if (api) {
SetNodeValue(componentNode[YAML_IMPLEMENTS], api->ConstructComponentID(true));
}
const string& rteDir = rteComponent->GetAttribute("rtedir");
if (!rteDir.empty()) {
SetNodeValue(componentNode[YAML_OUTPUT_RTEDIR], FormatPath(context->cproject->directory + "/" + rteDir, context->directories.cbuild));
Expand All @@ -515,7 +521,9 @@ void ProjMgrYamlCbuild::SetComponentsNode(YAML::Node node, const ContextItem* co
const RteGenerator* rteGenerator = get_or_null(context->generators, component.generator);
if(rteGenerator && !rteGenerator->IsExternal()) {
SetNodeValue(componentNode[YAML_GENERATOR][YAML_FROM_PACK], rteGenerator->GetPackageID());
SetGeneratorFiles(componentNode[YAML_GENERATOR], context, componentId);
if (context->generatorInputFiles.find(componentId) != context->generatorInputFiles.end()) {
SetFiles(componentNode[YAML_GENERATOR], context->generatorInputFiles.at(componentId), context->directories.cbuild);
}
} else if (contains_key(context->extGen, component.generator)) {
SetNodeValue(componentNode[YAML_GENERATOR][YAML_PATH],
FormatPath(fs::path(context->extGen.at(component.generator).name).generic_string(),
Expand Down Expand Up @@ -583,22 +591,39 @@ void ProjMgrYamlCbuild::SetComponentFilesNode(YAML::Node node, const ContextItem
}
}

void ProjMgrYamlCbuild::SetGeneratorFiles(YAML::Node node, const ContextItem* context, const string& componentId) {
if (context->generatorInputFiles.find(componentId) != context->generatorInputFiles.end()) {
YAML::Node filesNode;
for (const auto& [file, attr, category, language, scope, version, select] : context->generatorInputFiles.at(componentId)) {
YAML::Node fileNode;
SetNodeValue(fileNode[YAML_FILE], FormatPath(file, context->directories.cbuild));
SetNodeValue(fileNode[YAML_CATEGORY], category);
SetNodeValue(fileNode[YAML_ATTR], attr);
SetNodeValue(fileNode[YAML_LANGUAGE], language);
SetNodeValue(fileNode[YAML_SCOPE], scope);
SetNodeValue(fileNode[YAML_VERSION], version);
SetNodeValue(fileNode[YAML_SELECT], select);
filesNode.push_back(fileNode);
void ProjMgrYamlCbuild::SetApisNode(YAML::Node node, const ContextItem* context) {
for (const auto& [api, componentIds] : context->apis) {
YAML::Node apiNode;
const auto& apiId = api->ConstructComponentID(true);
SetNodeValue(apiNode[YAML_API], apiId);
SetNodeValue(apiNode[YAML_CONDITION], api->GetConditionID());
SetNodeValue(apiNode[YAML_FROM_PACK], api->GetPackageID());
if (componentIds.size() == 1) {
SetNodeValue(apiNode[YAML_IMPLEMENTED_BY], componentIds.front());
} else {
SetNodeValue(apiNode[YAML_IMPLEMENTED_BY], componentIds);
}
if (context->apiFiles.find(apiId) != context->apiFiles.end()) {
SetFiles(apiNode, context->apiFiles.at(apiId), context->directories.cbuild);
}
node[YAML_FILES] = filesNode;
node.push_back(apiNode);
}
}

void ProjMgrYamlCbuild::SetFiles(YAML::Node node, const std::vector<ComponentFileItem>& files, const std::string& dir) {
YAML::Node filesNode;
for (const auto& [file, attr, category, language, scope, version, select] : files) {
YAML::Node fileNode;
SetNodeValue(fileNode[YAML_FILE], FormatPath(file, dir));
SetNodeValue(fileNode[YAML_CATEGORY], category);
SetNodeValue(fileNode[YAML_ATTR], attr);
SetNodeValue(fileNode[YAML_LANGUAGE], language);
SetNodeValue(fileNode[YAML_SCOPE], scope);
SetNodeValue(fileNode[YAML_VERSION], version);
SetNodeValue(fileNode[YAML_SELECT], select);
filesNode.push_back(fileNode);
}
node[YAML_FILES] = filesNode;
}

void ProjMgrYamlCbuild::SetGeneratorsNode(YAML::Node node, const ContextItem* context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,19 @@ build:
condition: Cortex-M Device
from-pack: ARM::RteTest_DFP@0.1.1
selected-by: CORE
implements: RteTest:CORE@1.1.1
files:
- file: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.1.1/Doc/html/index.html
category: doc
version: 0.1.1
apis:
- api: RteTest:CORE@1.1.1
from-pack: ARM::RteTest_DFP@0.1.1
implemented-by: ARM::RteTest:CORE@0.1.1
files:
- file: https://arm-software.github.io/CMSIS_5/Pack/html/pdsc_apis_pg.html
category: doc
version: 1.1.1
linker:
script: ../data/TestAccessSequences/RTE/Device/RteTest_ARMCM4_FP/ac6_linker_script.sct.src
regions: ../data/TestAccessSequences/RTE/Device/RteTest_ARMCM4_FP/regions_RteTest_CM4_board.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,19 @@ build:
condition: Cortex-M Device
from-pack: ARM::RteTest_DFP@0.1.1
selected-by: CORE
implements: RteTest:CORE@1.1.1
files:
- file: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.1.1/Doc/html/index.html
category: doc
version: 0.1.1
apis:
- api: RteTest:CORE@1.1.1
from-pack: ARM::RteTest_DFP@0.1.1
implemented-by: ARM::RteTest:CORE@0.1.1
files:
- file: https://arm-software.github.io/CMSIS_5/Pack/html/pdsc_apis_pg.html
category: doc
version: 1.1.1
linker:
script: ../../data/TestDefault/RTE/Device/RteTest_ARMCM0/gcc_linker_script.ld.src
regions: ../../data/TestDefault/RTE/Device/RteTest_ARMCM0/regions_RteTest_ARMCM0.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,19 @@ build:
condition: Cortex-M Device
from-pack: ARM::RteTest_DFP@0.1.1
selected-by: CORE
implements: RteTest:CORE@1.1.1
files:
- file: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.1.1/Doc/html/index.html
category: doc
version: 0.1.1
apis:
- api: RteTest:CORE@1.1.1
from-pack: ARM::RteTest_DFP@0.1.1
implemented-by: ARM::RteTest:CORE@0.1.1
files:
- file: https://arm-software.github.io/CMSIS_5/Pack/html/pdsc_apis_pg.html
category: doc
version: 1.1.1
linker:
script: ../../data/TestDefault/RTE/Device/RteTest_ARMCM0/gcc_linker_script.ld.src
regions: ../../data/TestDefault/RTE/Device/RteTest_ARMCM0/regions_RteTest_ARMCM0.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,19 @@ build:
condition: Cortex-M Device
from-pack: ARM::RteTest_DFP@0.2.0
selected-by: RteTest:CORE
implements: RteTest:CORE@1.1.2
files:
- file: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Doc/html/index.html
category: doc
version: 0.1.1
apis:
- api: RteTest:CORE@1.1.2
from-pack: ARM::RteTest_DFP@0.2.0
implemented-by: ARM::RteTest:CORE@0.1.1
files:
- file: https://arm-software.github.io/CMSIS_5/Pack/html/pdsc_apis_pg.html
category: doc
version: 1.1.2
generators:
- generator: RteTestGeneratorIdentifier
from-pack: ARM::RteTestGenerator@0.1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,19 @@ build:
condition: Cortex-M Device
from-pack: ARM::RteTest_DFP@0.2.0
selected-by: RteTest:CORE
implements: RteTest:CORE@1.1.2
files:
- file: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Doc/html/index.html
category: doc
version: 0.1.1
apis:
- api: RteTest:CORE@1.1.2
from-pack: ARM::RteTest_DFP@0.2.0
implemented-by: ARM::RteTest:CORE@0.1.1
files:
- file: https://arm-software.github.io/CMSIS_5/Pack/html/pdsc_apis_pg.html
category: doc
version: 1.1.2
generators:
- generator: RteTestGeneratorIdentifier
from-pack: ARM::RteTestGenerator@0.1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,19 @@ build:
condition: Cortex-M Device
from-pack: ARM::RteTest_DFP@0.2.0
selected-by: RteTest:CORE
implements: RteTest:CORE@1.1.2
files:
- file: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Doc/html/index.html
category: doc
version: 0.1.1
apis:
- api: RteTest:CORE@1.1.2
from-pack: ARM::RteTest_DFP@0.2.0
implemented-by: ARM::RteTest:CORE@0.1.1
files:
- file: https://arm-software.github.io/CMSIS_5/Pack/html/pdsc_apis_pg.html
category: doc
version: 1.1.2
generators:
- generator: RteTestGeneratorIdentifier
from-pack: ARM::RteTestGenerator@0.1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,19 @@ build:
condition: Cortex-M Device
from-pack: ARM::RteTest_DFP@0.2.0
selected-by: RteTest:CORE
implements: RteTest:CORE@1.1.2
files:
- file: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Doc/html/index.html
category: doc
version: 0.1.1
apis:
- api: RteTest:CORE@1.1.2
from-pack: ARM::RteTest_DFP@0.2.0
implemented-by: ARM::RteTest:CORE@0.1.1
files:
- file: https://arm-software.github.io/CMSIS_5/Pack/html/pdsc_apis_pg.html
category: doc
version: 1.1.2
generators:
- generator: RteTestGeneratorIdentifier
from-pack: ARM::RteTestGenerator@0.1.0
Expand Down
Loading

0 comments on commit ca002ac

Please sign in to comment.