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
17 changes: 17 additions & 0 deletions tools/projmgr/include/ProjMgrParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ struct TargetSetItem {
* misc compiler controls,
* platform processor
* context map
* west defines
*/
struct BuildType {
std::string compiler;
Expand All @@ -228,6 +229,7 @@ struct BuildType {
ProcessorItem processor;
std::vector<std::pair<std::string, std::string>> variables;
std::vector<ContextName> contextMap;
std::vector<std::string> westDefs;
};

/**
Expand Down Expand Up @@ -452,6 +454,18 @@ struct GroupNode {
TypeFilter type;
};

/**
* @brief west descriptor
*/
struct WestDesc {
std::string projectId;
std::string app;
std::string board;
std::string device;
std::vector<std::string> westDefs;
std::vector<std::string> westOpt;
};

/**
* @brief context descriptor containing
* cproject filename,
Expand All @@ -460,6 +474,7 @@ struct GroupNode {
struct ContextDesc {
std::string cproject;
TypeFilter type;
WestDesc west;
};

/**
Expand Down Expand Up @@ -506,6 +521,7 @@ typedef std::vector<std::pair<std::string, TargetType>> TargetTypes;
* target types,
* target properties,
* list of cprojects,
* list of west apps,
* list of contexts descriptors,
* list of packs,
* cdefault enable switch,
Expand All @@ -524,6 +540,7 @@ struct CsolutionItem {
TargetTypes targetTypes;
TargetType target;
std::vector<std::string> cprojects;
std::vector<std::string> westApps;
std::vector<ContextDesc> contexts;
std::vector<PackItem> packs;
bool enableCdefault;
Expand Down
7 changes: 7 additions & 0 deletions tools/projmgr/include/ProjMgrUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,13 @@ class ProjMgrUtils {
*/
static const std::string NormalizeLineEndings(const std::string& in);

/**
* @brief convert board string to west board string
* @param board string
* @return output west board string
*/
static const std::string GetWestBoard(const std::string& board);

protected:
/**
* @brief get filtered list of contexts
Expand Down
9 changes: 9 additions & 0 deletions tools/projmgr/include/ProjMgrWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ struct DebuggerType {
* load offset for generated binary
* elf load mode
* image only flag
* west options
* west on flag
*/
struct ContextItem {
CdefaultItem* cdefault = nullptr;
Expand Down Expand Up @@ -498,6 +500,8 @@ struct ContextItem {
std::string loadOffset;
std::string elfLoadMode;
bool imageOnly = false;
WestDesc west;
bool westOn = false;
};

/**
Expand All @@ -509,6 +513,11 @@ static constexpr const char* PLM_STATUS_UPDATE_REQUIRED = "update required";
static constexpr const char* PLM_STATUS_UPDATE_RECOMMENDED = "update recommended";
static constexpr const char* PLM_STATUS_UPDATE_SUGGESTED = "update suggested";

/**
* @brief west board variable
*/
static constexpr const char* WEST_BOARD = "west-board";

/**
* @brief set policy for packs loading [latest|all|required]
*/
Expand Down
5 changes: 5 additions & 0 deletions tools/projmgr/include/ProjMgrYamlParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ static constexpr const char* YAML_ARGUMENTS = "arguments";
static constexpr const char* YAML_APID = "apid";
static constexpr const char* YAML_APIS = "apis";
static constexpr const char* YAML_API = "api";
static constexpr const char* YAML_APP_PATH = "app-path";
static constexpr const char* YAML_ATOMIC = "atomic";
static constexpr const char* YAML_ATTR = "attr";
static constexpr const char* YAML_AUTO = "auto";
Expand Down Expand Up @@ -189,6 +190,7 @@ static constexpr const char* YAML_PROCESSORS = "processors";
static constexpr const char* YAML_PROCESSOR = "processor";
static constexpr const char* YAML_PROGRAMMING = "programming";
static constexpr const char* YAML_PROJECT = "project";
static constexpr const char* YAML_PROJECT_ID = "project-id";
static constexpr const char* YAML_PROJECTS = "projects";
static constexpr const char* YAML_PROJECT_CONTEXT = "project-context";
static constexpr const char* YAML_PROJECT_TYPE = "project-type";
Expand Down Expand Up @@ -243,6 +245,9 @@ static constexpr const char* YAML_VARS = "vars";
static constexpr const char* YAML_VALUE = "value";
static constexpr const char* YAML_VERSION = "version";
static constexpr const char* YAML_WARNINGS = "warnings";
static constexpr const char* YAML_WEST = "west";
static constexpr const char* YAML_WEST_DEFS = "west-defs";
static constexpr const char* YAML_WEST_OPT = "west-opt";
static constexpr const char* YAML_WHILE = "while";
static constexpr const char* YAML_WORKING_DIR = "working-dir";

Expand Down
34 changes: 28 additions & 6 deletions tools/projmgr/schemas/common.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@
},
{
"type": "number"
},
{
"type": "boolean"
}
]
}
Expand Down Expand Up @@ -601,7 +604,8 @@
"target-set": { "$ref": "#/definitions/TargetSetsType" },
"undefine": { "$ref": "#/definitions/UndefinesType" },
"variables": { "$ref": "#/definitions/VariablesType" },
"warnings": { "$ref": "#/definitions/WarningsType" }
"warnings": { "$ref": "#/definitions/WarningsType" },
"west-defs": { "$ref": "#/definitions/DefinesType" }
},
"additionalProperties": false,
"required" : [ "type"]
Expand Down Expand Up @@ -638,7 +642,8 @@
"processor": { "$ref": "#/definitions/ProcessorType" },
"undefine": { "$ref": "#/definitions/UndefinesType" },
"variables": { "$ref": "#/definitions/VariablesType" },
"warnings": { "$ref": "#/definitions/WarningsType" }
"warnings": { "$ref": "#/definitions/WarningsType" },
"west-defs": { "$ref": "#/definitions/DefinesType" }
},
"additionalProperties": false,
"required" : [ "type"]
Expand All @@ -660,13 +665,13 @@
"pattern": "^.*[/]([^.+]*\\.cproject\\.(yml|yaml))$|^([^.+]+)\\.cproject\\.(yml|yaml)$",
"description": "Path to the valid project file."
},
"west": { "$ref": "#/definitions/WestProjectType" },
"for-context": { "$ref": "#/definitions/ForContext" },
"not-for-context": { "$ref": "#/definitions/NotForContext" }
},
"additionalProperties": false,
"allOf": [
{ "$ref": "#/definitions/TypeListMutualExclusion"},
{ "required": [ "project" ] }
"oneOf": [
{ "$ref": "#/definitions/TypeListMutualExclusion"}
]
},
"ProcessorTrustzone": {
Expand Down Expand Up @@ -1274,6 +1279,7 @@
"type": "object",
"properties": {
"cbuild": { "type": "string", "description": "Path to <context>.cbuild.yml file." },
"west": { "type": "boolean" },
"project": { "type": "string", "description": "Project name." },
"configuration": { "$ref": "#/definitions/BuildContext" },
"depends-on": {
Expand Down Expand Up @@ -1427,7 +1433,8 @@
"licenses": {
"type": "array",
"items": { "$ref": "#/definitions/LicenseInfoType" }
}
},
"west": { "$ref": "#/definitions/WestProjectType" }
},
"additionalProperties": false
},
Expand Down Expand Up @@ -2398,6 +2405,21 @@
"title": "optimize:\nDocumentation: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-Input-Format/#load",
"description": "Specifies the load mode for the project output or image file.",
"enum": [ "image+symbols", "symbols", "image", "none" ]
},
"WestProjectType": {
"title": "west:",
"description": "Enable West build orchestration wrapper for Zephyr projects.",
"type": "object",
"properties": {
"app-path": { "type": "string", "description": "Path to the application source directory." },
"project-id": { "type": "string", "description": "Project identifier (default: last sub-dir name of app-path)." },
"board": { "type": "string", "description": "Board name used for west build invocation (default: variable $west-board$)."},
"device": { "$ref": "#/definitions/ProcessorNameType" },
"west-defs": { "$ref": "#/definitions/DefinesType" },
"west-opts": { "type": "string", "description": "Options for the west tool (default: empty)." }
},
"additionalProperties": false,
"required": ["app-path"]
}
}
}
2 changes: 1 addition & 1 deletion tools/projmgr/src/ProjMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ bool ProjMgr::PopulateContexts(void) {
}
// Check cproject separate folders and unique names
const StrVec& cprojects = m_parser.GetCsolution().cprojects;
if (!IsSolutionImageOnly() && cprojects.empty()) {
if (!IsSolutionImageOnly() && cprojects.empty() && m_parser.GetCsolution().westApps.empty()) {
ProjMgrLogger::Get().Error("projects not found", "", m_csolutionFile);
return false;
}
Expand Down
26 changes: 23 additions & 3 deletions tools/projmgr/src/ProjMgrCbuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class ProjMgrCbuild : public ProjMgrCbuildBase {
void SetBooksNode(YAML::Node node, const std::vector<BookItem>& books, const std::string& dir);
void SetDebugConfigNode(YAML::Node node, const ContextItem* context);
void SetPLMStatus(YAML::Node node, const ContextItem* context, const string& file);
void SetWestNode(YAML::Node node, const ContextItem* context);
bool m_ignoreRteFileMissing;
};

Expand Down Expand Up @@ -85,11 +86,11 @@ void ProjMgrCbuild::SetContextNode(YAML::Node contextNode, const ContextItem* co
}
SetBooksNode(contextNode[YAML_DEVICE_BOOKS], context->deviceBooks, context->directories.cbuild);
SetDebugConfigNode(contextNode[YAML_DBGCONF], context);
if (!context->imageOnly) {
if (!context->imageOnly && !context->westOn) {
SetProcessorNode(contextNode[YAML_PROCESSOR], context->targetAttributes);
}
SetPacksNode(contextNode[YAML_PACKS], context);
if (!context->imageOnly) {
if (!context->imageOnly && !context->westOn) {
SetControlsNode(contextNode, context, context->controls.processed);
vector<string> defines;
if (context->rteActiveTarget != nullptr) {
Expand All @@ -108,7 +109,14 @@ void ProjMgrCbuild::SetContextNode(YAML::Node contextNode, const ContextItem* co
}
}
SetOutputDirsNode(contextNode[YAML_OUTPUTDIRS], context);
SetOutputNode(contextNode[YAML_OUTPUT], context);
}
if (context->westOn) {
string outDir = context->directories.outdir;
RteFsUtils::NormalizePath(outDir, context->directories.cprj);
SetNodeValue(contextNode[YAML_OUTPUTDIRS][YAML_OUTPUT_OUTDIR], FormatPath(outDir, context->directories.cbuild));
}
SetOutputNode(contextNode[YAML_OUTPUT], context);
if (!context->imageOnly && !context->westOn) {
SetComponentsNode(contextNode[YAML_COMPONENTS], context);
SetApisNode(contextNode[YAML_APIS], context);
SetGeneratorsNode(contextNode[YAML_GENERATORS], context);
Expand All @@ -117,6 +125,9 @@ void ProjMgrCbuild::SetContextNode(YAML::Node contextNode, const ContextItem* co
SetConstructedFilesNode(contextNode[YAML_CONSTRUCTEDFILES], context);
}
SetLicenseInfoNode(contextNode[YAML_LICENSES], context);
if (context->westOn) {
SetWestNode(contextNode[YAML_WEST], context);
}
}

void ProjMgrCbuild::SetComponentsNode(YAML::Node node, const ContextItem* context) {
Expand Down Expand Up @@ -590,3 +601,12 @@ bool ProjMgrYamlEmitter::GenerateCbuild(ContextItem* context,
context->needRebuild = NeedRebuild(filename, rootNode);
return WriteFile(rootNode, filename, context->name);
}

void ProjMgrCbuild::SetWestNode(YAML::Node node, const ContextItem* context) {
SetNodeValue(node[YAML_PROJECT_ID], context->west.projectId);
SetNodeValue(node[YAML_APP_PATH], FormatPath(context->west.app, context->directories.cbuild));
SetNodeValue(node[YAML_BOARD], context->west.board);
SetNodeValue(node[YAML_DEVICE], context->west.device);
SetDefineNode(node[YAML_WEST_DEFS], context->west.westDefs);
SetNodeValue(node[YAML_WEST_OPT], context->west.westOpt);
}
14 changes: 12 additions & 2 deletions tools/projmgr/src/ProjMgrCbuildIdx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ProjMgrCbuildIdx::ProjMgrCbuildIdx(YAML::Node node,
if (!processedContexts.empty()) {
const auto& context = processedContexts.front();
SetNodeValue(node[YAML_DESCRIPTION], context->csolution->description);
if (!parser->GetCdefault().path.empty() && !context->imageOnly) {
if (!parser->GetCdefault().path.empty() && !context->imageOnly && !context->westOn) {
SetNodeValue(node[YAML_CDEFAULT], FormatPath(parser->GetCdefault().path, directory));
}
}
Expand All @@ -44,7 +44,14 @@ ProjMgrCbuildIdx::ProjMgrCbuildIdx(YAML::Node node,
SetNodeValue(node[YAML_OUTPUT_TMPDIR], FormatPath(parser->GetCsolution().directories.tmpdir, directory));

// Image Only flag
if (!processedContexts.empty() && processedContexts.front()->imageOnly) {
bool imageOnlySolution = true;
for (const auto& processedContext : processedContexts) {
if (!processedContext->imageOnly) {
imageOnlySolution = false;
break;
}
}
if (imageOnlySolution) {
node[YAML_IMAGE_ONLY] = true;
}

Expand Down Expand Up @@ -134,6 +141,9 @@ ProjMgrCbuildIdx::ProjMgrCbuildIdx(YAML::Node node,
const string& filename = context->directories.cprj + "/" + context->name + ".cbuild.yml";
const string& relativeFilename = fs::relative(filename, directory, ec).generic_string();
SetNodeValue(cbuildNode[YAML_CBUILD], relativeFilename);
if (context->westOn) {
cbuildNode[YAML_WEST] = true;
}
if (context->cproject) {
if (!context->imageOnly) {
SetNodeValue(cbuildNode[YAML_PROJECT], context->cproject->name);
Expand Down
8 changes: 8 additions & 0 deletions tools/projmgr/src/ProjMgrUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,3 +498,11 @@ const std::string ProjMgrUtils::NormalizeLineEndings(const std::string& in) {
}
return out;
}

const std::string ProjMgrUtils::GetWestBoard(const std::string& board) {
string westBoard = RteUtils::StripSuffix(RteUtils::StripPrefix(board, "::"));
std::transform(westBoard.begin(), westBoard.end(), westBoard.begin(),
[](unsigned char c) { return std::tolower(c); });
std::replace(westBoard.begin(), westBoard.end(), '-', '_');
return westBoard;
}
Loading
Loading