9#include "directory_replace_placeholder.h"
44 return (packageName.isSameBegining(
"Phoenix") || packageName.isSameBegining(
"phoenix"));
52 PString cmakeFindBody;
57 cmakeFindBody +=
"find_package("+pkgAttr.
getCmakeFind()+
")";
69 PString phoenixPullExtraModule;
73 phoenixPullExtraModule +=
"pull_extra_module(\""+pkgAttr.
getName()+
"\" \""+pkgAttr.
getUrl()+
"\")\n";
76 return phoenixPullExtraModule;
84 PString phoenixFindModule;
88 phoenixFindModule +=
" "+pkgAttr.
getName();
91 return phoenixFindModule;
99 PString phoenixGlobalDep;
100 phoenixGlobalDep +=
"set(" + projectConfig.
name.toUpper() +
"_TEST_DEPENDENCIES\n";
101 phoenixGlobalDep +=
"\t" + projectConfig.
name.toSnakeCase() +
"\n";
105 phoenixGlobalDep +=
"\t"+pkgAttr.
getCmakeLib()+
"\n";
108 phoenixGlobalDep +=
")";
109 return phoenixGlobalDep;
117 PString targetLinkBody;
118 targetLinkBody +=
"target_link_libraries("+projectConfig.
name.toSnakeCase()+
" ";
125 targetLinkBody +=
")\n";
126 return targetLinkBody;
137 PString pixi_name = pkgAttr.
getPixiName().toLower();
140 if(pixi_name ==
"")
continue;
141 else if(min_version.empty() && max_version.empty()){
142 pixiBody += pixi_name +
" = \"*\"\n";
143 }
else if(max_version.empty()){
144 pixiBody += pixi_name +
" = \"" + min_version +
"\"\n";
146 pixiBody += pixi_name +
" = \"" + min_version;
147 if(!min_version.empty() && !max_version.empty()) pixiBody +=
",";
148 pixiBody += max_version +
"\"\n";
159 PString packageMdList;
163 packageMdList +=
"- ["+pkgAttr.
getName()+
"]("+pkgAttr.
getUrl()+
")\n";
166 return packageMdList;
174 PString authorListPixi;
175 authorListPixi +=
"authors = [\n";
176 for(ProjectMembersMap::const_iterator it = projectConfig.
authorMap.begin(); it != projectConfig.
authorMap.end(); ++it){
180 authorListPixi +=
"]\n";
181 return authorListPixi;
189 PString projectAuthorList;
190 bool firstAuthor =
true;
191 for(ProjectMembersMap::const_iterator it = projectConfig.
authorMap.begin(); it != projectConfig.
authorMap.end(); ++it){
193 if(!firstAuthor) projectAuthorList +=
",\n";
194 projectAuthorList +=
" {\n";
195 projectAuthorList +=
" \"@type\": \"Person\",\n";
196 projectAuthorList +=
" \"givenName\": \"" + author.
getFirstName() +
"\",\n";
197 projectAuthorList +=
" \"familyName\": \"" + author.
getLastName() +
"\",\n";
198 projectAuthorList +=
" \"email\": \"" + author.
getEmail() +
"\",\n";
199 projectAuthorList +=
" \"affiliation\": {\n";
200 projectAuthorList +=
" \"@type\": \"Organization\",\n";
201 projectAuthorList +=
" \"name\": \"" + author.
getAffiliation() +
"\"\n";
202 projectAuthorList +=
" }\n";
203 projectAuthorList +=
" }";
206 return projectAuthorList;
214 PString projectContributorList;
215 bool firstContributor =
true;
218 if(!firstContributor) projectContributorList +=
",\n";
219 projectContributorList +=
" {\n";
220 projectContributorList +=
" \"@type\": \"Person\",\n";
221 projectContributorList +=
" \"givenName\": \"" + contributor.
getFirstName() +
"\",\n";
222 projectContributorList +=
" \"familyName\": \"" + contributor.
getLastName() +
"\",\n";
223 projectContributorList +=
" \"email\": \"" + contributor.
getEmail() +
"\",\n";
224 projectContributorList +=
" \"affiliation\": {\n";
225 projectContributorList +=
" \"@type\": \"Organization\",\n";
226 projectContributorList +=
" \"name\": \"" + contributor.
getAffiliation() +
"\"\n";
227 projectContributorList +=
" }\n";
228 projectContributorList +=
" }";
229 firstContributor =
false;
231 return projectContributorList;
241 maintainer +=
" \"@type\": \"Person\",\n";
242 maintainer +=
" \"givenName\": \"" + maintainerPerson.
getFirstName() +
"\",\n";
243 maintainer +=
" \"familyName\": \"" + maintainerPerson.
getLastName() +
"\",\n";
244 maintainer +=
" \"email\": \"" + maintainerPerson.
getEmail() +
"\",\n";
245 maintainer +=
" \"affiliation\": {\n";
246 maintainer +=
" \"@type\": \"Organization\",\n";
247 maintainer +=
" \"name\": \"" + maintainerPerson.
getAffiliation() +
"\"\n";
257 PString keywordsBody;
259 bool firstKeyword =
true;
260 for(std::vector<PString>::const_iterator it = projectConfig.
keywordList.begin(); it != projectConfig.
keywordList.end(); ++it){
261 if(!firstKeyword) keywordsBody +=
",\n";
262 keywordsBody +=
" \"" + *it +
"\"";
263 firstKeyword =
false;
286 const PString & phoenixFindModule,
const PString & phoenixGlobalDep,
const PString & targetLinkBody,
287 const PString & pixiBody,
const PString & markdownDepList,
const PString & authorListPixi,
288 const PString & projectAuthorList,
const PString & projectContributorList,
const PString & maintainer,
289 const PString & keywordsBody,
const PString & dateStr)
291 PMapString mapReplace;
292 mapReplace[
"XXXProjectNameXXX"] = projectConfig.
name;
293 mapReplace[
"XXXPROJECT_NAMEXXX"] = projectConfig.
name.toUpper();
294 mapReplace[
"xxxproject_namexxx"] = projectConfig.
name.toSnakeCase();
295 mapReplace[
"XXXProjectNameDescriptionXXX"] = projectConfig.
description;
296 mapReplace[
"XXXProjectNameUrlXXX"] = projectConfig.
url;
297 mapReplace[
"XXXProjectVersionXXX"] = projectConfig.
version;
298 mapReplace[
"XXXProjectNameHomepageUrlXXX"] = projectConfig.
url;
299 mapReplace[
"XXXProjectNameRunnerTagXXX"] = projectConfig.
runnerTag;
300 mapReplace[
"XXXProjectFindPackageDependenciesXXX"] = cmakeFindBody;
301 mapReplace[
"XXXProjectPhoenixDependenciesXXX"] = phoenixPullExtraModule;
302 mapReplace[
"XXXProjectNameCMakeFindDependenciesXXX"] = phoenixFindModule;
303 mapReplace[
"XXXProjectDependenciesCMakeVarXXX"] = phoenixGlobalDep;
304 mapReplace[
"XXXProjectNameTargetLinkLinDependenciesXXX"] = targetLinkBody;
306 mapReplace[
"xxxphoenixprojectpixipackagenamexxx"] = projectConfig.
name.toLower();
307 mapReplace[
"xxxprojectnamepixiextradependenciesxxx"] = pixiBody;
308 mapReplace[
"XXXProjectNameMarkdownListDependenciesXXX"] = markdownDepList;
309 mapReplace[
"XXXcreationDateXXX"] = dateStr;
310 mapReplace[
"XXXProjectAuthorListPixiXXX"] = authorListPixi;
311 mapReplace[
"XXXAuthorListXXX"] = projectAuthorList;
312 mapReplace[
"XXXContributorListXXX"] = projectContributorList;
313 mapReplace[
"XXXMaintainerXXX"] = maintainer;
314 mapReplace[
"XXXKeywordListsXXX"] = keywordsBody;
338 PString dateStr = ctime(&(timestamp = time(
nullptr)));
339 dateStr = dateStr.eraseLastChar(
"\n");
343 phoenixFindModule, phoenixGlobalDep, targetLinkBody,
344 pixiBody, markdownDepList, authorListPixi, projectAuthorList,
345 projectContributorList, maintainer, keywordsBody, dateStr);
356 for(
const PPath & classConfigFile : vecClassConfigFile){
360 std::cerr <<
"simple_project_load_config : can't load file '" << classConfigFile <<
"'" << std::endl;
365 PPath destFile = pdataDir / classConfigFile.getFileName();
366 PString fileContent = classConfigFile.loadFileContent();
367 if(!destFile.saveFileContent(fileContent)){
368 std::cerr <<
"simple_project_load_config : cannot copy pdata file to project pdata directory '"<<destFile<<
"'" << std::endl;
414 std::cerr <<
"simple_project_generator : cannot parse project description file '"<<descriptionFile<<
"'" << std::endl;
419 std::cerr <<
"simple_project_generator : cannot find package info of project '"<<projectConfig.
name<<
"'" << std::endl;
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;
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;
448 std::cerr <<
"simple_project_generator : cannot load config to generate project in '"<<srcPath<<
"'" << std::endl;
452 std::cerr <<
"simple_project_generator : cannot generate sources in '"<<srcPath<<
"'" << std::endl;
457 std::cerr <<
"simple_project_generator : cannot generate class generator script in pdata directory '"<<pdataDir<<
"'" << std::endl;
Class generator for setter trait.
Class generator for setter trait.
Class generator for setter trait.
Class generator for setter trait.
Class generator for setter trait.
Class generator for setter trait.
Class generator for setter trait.
Class generator for setter trait.
Class to describe a basic class.
const PVecClassConfig & getVecClassConfig() const
Get the vector of all config class of the current pdata file.
const PPath & getFileName() const
Get the file name of the current PDataConfig.
const PVecPath & getVecInclude() const
Get the vector of all include files of the current pdata file.
Describes a package attributes.
const PString & getName() const
Gets the name of the PPackageAttribute.
const PString & getMaxVersion() const
Gets the maxVersion of the PPackageAttribute.
const PString & getUrl() const
Gets the url of the PPackageAttribute.
const PString & getCmakeFind() const
Gets the cmakeFind of the PPackageAttribute.
const PString & getCmakeLib() const
Gets the cmakeLib of the PPackageAttribute.
const PString & getMinVersion() const
Gets the minVersion of the PPackageAttribute.
const PString & getPixiName() const
Gets the pixiName of the PPackageAttribute.
Describes a package attributes.
const PString & getFirstName() const
Gets the firstName of the PProjectMembers.
const PString & getLastName() const
Gets the lastName of the PProjectMembers.
const PString & getEmail() const
Gets the email of the PProjectMembers.
const PString & getAffiliation() const
Gets the affiliation of the PProjectMembers.
Manager of the Trait backends.
void addTraitBackend()
Add a trait backend into the PTraitBackendManager.
Manager of the Trait backends.
void addTraitBackend()
Add a trait backend into the PWrapperTraitBackendManager.
Class generator for setter trait.
Class generator for setter trait.
Class generator for setter trait.
bool generator_class_full(const PTraitBackendManager &manager, const ProjectParam &projectParam)
Generate the full sources and related unit tests from configuration.
bool parserClassConfig(std::vector< PClassConfig > &listClassConfig, PVecPath &listInclude, const PPath &fileName)
Parser list class config.
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 ¶m, const PPath &pdataDir, const PVecPath &vecClassConfigFile)
Load configuration pdata of generated sources.
PString generateAuthorListPixi(const ProjectConfig &projectConfig)
Generate author list for Pixi.
PString generateCmakeFindBody(const ProjectConfig &projectConfig)
Generate CMake find_package commands for non-Phoenix dependencies.
PString generateProjectContributorList(const ProjectConfig &projectConfig)
Generate project contributor list for codemeta.json.
bool simple_project_generate_source(const ProjectParam &projectParam)
Save generated sources of project.
PString generateKeywordsBody(const ProjectConfig &projectConfig)
Generate keywords list for codemeta.json.
bool isPhoenixDependency(const PString &packageName)
Check if a package is a Phoenix dependency.
PString generatePhoenixFindModule(const ProjectConfig &projectConfig)
Generate Phoenix find module list.
PString generateMarkdownDepList(const ProjectConfig &projectConfig)
Generate markdown list of Phoenix dependencies.
PString generatePhoenixPullExtraModule(const ProjectConfig &projectConfig)
Generate Phoenix pull_extra_module commands.
PString generatePixiBody(const ProjectConfig &projectConfig)
Generate Pixi dependencies.
PMapString generateAllReplacementData(const ProjectConfig &projectConfig)
Generate all replacement data for project generation.
bool simple_project_generator(const PPath &descriptionFile, const PVecPath &vecClassConfigFile, const PString &projectType, const GeneratorMode &mode)
Create a simple project from a configuration.
PString generateMaintainer(const ProjectConfig &projectConfig)
Generate maintainer information for codemeta.json.
PString generateTargetLinkBody(const ProjectConfig &projectConfig)
Generate target_link_libraries command.
PString generateProjectAuthorList(const ProjectConfig &projectConfig)
Generate project author list for codemeta.json.
PString generatePhoenixGlobalDep(const ProjectConfig &projectConfig)
Generate Phoenix global dependencies variable.
PMapString generateReplacementMap(const ProjectConfig &projectConfig, const PString &cmakeFindBody, const PString &phoenixPullExtraModule, const PString &phoenixFindModule, const PString &phoenixGlobalDep, const PString &targetLinkBody, const PString &pixiBody, const PString &markdownDepList, const PString &authorListPixi, const PString &projectAuthorList, const PString &projectContributorList, const PString &maintainer, const PString &keywordsBody, const PString &dateStr)
Generate the replacement map for placeholders.
ProjectType::ProjectType type
Type of the project to be generated.
Configuration of the project.
PString description
Description of the project.
ProjectMembersMap contributorMap
Map of the contributors of the project.
PString name
Name of the project.
PackageMap mapDependencies
Map of all dependencies of the project with structure PPackageAttribute values.
ProjectMembersMap authorMap
Map of authors of the project.
PString runnerTag
Specific runner tag if needed (could be MUST_big_runner)
PString ciToolkitUrl
CI toolkit url.
PString ciToolkitVersion
Version of the Phoenix CI toolkit component (optional, defaults to 3.0.4)
PString version
Project version.
ProjectMembersMap maintainerMap
Map of maintainers of the project.
std::vector< PString > keywordList
List of keywords linked to the project.
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.
PVecDataConfig vecDataConfig
Configuration of classes to be generated.
PString name
Name of the project.
PPath outputSourceDir
Output path of the sources.
bool wrapper_generator_class_full(const PWrapperTraitBackendManager &manager, const ProjectParam &projectParam)
Generate the full sources and related unit tests from configuration.