PhoenixGenerator  2.0.0
Set of tools to generate code
wrapper_generator.h File Reference
+ Include dependency graph for wrapper_generator.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool project_wrapper_generator (const ProjectConfig &projectConfig, const PPath &configFile)
 Generate a full python wrapper project with PhoenixDataStream and PhoenixTypeStream. More...
 

Function Documentation

◆ project_wrapper_generator()

bool project_wrapper_generator ( const ProjectConfig projectConfig,
const PPath configFile 
)

Generate a full python wrapper project with PhoenixDataStream and PhoenixTypeStream.

Parameters
projectConfig: description of the full project
configFile: configuration file of the
Returns
true on success, false otherwise

Definition at line 178 of file wrapper_generator.cpp.

178  {
179  ProjectConfig wrapperConfig(project_createWrapperConfig(projectConfig));
180  PVecPath vecInclude;
181  std::vector<PClassConfig> vecClassConfig;
182  if(!parserClassConfig(vecClassConfig, vecInclude, configFile)){
183  std::cerr << "project_wrapper_generator : can't load file '" << configFile << "'" << std::endl;
184  return false;
185  }
186  //TODO : pass through vecClassConfig and replace PPath and PString by std::string to ensure PhoenixDataStream will work well on them for the wrapper
187  updateVecClassConfig(vecClassConfig);
188 
189  //Then, let's create the hierarchy
190  PPath mainProjectDir(wrapperConfig.name);
191  if(!mainProjectDir.createDirectory()){
192  std::cerr << "project_wrapper_generator : cannot create main directory of project '"<<mainProjectDir<<"'" << std::endl;
193  return false;
194  }
195  //And module dir
196  PPath mainProjectModule(mainProjectDir / PPath(wrapperConfig.name.toLower()));
197  if(!mainProjectModule.createDirectory()){
198  std::cerr << "project_generator : cannot create module directory of project '"<<mainProjectModule<<"'" << std::endl;
199  return false;
200  }
201  //The readme
202  PPath readmeFile(mainProjectDir / PPath("README.md"));
203  if(!project_wrapper_generator_readme(readmeFile, projectConfig)){return false;}
204 
205  PString baseImplInclude = configFile.getFileName().eraseExtension();
206  //The readme
207  PPath setupFile(mainProjectDir / PPath("setup.py"));
208  if(!project_wrapper_generator_setuppy(setupFile, projectConfig, baseImplInclude, vecClassConfig, vecInclude)){return false;}
209 
210  PPath pyprojectFile(mainProjectDir / PPath("pyproject.toml"));
211  if(!project_wrapper_generator_pyprojectToml(pyprojectFile, projectConfig, baseImplInclude, vecClassConfig, vecInclude)){return false;}
212  //The unit tests
213  if(!project_wrapper_moduleGeneratorTest(mainProjectDir, projectConfig, "py"+projectConfig.name.toLower(), vecClassConfig, vecInclude)){return false;}
214  //The full module
215  return project_wrapper_moduleGenerator(mainProjectModule, projectConfig, baseImplInclude, vecClassConfig, vecInclude);
216 }
std::vector< PPath > PVecPath
Definition: PPath.h:75
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 parserClassConfig(std::vector< PClassConfig > &listClassConfig, PVecPath &listInclude, const PPath &fileName)
Parser list class config.
Configuration of the project.
PString name
Name of the project.
bool project_wrapper_generator_setuppy(const PPath &fileName, const ProjectConfig &projectConfig, const PString &baseImplInclude, const std::vector< PClassConfig > &vecClassConfig, const PVecPath &vecInclude)
Create the readme of the project directory.
bool project_wrapper_generator_readme(const PPath &fileName, const ProjectConfig &projectConfig)
Create the readme of the project directory.
bool project_wrapper_generator_pyprojectToml(const PPath &fileName, const ProjectConfig &projectConfig, const PString &baseImplInclude, const std::vector< PClassConfig > &vecClassConfig, const PVecPath &vecInclude)
Create the readme of the project directory.
ProjectConfig project_createWrapperConfig(const ProjectConfig &projectConfig)
Create the config of the wrapper.
void updateVecClassConfig(std::vector< PClassConfig > &vecClassConfig)
Update the vector of class configuration.
bool project_wrapper_moduleGenerator(const PPath &modulePath, const ProjectConfig &projectConfig, const PString &baseImplInclude, const std::vector< PClassConfig > &vecClassConfig, const PVecPath &vecInclude)
Create the wrapper module.
bool project_wrapper_moduleGeneratorTest(const PPath &projectPath, const ProjectConfig &projectConfig, const PString &moduleName, const std::vector< PClassConfig > &vecClassConfig, const PVecPath &vecInclude)
Generate the unit tests of the project.

References PPath::createDirectory(), PPath::eraseExtension(), PPath::getFileName(), ProjectConfig::name, parserClassConfig(), project_createWrapperConfig(), project_wrapper_generator_pyprojectToml(), project_wrapper_generator_readme(), project_wrapper_generator_setuppy(), project_wrapper_moduleGenerator(), project_wrapper_moduleGeneratorTest(), PString::toLower(), and updateVecClassConfig().

Referenced by project_generator().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: