@@ -35,6 +35,7 @@ Commands:\n\
3535 list packs Print list of used packs from the pack repository\n \
3636 list toolchains Print list of supported toolchains\n \
3737 run Run code generator\n \
38+ rpc Run remote procedure call server\n \
3839 update-rte Create/update configuration files and validate solution\n\n \
3940Options:\n \
4041 -c, --context arg [...] Input context names [<project-name>][.<build-type>][+<target-type>]\n \
@@ -63,6 +64,7 @@ ProjMgr::ProjMgr() :
6364 m_extGenerator(&m_parser),
6465 m_worker(&m_parser, &m_extGenerator),
6566 m_emitter(&m_parser, &m_worker),
67+ m_rpcServer(this ),
6668 m_checkSchema(false ),
6769 m_missingPacks(false ),
6870 m_updateRteFiles(true ),
@@ -162,6 +164,7 @@ int ProjMgr::ParseCommandLine(int argc, char** argv) {
162164 cxxopts::Option updateIdx (" update-idx" , " Update cbuild-idx file with layer info" , cxxopts::value<bool >()->default_value (" false" ));
163165 cxxopts::Option quiet (" q,quiet" , " Run silently, printing only error messages" , cxxopts::value<bool >()->default_value (" false" ));
164166 cxxopts::Option cbuildgen (" cbuildgen" , " Generate legacy *.cprj files" , cxxopts::value<bool >()->default_value (" false" ));
167+ cxxopts::Option contentLength (" content-length" , " Prepend 'Content-Length' header to JSON RPC requests and responses" , cxxopts::value<bool >()->default_value (" false" ));
165168
166169 // command options dictionary
167170 map<string, std::pair<bool , vector<cxxopts::Option>>> optionsDict = {
@@ -180,6 +183,7 @@ int ProjMgr::ParseCommandLine(int argc, char** argv) {
180183 {" list layers" , { false , {context, contextSet, debug, load, clayerSearchPath, quiet, schemaCheck, toolchain, verbose, updateIdx}}},
181184 {" list toolchains" , { false , {context, contextSet, debug, quiet, toolchain, verbose}}},
182185 {" list environment" , { true , {}}},
186+ {" rpc" , { true , {contentLength}}},
183187 };
184188
185189 try {
@@ -188,7 +192,7 @@ int ProjMgr::ParseCommandLine(int argc, char** argv) {
188192 solution, context, contextSet, filter, generator,
189193 load, clayerSearchPath, missing, schemaCheck, noUpdateRte, output, outputAlt,
190194 help, version, verbose, debug, dryRun, exportSuffix, toolchain, ymlOrder,
191- relativePaths, frozenPacks, updateIdx, quiet, cbuildgen
195+ relativePaths, frozenPacks, updateIdx, quiet, cbuildgen, contentLength
192196 });
193197 options.parse_positional ({ " positional" });
194198
@@ -215,6 +219,7 @@ int ProjMgr::ParseCommandLine(int argc, char** argv) {
215219 m_cbuildgen = parseResult.count (" cbuildgen" );
216220 m_worker.SetCbuild2Cmake (!m_cbuildgen);
217221 ProjMgrLogger::m_quiet = parseResult.count (" quiet" );
222+ m_rpcServer.SetContentLengthHeader (parseResult.count (" content-length" ));
218223
219224 vector<string> positionalArguments;
220225 if (parseResult.count (" positional" )) {
@@ -403,6 +408,11 @@ int ProjMgr::ProcessCommands() {
403408 if (!RunCodeGenerator ()) {
404409 return ErrorCode::ERROR;
405410 }
411+ } else if (m_command == " rpc" ) {
412+ // Launch 'rpc' server
413+ if (!m_rpcServer.Run ()) {
414+ return ErrorCode::ERROR;
415+ }
406416 } else {
407417 ProjMgrLogger::Get ().Error (" <command> was not found" );
408418 return ErrorCode::ERROR;
0 commit comments