PhoenixGenerator  2.0.0
Set of tools to generate code
project_generator.h File Reference
#include "header_generator.h"
#include "PClassGenerator.h"
#include "saveClassConfig.h"
#include "parserClassConfig.h"
+ Include dependency graph for project_generator.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ProjectConfig
 Configuration of the project. More...
 

Functions

bool project_generator (const PPath &descriptionFile, const PPath &configFile, bool isPythonWrapper)
 Generate a full project with PhoenixDataStream and PhoenixTypeStream. More...
 

Function Documentation

◆ project_generator()

bool project_generator ( const PPath descriptionFile,
const PPath configFile,
bool  isPythonWrapper 
)

Generate a full project with PhoenixDataStream and PhoenixTypeStream.

Parameters
descriptionFile: description of the full project
configFile: configuration file of the
isPythonWrapper: true if we want to generate a Python wrapper
Returns
true on success, false otherwise

Definition at line 292 of file project_generator.cpp.

292  {
293  //First, let's read the toml config of the project
294  ProjectConfig projectConfig;
295  if(!project_generator_loadConfig(projectConfig, descriptionFile)){
296  std::cerr << "project_generator : cannot parse project description file '"<<descriptionFile<<"'" << std::endl;
297  return false;
298  }
299  //Then, let's create the hierarchy
300  PPath mainProjectDir(projectConfig.name);
301  if(!mainProjectDir.createDirectory()){
302  std::cerr << "project_generator : cannot create main directory of project '"<<mainProjectDir<<"'" << std::endl;
303  return false;
304  }
305  //And src dir
306  PPath mainProjectSrc(mainProjectDir / PPath("src"));
307  if(!mainProjectSrc.createDirectory()){
308  std::cerr << "project_generator : cannot create source directory of project '"<<mainProjectSrc<<"'" << std::endl;
309  return false;
310  }
311  //Let's generate sources
312  PString className = configFile.getFileName().eraseExtension();
313  if(!saveParserClassConfig(mainProjectSrc / className, configFile, true, true, true, mainProjectDir, projectConfig.name.toLower())){
314  std::cerr << "project_generator : can't save file '"<<className<<"'[.h or .cpp]" << std::endl;
315  return false;
316  }
317  //Now, some CMakeLists.txt of the sources
318  PPath cmakeListsSrc(mainProjectSrc / PPath("CMakeLists.txt"));
319  if(!project_generator_cmakeListsSrc(cmakeListsSrc, projectConfig.name, projectConfig.name.toLower())){return false;}
320  //The main CMakeLists
321  PPath cmakeListsMain(mainProjectDir / PPath("CMakeLists.txt"));
322  if(!project_generator_cmakeListsMain(cmakeListsMain, projectConfig, configFile.getFileName().eraseExtension())){return false;}
323  //CMakeLists of the tests
324  PPath cmakeListsTest(mainProjectDir / PPath("TESTS/CMakeLists.txt"));
325  if(!project_generator_cmakeListsTest(cmakeListsTest, configFile.getFileName().eraseExtension())){return false;}
326  //The readme
327  PPath readmeFile(mainProjectDir / PPath("README.md"));
328  if(!project_generator_readme(readmeFile, projectConfig)){return false;}
329  //The gitignore
330  PPath gitignoreFile(mainProjectDir / PPath(".gitignore"));
331  if(!project_generator_gitignore(gitignoreFile)){return false;}
332 
333  PPath gitlabciFile(mainProjectDir / PPath(".gitlab-ci.yml"));
334  if(!project_generator_gitlabci(gitlabciFile, projectConfig)){return false;}
335  if(isPythonWrapper){
336  return project_wrapper_generator(projectConfig, configFile);
337  }
338  return true;
339 }
Path of a directory or a file.
Definition: PPath.h:17
PPath & eraseExtension()
Erase the extension of the PPath.
Definition: PPath.cpp:292
PPath getFileName() const
Get the name of the file, from last char to /.
Definition: PPath.cpp:172
Extends the std::string.
Definition: PString.h:16
PString toLower() const
Convert PString in lower case.
Definition: PString.cpp:598
bool saveParserClassConfig(const PPath &baseFileNameOutput, const PPath &fileName, bool enableDataStream, bool enableTypeStream, bool enableUnitTest, const PPath &testParentDir, const PString &libName)
Parser list class config.
bool project_generator_cmakeListsMain(const PPath &fileName, const ProjectConfig &projectConfig, const PString &baseConfigClassName)
Create the main CMakeLists.txt of the project directory.
bool project_generator_cmakeListsSrc(const PPath &fileName, const PString &projectName, const PString &libName)
Create the CMakeLists.txt of the src directory.
bool project_generator_gitlabci(const PPath &fileName, const ProjectConfig &projectConfig)
Create the .gitlab-ci.yml of the project.
bool project_generator_gitignore(const PPath &fileName)
Create the .gitignore of the project.
bool project_generator_readme(const PPath &fileName, const ProjectConfig &projectConfig)
Create the readme of the project directory.
bool project_generator_cmakeListsTest(const PPath &fileName, const PString &baseConfigClassName)
Create the main CMakeLists.txt of the project directory.
bool project_generator_loadConfig(ProjectConfig &config, const PPath &descriptionFile)
Load the project configuration.
Configuration of the project.
PString name
Name of the project.
bool project_wrapper_generator(const ProjectConfig &projectConfig, const PPath &configFile)
Generate a full python wrapper project with PhoenixDataStream and PhoenixTypeStream.

References PPath::createDirectory(), PPath::eraseExtension(), PPath::getFileName(), ProjectConfig::name, project_generator_cmakeListsMain(), project_generator_cmakeListsSrc(), project_generator_cmakeListsTest(), project_generator_gitignore(), project_generator_gitlabci(), project_generator_loadConfig(), project_generator_readme(), project_wrapper_generator(), saveParserClassConfig(), and PString::toLower().

+ Here is the call graph for this function: