PhoenixGenerator  2.0.4
Set of tools to generate code
Loading...
Searching...
No Matches
simple_project_generator.h File Reference
+ Include dependency graph for simple_project_generator.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool isPhoenixDependency (const PString &packageName)
 Check if a package is a Phoenix dependency.
 
bool simple_project_generator (const PPath &descriptionFile, const PVecPath &vecClassConfigFile, const PString &projectType, const GeneratorMode &mode)
 Create a simple project from a configuration.
 

Function Documentation

◆ isPhoenixDependency()

bool isPhoenixDependency ( const PString & packageName)

Check if a package is a Phoenix dependency.

Parameters
packageName: name of the package
Returns
true if it's a Phoenix dependency, false otherwise

Definition at line 43 of file simple_project_generator.cpp.

43 {
44 return (packageName.isSameBegining("Phoenix") || packageName.isSameBegining("phoenix"));
45}

Referenced by generateCmakeFindBody(), generateMarkdownDepList(), generatePhoenixFindModule(), generatePhoenixGlobalDep(), generatePhoenixPullExtraModule(), and generateTargetLinkBody().

+ Here is the caller graph for this function:

◆ simple_project_generator()

bool simple_project_generator ( const PPath & descriptionFile,
const PVecPath & vecClassConfigFile,
const PString & projectType,
const GeneratorMode & mode )

Create a simple project from a configuration.

Parameters
descriptionFile: description of the full project
vecClassConfigFile: vector of class configuration files (.pdata files)
projectType: type of the project (SimpleCpp)
mode: all modes of the generator (data/check/type/config stream)
Returns
true on success, false otherwise

Definition at line 408 of file simple_project_generator.cpp.

410{
411 //First, let's read the toml config of the project
412 ProjectConfig projectConfig;
413 if(!project_generator_loadConfig(projectConfig, descriptionFile)){
414 std::cerr << "simple_project_generator : cannot parse project description file '"<<descriptionFile<<"'" << std::endl;
415 return false;
416 }
417 //Then look in the config files if the packages exists
418 if(!project_generator_loadPackageInfo(projectConfig)){
419 std::cerr << "simple_project_generator : cannot find package info of project '"<<projectConfig.name<<"'" << std::endl;
420 return false;
421 }
422 // Generate replacement data
423 PMapString mapReplace = generateAllReplacementData(projectConfig);
424 PPath inputConfigPlaceholderDir = PPath(SYSTEM_INSTALL_DIR) / PPath("share") / PPath("PhoenixGenerator") / PPath("Projects") / PPath(projectType), outputPath("./");
425 if(!directory_replace_placeholder(outputPath, inputConfigPlaceholderDir, mapReplace)){
426 std::cerr << "simple_project_generator : cannot replace placeholder in project generation '"<<projectConfig.name<<"'" << std::endl;
427 return false;
428 }
429 PPath mainPath = PPath(".") / PPath(projectConfig.name);
430 PPath srcPath = mainPath / PPath("src"), pdataDir = mainPath / PPath("pdata");
431 if(!pdataDir.createDirectory()){
432 std::cerr << "simple_project_generator : cannot create pdata directory '"<<pdataDir<<"'" << std::endl;
433 return false;
434 }
435 ProjectParam param;
436 param.mode = mode;
437 param.name = projectConfig.name;
438 param.version = projectConfig.version;
439 param.outputProjectDir = mainPath;
440 param.outputSourceDir = srcPath;
441 if(param.mode.type == ProjectType::CPP){
442 param.outputTestDir = mainPath / PPath("TESTS");
443 }else if(param.mode.type == ProjectType::WRAPPER){
444 param.outputTestDir = mainPath / PPath("tests");
445 }
446
447 if(!simple_project_load_config(param, pdataDir, vecClassConfigFile)){
448 std::cerr << "simple_project_generator : cannot load config to generate project in '"<<srcPath<<"'" << std::endl;
449 return false;
450 }
452 std::cerr << "simple_project_generator : cannot generate sources in '"<<srcPath<<"'" << std::endl;
453 return false;
454 }
455 // Generate class generator script
456 if(!generateClassGeneratorScript(vecClassConfigFile, pdataDir, param.mode)){
457 std::cerr << "simple_project_generator : cannot generate class generator script in pdata directory '"<<pdataDir<<"'" << std::endl;
458 return false;
459 }
460 return true;
461}
bool project_generator_loadPackageInfo(ProjectConfig &config)
This function should load the package info file from share/PhoenixGenerator/Packages and retrieve the...
bool project_generator_loadConfig(ProjectConfig &config, const PPath &descriptionFile)
Load the project configuration.
bool generateClassGeneratorScript(const PVecPath &vecClassConfigFile, const PPath &scriptDir, const GeneratorMode &mode)
Generate a bash script to re generate all the classes from their pdata configuration files.
bool simple_project_load_config(ProjectParam &param, const PPath &pdataDir, const PVecPath &vecClassConfigFile)
Load configuration pdata of generated sources.
bool simple_project_generate_source(const ProjectParam &projectParam)
Save generated sources of project.
PMapString generateAllReplacementData(const ProjectConfig &projectConfig)
Generate all replacement data for project generation.
ProjectType::ProjectType type
Type of the project to be generated.
Configuration of the project.
PString name
Name of the project.
PString version
Project version.
Set of parameters to generate a project.
PPath outputProjectDir
Output path of the full project.
GeneratorMode mode
Mode to be used to generate the project.
PString version
Version of the project.
PPath outputTestDir
Output path of the unit tests.
PString name
Name of the project.
PPath outputSourceDir
Output path of the sources.

References ProjectType::CPP, generateAllReplacementData(), generateClassGeneratorScript(), ProjectParam::mode, ProjectConfig::name, ProjectParam::name, ProjectParam::outputProjectDir, ProjectParam::outputSourceDir, ProjectParam::outputTestDir, project_generator_loadConfig(), project_generator_loadPackageInfo(), simple_project_generate_source(), simple_project_load_config(), GeneratorMode::type, ProjectConfig::version, ProjectParam::version, and ProjectType::WRAPPER.

+ Here is the call graph for this function: