| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*************************************** | ||
| 2 | Auteur : Pierre Aubert | ||
| 3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
| 4 | Licence : CeCILL-C | ||
| 5 | ****************************************/ | ||
| 6 | |||
| 7 | #include <ctime> | ||
| 8 | |||
| 9 | #include "directory_replace_placeholder.h" | ||
| 10 | #include "simple_project_generator.h" | ||
| 11 | #include "parserClassConfig.h" | ||
| 12 | |||
| 13 | //C++ Trait Backend | ||
| 14 | #include "CppTraitFromString.h" | ||
| 15 | #include "CppTraitSetter.h" | ||
| 16 | #include "CppTraitGetter.h" | ||
| 17 | #include "CppTraitCopy.h" | ||
| 18 | #include "CppTraitTypeStream.h" | ||
| 19 | #include "CppTraitDataStream.h" | ||
| 20 | #include "CppTraitConfigStream.h" | ||
| 21 | #include "CppTraitCheckStream.h" | ||
| 22 | |||
| 23 | #include "PTraitBackendManager.h" | ||
| 24 | |||
| 25 | //Wrapper Trait Backend | ||
| 26 | #include "WrapperTraitGetterSetter.h" | ||
| 27 | #include "WrapperTraitTypeStream.h" | ||
| 28 | #include "WrapperTraitDataStream.h" | ||
| 29 | #include "PWrapperTraitBackendManager.h" | ||
| 30 | |||
| 31 | //Nanobind Trait Backend | ||
| 32 | #include "NanobindTraitProperty.h" | ||
| 33 | #include "NanobindTraitMethod.h" | ||
| 34 | #include "NanobindTraitTypeStream.h" | ||
| 35 | #include "NanobindTraitDataStream.h" | ||
| 36 | #include "NanobindTraitCheckStream.h" | ||
| 37 | #include "NanobindTraitTestSetup.h" | ||
| 38 | #include "NanobindTraitInclude.h" | ||
| 39 | #include "PNanobindTraitBackendManager.h" | ||
| 40 | |||
| 41 | //C++ Generator | ||
| 42 | #include "generator_class_cpp.h" | ||
| 43 | //Wrapper Generator | ||
| 44 | #include "wrapper_generator_struct.h" | ||
| 45 | //Nanobind Generator | ||
| 46 | #include "nanobind_generator.h" | ||
| 47 | |||
| 48 | #include "simpleClassGenerator.h" | ||
| 49 | |||
| 50 | ///Check if a package is a Phoenix dependency | ||
| 51 | /** @param packageName : name of the package | ||
| 52 | * @return true if it's a Phoenix dependency, false otherwise | ||
| 53 | */ | ||
| 54 | 119 | bool isPhoenixDependency(const PString & packageName){ | |
| 55 |
10/16✓ Branch 0 (2→3) taken 119 times.
✓ Branch 2 (3→4) taken 119 times.
✓ Branch 4 (4→5) taken 14 times.
✓ Branch 5 (4→8) taken 105 times.
✓ Branch 6 (5→6) taken 14 times.
✓ Branch 8 (6→7) taken 14 times.
✗ Branch 10 (7→8) not taken.
✓ Branch 11 (7→9) taken 14 times.
✓ Branch 12 (11→12) taken 14 times.
✓ Branch 13 (11→13) taken 105 times.
✓ Branch 14 (13→14) taken 119 times.
✗ Branch 15 (13→15) not taken.
✗ Branch 16 (17→18) not taken.
✗ Branch 17 (17→19) not taken.
✗ Branch 18 (21→22) not taken.
✗ Branch 19 (21→23) not taken.
|
119 | return (packageName.isSameBegining("Phoenix") || packageName.isSameBegining("phoenix")); |
| 56 | } | ||
| 57 | |||
| 58 | ///Generate CMake find_package commands for non-Phoenix dependencies | ||
| 59 | /** @param projectConfig : project configuration | ||
| 60 | * @return CMake find_package commands | ||
| 61 | */ | ||
| 62 | 3 | PString generateCmakeFindBody(const ProjectConfig & projectConfig){ | |
| 63 | 3 | PString cmakeFindBody; | |
| 64 |
2/2✓ Branch 0 (21→4) taken 17 times.
✓ Branch 1 (21→22) taken 3 times.
|
20 | for(PackageMap::const_iterator depIt = projectConfig.mapDependencies.begin(); depIt != projectConfig.mapDependencies.end(); ++depIt){ |
| 65 | 17 | const PPackageAttribute & pkgAttr = depIt->second; | |
| 66 |
4/4✓ Branch 0 (5→6) taken 17 times.
✓ Branch 2 (6→7) taken 17 times.
✓ Branch 4 (7→8) taken 2 times.
✓ Branch 5 (7→18) taken 15 times.
|
17 | if(!isPhoenixDependency(pkgAttr.getName())){ |
| 67 |
2/3✓ Branch 0 (8→9) taken 2 times.
✓ Branch 2 (10→11) taken 2 times.
✗ Branch 3 (10→18) not taken.
|
2 | if(!pkgAttr.getCmakeFind().empty()){ |
| 68 |
4/4✓ Branch 0 (11→12) taken 2 times.
✓ Branch 2 (12→13) taken 2 times.
✓ Branch 4 (13→14) taken 2 times.
✓ Branch 6 (14→15) taken 2 times.
|
2 | cmakeFindBody += "find_package("+pkgAttr.getCmakeFind()+")"; |
| 69 | } | ||
| 70 | } | ||
| 71 | } | ||
| 72 | 3 | return cmakeFindBody; | |
| 73 | ✗ | } | |
| 74 | |||
| 75 | ///Generate Phoenix pull_extra_module commands | ||
| 76 | /** @param projectConfig : project configuration | ||
| 77 | * @return Phoenix pull_extra_module commands | ||
| 78 | */ | ||
| 79 | 3 | PString generatePhoenixPullExtraModule(const ProjectConfig & projectConfig){ | |
| 80 | 3 | PString phoenixPullExtraModule; | |
| 81 |
2/2✓ Branch 0 (23→4) taken 17 times.
✓ Branch 1 (23→24) taken 3 times.
|
20 | for(PackageMap::const_iterator depIt = projectConfig.mapDependencies.begin(); depIt != projectConfig.mapDependencies.end(); ++depIt){ |
| 82 | 17 | const PPackageAttribute & pkgAttr = depIt->second; | |
| 83 |
4/4✓ Branch 0 (5→6) taken 17 times.
✓ Branch 2 (6→7) taken 17 times.
✓ Branch 4 (7→8) taken 15 times.
✓ Branch 5 (7→20) taken 2 times.
|
17 | if(isPhoenixDependency(pkgAttr.getName())){ |
| 84 |
7/7✓ Branch 0 (8→9) taken 15 times.
✓ Branch 2 (9→10) taken 15 times.
✓ Branch 4 (10→11) taken 15 times.
✓ Branch 6 (11→12) taken 15 times.
✓ Branch 8 (12→13) taken 15 times.
✓ Branch 10 (13→14) taken 15 times.
✓ Branch 12 (14→15) taken 15 times.
|
15 | phoenixPullExtraModule += "pull_extra_module(\""+pkgAttr.getName()+"\" \""+pkgAttr.getUrl()+"\")\n"; |
| 85 | } | ||
| 86 | } | ||
| 87 | 3 | return phoenixPullExtraModule; | |
| 88 | ✗ | } | |
| 89 | |||
| 90 | ///Generate Phoenix find module list | ||
| 91 | /** @param projectConfig : project configuration | ||
| 92 | * @return Phoenix find module list | ||
| 93 | */ | ||
| 94 | 3 | PString generatePhoenixFindModule(const ProjectConfig & projectConfig){ | |
| 95 | 3 | PString phoenixFindModule; | |
| 96 |
2/2✓ Branch 0 (16→4) taken 17 times.
✓ Branch 1 (16→17) taken 3 times.
|
20 | for(PackageMap::const_iterator depIt = projectConfig.mapDependencies.begin(); depIt != projectConfig.mapDependencies.end(); ++depIt){ |
| 97 | 17 | const PPackageAttribute & pkgAttr = depIt->second; | |
| 98 |
4/4✓ Branch 0 (5→6) taken 17 times.
✓ Branch 2 (6→7) taken 17 times.
✓ Branch 4 (7→8) taken 15 times.
✓ Branch 5 (7→13) taken 2 times.
|
17 | if(isPhoenixDependency(pkgAttr.getName())){ |
| 99 |
3/3✓ Branch 0 (8→9) taken 15 times.
✓ Branch 2 (9→10) taken 15 times.
✓ Branch 4 (10→11) taken 15 times.
|
15 | phoenixFindModule += " "+pkgAttr.getName(); |
| 100 | } | ||
| 101 | } | ||
| 102 | 3 | return phoenixFindModule; | |
| 103 | ✗ | } | |
| 104 | |||
| 105 | ///Generate Phoenix global dependencies variable | ||
| 106 | /** @param projectConfig : project configuration | ||
| 107 | * @return Phoenix global dependencies variable | ||
| 108 | */ | ||
| 109 | 3 | PString generatePhoenixGlobalDep(const ProjectConfig & projectConfig){ | |
| 110 | 3 | PString phoenixGlobalDep; | |
| 111 |
4/4✓ Branch 0 (3→4) taken 3 times.
✓ Branch 2 (4→5) taken 3 times.
✓ Branch 4 (5→6) taken 3 times.
✓ Branch 6 (6→7) taken 3 times.
|
3 | phoenixGlobalDep += "set(" + projectConfig.name.toUpper() + "_TEST_DEPENDENCIES\n"; |
| 112 |
4/4✓ Branch 0 (10→11) taken 3 times.
✓ Branch 2 (11→12) taken 3 times.
✓ Branch 4 (12→13) taken 3 times.
✓ Branch 6 (13→14) taken 3 times.
|
3 | phoenixGlobalDep += "\t" + projectConfig.name.toSnakeCase() + "\n"; |
| 113 |
3/3✓ Branch 0 (31→32) taken 20 times.
✓ Branch 2 (32→18) taken 17 times.
✓ Branch 3 (32→33) taken 3 times.
|
20 | for(PackageMap::const_reverse_iterator depIt = projectConfig.mapDependencies.rbegin(); depIt != projectConfig.mapDependencies.rend(); ++depIt){ |
| 114 |
1/1✓ Branch 0 (18→19) taken 17 times.
|
17 | const PPackageAttribute & pkgAttr = depIt->second; |
| 115 |
4/4✓ Branch 0 (19→20) taken 17 times.
✓ Branch 2 (20→21) taken 17 times.
✓ Branch 4 (21→22) taken 15 times.
✓ Branch 5 (21→29) taken 2 times.
|
17 | if(isPhoenixDependency(pkgAttr.getName())){ |
| 116 |
4/4✓ Branch 0 (22→23) taken 15 times.
✓ Branch 2 (23→24) taken 15 times.
✓ Branch 4 (24→25) taken 15 times.
✓ Branch 6 (25→26) taken 15 times.
|
15 | phoenixGlobalDep += "\t"+pkgAttr.getCmakeLib()+"\n"; |
| 117 | } | ||
| 118 | } | ||
| 119 |
1/1✓ Branch 0 (33→34) taken 3 times.
|
3 | phoenixGlobalDep += ")"; |
| 120 | 3 | return phoenixGlobalDep; | |
| 121 | ✗ | } | |
| 122 | |||
| 123 | ///Generate target_link_libraries command | ||
| 124 | /** @param projectConfig : project configuration | ||
| 125 | * @return target_link_libraries command | ||
| 126 | */ | ||
| 127 | 3 | PString generateTargetLinkBody(const ProjectConfig & projectConfig){ | |
| 128 | 3 | PString targetLinkBody; | |
| 129 |
4/4✓ Branch 0 (3→4) taken 3 times.
✓ Branch 2 (4→5) taken 3 times.
✓ Branch 4 (5→6) taken 3 times.
✓ Branch 6 (6→7) taken 3 times.
|
3 | targetLinkBody += "target_link_libraries("+projectConfig.name.toSnakeCase()+" "; |
| 130 |
2/2✓ Branch 0 (23→11) taken 17 times.
✓ Branch 1 (23→24) taken 3 times.
|
20 | for(PackageMap::const_iterator depIt = projectConfig.mapDependencies.begin(); depIt != projectConfig.mapDependencies.end(); ++depIt){ |
| 131 | 17 | const PPackageAttribute & pkgAttr = depIt->second; | |
| 132 |
4/4✓ Branch 0 (12→13) taken 17 times.
✓ Branch 2 (13→14) taken 17 times.
✓ Branch 4 (14→15) taken 2 times.
✓ Branch 5 (14→20) taken 15 times.
|
17 | if(!isPhoenixDependency(pkgAttr.getName())){ |
| 133 |
3/3✓ Branch 0 (15→16) taken 2 times.
✓ Branch 2 (16→17) taken 2 times.
✓ Branch 4 (17→18) taken 2 times.
|
2 | targetLinkBody += pkgAttr.getCmakeLib()+" "; |
| 134 | } | ||
| 135 | } | ||
| 136 | // Add Phoenix dependencies (to ensure proper linking even if phoenix_create_find should handle it) | ||
| 137 |
2/2✓ Branch 0 (37→25) taken 17 times.
✓ Branch 1 (37→38) taken 3 times.
|
20 | for(PackageMap::const_iterator depIt = projectConfig.mapDependencies.begin(); depIt != projectConfig.mapDependencies.end(); ++depIt){ |
| 138 | 17 | const PPackageAttribute & pkgAttr = depIt->second; | |
| 139 |
4/4✓ Branch 0 (26→27) taken 17 times.
✓ Branch 2 (27→28) taken 17 times.
✓ Branch 4 (28→29) taken 15 times.
✓ Branch 5 (28→34) taken 2 times.
|
17 | if(isPhoenixDependency(pkgAttr.getName())){ |
| 140 |
3/3✓ Branch 0 (29→30) taken 15 times.
✓ Branch 2 (30→31) taken 15 times.
✓ Branch 4 (31→32) taken 15 times.
|
15 | targetLinkBody += pkgAttr.getCmakeLib()+" "; |
| 141 | } | ||
| 142 | } | ||
| 143 |
1/1✓ Branch 0 (38→39) taken 3 times.
|
3 | targetLinkBody += ")\n"; |
| 144 | 3 | return targetLinkBody; | |
| 145 | ✗ | } | |
| 146 | |||
| 147 | ///Generate Pixi dependencies | ||
| 148 | /** @param projectConfig : project configuration | ||
| 149 | * @return Pixi dependencies | ||
| 150 | */ | ||
| 151 | 3 | PString generatePixiBody(const ProjectConfig & projectConfig){ | |
| 152 | 3 | PString pixiBody; | |
| 153 |
2/2✓ Branch 0 (69→4) taken 17 times.
✓ Branch 1 (69→70) taken 3 times.
|
20 | for(PackageMap::const_iterator depIt = projectConfig.mapDependencies.begin(); depIt != projectConfig.mapDependencies.end(); ++depIt){ |
| 154 | 17 | const PPackageAttribute & pkgAttr = depIt->second; | |
| 155 |
2/2✓ Branch 0 (5→6) taken 17 times.
✓ Branch 2 (6→7) taken 17 times.
|
17 | PString pixi_name = pkgAttr.getPixiName().toLower(); |
| 156 |
2/2✓ Branch 0 (7→8) taken 17 times.
✓ Branch 2 (8→9) taken 17 times.
|
17 | PString min_version = pkgAttr.getMinVersion(); |
| 157 |
2/2✓ Branch 0 (9→10) taken 17 times.
✓ Branch 2 (10→11) taken 17 times.
|
17 | PString max_version = pkgAttr.getMaxVersion(); |
| 158 |
2/3✓ Branch 0 (11→12) taken 17 times.
✗ Branch 2 (12→13) not taken.
✓ Branch 3 (12→14) taken 17 times.
|
17 | if(pixi_name == "") continue; |
| 159 |
5/6✓ Branch 0 (15→16) taken 2 times.
✓ Branch 1 (15→19) taken 15 times.
✓ Branch 2 (17→18) taken 2 times.
✗ Branch 3 (17→19) not taken.
✓ Branch 4 (20→21) taken 2 times.
✓ Branch 5 (20→25) taken 15 times.
|
17 | else if(min_version.empty() && max_version.empty()){ |
| 160 |
2/2✓ Branch 0 (21→22) taken 2 times.
✓ Branch 2 (22→23) taken 2 times.
|
2 | pixiBody += pixi_name + " = \"*\"\n"; |
| 161 |
2/2✓ Branch 0 (26→27) taken 2 times.
✓ Branch 1 (26→35) taken 13 times.
|
15 | }else if(max_version.empty()){ |
| 162 |
4/4✓ Branch 0 (27→28) taken 2 times.
✓ Branch 2 (28→29) taken 2 times.
✓ Branch 4 (29→30) taken 2 times.
✓ Branch 6 (30→31) taken 2 times.
|
2 | pixiBody += pixi_name + " = \"" + min_version + "\"\n"; |
| 163 | }else{ | ||
| 164 |
3/3✓ Branch 0 (35→36) taken 13 times.
✓ Branch 2 (36→37) taken 13 times.
✓ Branch 4 (37→38) taken 13 times.
|
13 | pixiBody += pixi_name + " = \"" + min_version; |
| 165 |
4/7✓ Branch 0 (41→42) taken 13 times.
✗ Branch 1 (41→45) not taken.
✓ Branch 2 (43→44) taken 13 times.
✗ Branch 3 (43→45) not taken.
✓ Branch 4 (46→47) taken 13 times.
✗ Branch 5 (46→48) not taken.
✓ Branch 6 (47→48) taken 13 times.
|
13 | if(!min_version.empty() && !max_version.empty()) pixiBody += ","; |
| 166 |
2/2✓ Branch 0 (48→49) taken 13 times.
✓ Branch 2 (49→50) taken 13 times.
|
13 | pixiBody += max_version + "\"\n"; |
| 167 | } | ||
| 168 | 17 | } | |
| 169 | 3 | return pixiBody; | |
| 170 | ✗ | } | |
| 171 | |||
| 172 | ///Generate markdown list of Phoenix dependencies | ||
| 173 | /** @param projectConfig : project configuration | ||
| 174 | * @return markdown list of Phoenix dependencies | ||
| 175 | */ | ||
| 176 | 3 | PString generateMarkdownDepList(const ProjectConfig & projectConfig){ | |
| 177 | 3 | PString packageMdList; | |
| 178 |
2/2✓ Branch 0 (23→4) taken 17 times.
✓ Branch 1 (23→24) taken 3 times.
|
20 | for(PackageMap::const_iterator depIt = projectConfig.mapDependencies.begin(); depIt != projectConfig.mapDependencies.end(); ++depIt){ |
| 179 | 17 | const PPackageAttribute & pkgAttr = depIt->second; | |
| 180 |
4/4✓ Branch 0 (5→6) taken 17 times.
✓ Branch 2 (6→7) taken 17 times.
✓ Branch 4 (7→8) taken 15 times.
✓ Branch 5 (7→20) taken 2 times.
|
17 | if(isPhoenixDependency(pkgAttr.getName())){ |
| 181 |
7/7✓ Branch 0 (8→9) taken 15 times.
✓ Branch 2 (9→10) taken 15 times.
✓ Branch 4 (10→11) taken 15 times.
✓ Branch 6 (11→12) taken 15 times.
✓ Branch 8 (12→13) taken 15 times.
✓ Branch 10 (13→14) taken 15 times.
✓ Branch 12 (14→15) taken 15 times.
|
15 | packageMdList += "- ["+pkgAttr.getName()+"]("+pkgAttr.getUrl()+")\n"; |
| 182 | } | ||
| 183 | } | ||
| 184 | 3 | return packageMdList; | |
| 185 | ✗ | } | |
| 186 | |||
| 187 | ///Generate author list for Pixi | ||
| 188 | /** @param projectConfig : project configuration | ||
| 189 | * @return author list for Pixi | ||
| 190 | */ | ||
| 191 | 3 | PString generateAuthorListPixi(const ProjectConfig & projectConfig){ | |
| 192 | 3 | PString authorListPixi; | |
| 193 |
1/1✓ Branch 0 (3→4) taken 3 times.
|
3 | authorListPixi += "authors = [\n"; |
| 194 |
2/2✓ Branch 0 (25→5) taken 6 times.
✓ Branch 1 (25→26) taken 3 times.
|
9 | for(ProjectMembersMap::const_iterator it = projectConfig.authorMap.begin(); it != projectConfig.authorMap.end(); ++it){ |
| 195 | 6 | const PProjectMembers & author = it->second; | |
| 196 |
10/10✓ Branch 0 (6→7) taken 6 times.
✓ Branch 2 (7→8) taken 6 times.
✓ Branch 4 (8→9) taken 6 times.
✓ Branch 6 (9→10) taken 6 times.
✓ Branch 8 (10→11) taken 6 times.
✓ Branch 10 (11→12) taken 6 times.
✓ Branch 12 (12→13) taken 6 times.
✓ Branch 14 (13→14) taken 6 times.
✓ Branch 16 (14→15) taken 6 times.
✓ Branch 18 (15→16) taken 6 times.
|
6 | authorListPixi += " \"" + author.getFirstName() + " " + author.getLastName() + " <" + author.getEmail() + ">\",\n"; |
| 197 | } | ||
| 198 |
1/1✓ Branch 0 (26→27) taken 3 times.
|
3 | authorListPixi += "]\n"; |
| 199 | 3 | return authorListPixi; | |
| 200 | ✗ | } | |
| 201 | |||
| 202 | ///Generate project author list for codemeta.json | ||
| 203 | /** @param projectConfig : project configuration | ||
| 204 | * @return project author list | ||
| 205 | */ | ||
| 206 | 3 | PString generateProjectAuthorList(const ProjectConfig & projectConfig){ | |
| 207 | 3 | PString projectAuthorList; | |
| 208 | 3 | bool firstAuthor = true; | |
| 209 |
2/2✓ Branch 0 (40→4) taken 6 times.
✓ Branch 1 (40→41) taken 3 times.
|
9 | for(ProjectMembersMap::const_iterator it = projectConfig.authorMap.begin(); it != projectConfig.authorMap.end(); ++it){ |
| 210 | 6 | const PProjectMembers & author = it->second; | |
| 211 |
3/3✓ Branch 0 (5→6) taken 3 times.
✓ Branch 1 (5→7) taken 3 times.
✓ Branch 2 (6→7) taken 3 times.
|
6 | if(!firstAuthor) projectAuthorList += ",\n"; |
| 212 |
1/1✓ Branch 0 (7→8) taken 6 times.
|
6 | projectAuthorList += " {\n"; |
| 213 |
1/1✓ Branch 0 (8→9) taken 6 times.
|
6 | projectAuthorList += " \"@type\": \"Person\",\n"; |
| 214 |
4/4✓ Branch 0 (9→10) taken 6 times.
✓ Branch 2 (10→11) taken 6 times.
✓ Branch 4 (11→12) taken 6 times.
✓ Branch 6 (12→13) taken 6 times.
|
6 | projectAuthorList += " \"givenName\": \"" + author.getFirstName() + "\",\n"; |
| 215 |
4/4✓ Branch 0 (15→16) taken 6 times.
✓ Branch 2 (16→17) taken 6 times.
✓ Branch 4 (17→18) taken 6 times.
✓ Branch 6 (18→19) taken 6 times.
|
6 | projectAuthorList += " \"familyName\": \"" + author.getLastName() + "\",\n"; |
| 216 |
4/4✓ Branch 0 (21→22) taken 6 times.
✓ Branch 2 (22→23) taken 6 times.
✓ Branch 4 (23→24) taken 6 times.
✓ Branch 6 (24→25) taken 6 times.
|
6 | projectAuthorList += " \"email\": \"" + author.getEmail() + "\",\n"; |
| 217 |
1/1✓ Branch 0 (27→28) taken 6 times.
|
6 | projectAuthorList += " \"affiliation\": {\n"; |
| 218 |
1/1✓ Branch 0 (28→29) taken 6 times.
|
6 | projectAuthorList += " \"@type\": \"Organization\",\n"; |
| 219 |
4/4✓ Branch 0 (29→30) taken 6 times.
✓ Branch 2 (30→31) taken 6 times.
✓ Branch 4 (31→32) taken 6 times.
✓ Branch 6 (32→33) taken 6 times.
|
6 | projectAuthorList += " \"name\": \"" + author.getAffiliation() + "\"\n"; |
| 220 |
1/1✓ Branch 0 (35→36) taken 6 times.
|
6 | projectAuthorList += " }\n"; |
| 221 |
1/1✓ Branch 0 (36→37) taken 6 times.
|
6 | projectAuthorList += " }"; |
| 222 | 6 | firstAuthor = false; | |
| 223 | } | ||
| 224 | 3 | return projectAuthorList; | |
| 225 | ✗ | } | |
| 226 | |||
| 227 | ///Generate project contributor list for codemeta.json | ||
| 228 | /** @param projectConfig : project configuration | ||
| 229 | * @return project contributor list | ||
| 230 | */ | ||
| 231 | 3 | PString generateProjectContributorList(const ProjectConfig & projectConfig){ | |
| 232 | 3 | PString projectContributorList; | |
| 233 | 3 | bool firstContributor = true; | |
| 234 |
2/2✓ Branch 0 (40→4) taken 3 times.
✓ Branch 1 (40→41) taken 3 times.
|
6 | for(ProjectMembersMap::const_iterator it = projectConfig.contributorMap.begin(); it != projectConfig.contributorMap.end(); ++it){ |
| 235 | 3 | const PProjectMembers & contributor = it->second; | |
| 236 |
1/3✗ Branch 0 (5→6) not taken.
✓ Branch 1 (5→7) taken 3 times.
✗ Branch 2 (6→7) not taken.
|
3 | if(!firstContributor) projectContributorList += ",\n"; |
| 237 |
1/1✓ Branch 0 (7→8) taken 3 times.
|
3 | projectContributorList += " {\n"; |
| 238 |
1/1✓ Branch 0 (8→9) taken 3 times.
|
3 | projectContributorList += " \"@type\": \"Person\",\n"; |
| 239 |
4/4✓ Branch 0 (9→10) taken 3 times.
✓ Branch 2 (10→11) taken 3 times.
✓ Branch 4 (11→12) taken 3 times.
✓ Branch 6 (12→13) taken 3 times.
|
3 | projectContributorList += " \"givenName\": \"" + contributor.getFirstName() + "\",\n"; |
| 240 |
4/4✓ Branch 0 (15→16) taken 3 times.
✓ Branch 2 (16→17) taken 3 times.
✓ Branch 4 (17→18) taken 3 times.
✓ Branch 6 (18→19) taken 3 times.
|
3 | projectContributorList += " \"familyName\": \"" + contributor.getLastName() + "\",\n"; |
| 241 |
4/4✓ Branch 0 (21→22) taken 3 times.
✓ Branch 2 (22→23) taken 3 times.
✓ Branch 4 (23→24) taken 3 times.
✓ Branch 6 (24→25) taken 3 times.
|
3 | projectContributorList += " \"email\": \"" + contributor.getEmail() + "\",\n"; |
| 242 |
1/1✓ Branch 0 (27→28) taken 3 times.
|
3 | projectContributorList += " \"affiliation\": {\n"; |
| 243 |
1/1✓ Branch 0 (28→29) taken 3 times.
|
3 | projectContributorList += " \"@type\": \"Organization\",\n"; |
| 244 |
4/4✓ Branch 0 (29→30) taken 3 times.
✓ Branch 2 (30→31) taken 3 times.
✓ Branch 4 (31→32) taken 3 times.
✓ Branch 6 (32→33) taken 3 times.
|
3 | projectContributorList += " \"name\": \"" + contributor.getAffiliation() + "\"\n"; |
| 245 |
1/1✓ Branch 0 (35→36) taken 3 times.
|
3 | projectContributorList += " }\n"; |
| 246 |
1/1✓ Branch 0 (36→37) taken 3 times.
|
3 | projectContributorList += " }"; |
| 247 | 3 | firstContributor = false; | |
| 248 | } | ||
| 249 | 3 | return projectContributorList; | |
| 250 | ✗ | } | |
| 251 | |||
| 252 | ///Generate maintainer information for codemeta.json | ||
| 253 | /** @param projectConfig : project configuration | ||
| 254 | * @return maintainer information | ||
| 255 | */ | ||
| 256 | 3 | PString generateMaintainer(const ProjectConfig & projectConfig){ | |
| 257 | 3 | PString maintainer; | |
| 258 | 3 | const PProjectMembers & maintainerPerson = projectConfig.maintainerMap.begin()->second; | |
| 259 |
1/1✓ Branch 0 (5→6) taken 3 times.
|
3 | maintainer += " \"@type\": \"Person\",\n"; |
| 260 |
4/4✓ Branch 0 (6→7) taken 3 times.
✓ Branch 2 (7→8) taken 3 times.
✓ Branch 4 (8→9) taken 3 times.
✓ Branch 6 (9→10) taken 3 times.
|
3 | maintainer += " \"givenName\": \"" + maintainerPerson.getFirstName() + "\",\n"; |
| 261 |
4/4✓ Branch 0 (12→13) taken 3 times.
✓ Branch 2 (13→14) taken 3 times.
✓ Branch 4 (14→15) taken 3 times.
✓ Branch 6 (15→16) taken 3 times.
|
3 | maintainer += " \"familyName\": \"" + maintainerPerson.getLastName() + "\",\n"; |
| 262 |
4/4✓ Branch 0 (18→19) taken 3 times.
✓ Branch 2 (19→20) taken 3 times.
✓ Branch 4 (20→21) taken 3 times.
✓ Branch 6 (21→22) taken 3 times.
|
3 | maintainer += " \"email\": \"" + maintainerPerson.getEmail() + "\",\n"; |
| 263 |
1/1✓ Branch 0 (24→25) taken 3 times.
|
3 | maintainer += " \"affiliation\": {\n"; |
| 264 |
1/1✓ Branch 0 (25→26) taken 3 times.
|
3 | maintainer += " \"@type\": \"Organization\",\n"; |
| 265 |
4/4✓ Branch 0 (26→27) taken 3 times.
✓ Branch 2 (27→28) taken 3 times.
✓ Branch 4 (28→29) taken 3 times.
✓ Branch 6 (29→30) taken 3 times.
|
3 | maintainer += " \"name\": \"" + maintainerPerson.getAffiliation() + "\"\n"; |
| 266 |
1/1✓ Branch 0 (32→33) taken 3 times.
|
3 | maintainer += " }"; |
| 267 | 3 | return maintainer; | |
| 268 | ✗ | } | |
| 269 | |||
| 270 | ///Generate keywords list for codemeta.json | ||
| 271 | /** @param projectConfig : project configuration | ||
| 272 | * @return keywords list | ||
| 273 | */ | ||
| 274 | 3 | PString generateKeywordsBody(const ProjectConfig & projectConfig){ | |
| 275 | 3 | PString keywordsBody; | |
| 276 |
1/2✓ Branch 0 (4→5) taken 3 times.
✗ Branch 1 (4→27) not taken.
|
3 | if(!projectConfig.keywordList.empty()){ |
| 277 | 3 | bool firstKeyword = true; | |
| 278 |
2/2✓ Branch 0 (25→6) taken 15 times.
✓ Branch 1 (25→26) taken 3 times.
|
36 | for(std::vector<PString>::const_iterator it = projectConfig.keywordList.begin(); it != projectConfig.keywordList.end(); ++it){ |
| 279 |
3/3✓ Branch 0 (6→7) taken 12 times.
✓ Branch 1 (6→8) taken 3 times.
✓ Branch 2 (7→8) taken 12 times.
|
15 | if(!firstKeyword) keywordsBody += ",\n"; |
| 280 |
3/3✓ Branch 0 (10→11) taken 15 times.
✓ Branch 2 (11→12) taken 15 times.
✓ Branch 4 (12→13) taken 15 times.
|
15 | keywordsBody += " \"" + *it + "\""; |
| 281 | 15 | firstKeyword = false; | |
| 282 | } | ||
| 283 | } | ||
| 284 | 3 | return keywordsBody; | |
| 285 | ✗ | } | |
| 286 | |||
| 287 | ///Generate the nanobind cmake sources list | ||
| 288 | /** @param projectConfig : project configuration | ||
| 289 | * @param vecClassConfigFile : vector of class config files | ||
| 290 | * @param mode : generator mode | ||
| 291 | * @return nanobind cmake sources list | ||
| 292 | */ | ||
| 293 | 1 | PString generateNanobindCmakeSources(const ProjectConfig & projectConfig, const PVecPath & vecClassConfigFile, const GeneratorMode & mode){ | |
| 294 | 1 | PString nanobindSources; | |
| 295 |
1/1✓ Branch 0 (3→4) taken 1 times.
|
1 | nanobindSources += "# We are now ready to compile the actual extension module\n"; |
| 296 | |||
| 297 |
2/2✓ Branch 0 (63→6) taken 2 times.
✓ Branch 1 (63→64) taken 1 times.
|
4 | for(const PPath & classConfigFile : vecClassConfigFile){ |
| 298 |
3/3✓ Branch 0 (8→9) taken 2 times.
✓ Branch 2 (9→10) taken 2 times.
✓ Branch 4 (10→11) taken 2 times.
|
2 | PPath baseFileName = classConfigFile.getFileName().eraseExtension(); |
| 299 |
2/2✓ Branch 0 (12→13) taken 2 times.
✓ Branch 2 (13→14) taken 2 times.
|
2 | PString bindingSource = baseFileName + "_binding.cpp"; |
| 300 |
3/3✓ Branch 0 (15→16) taken 2 times.
✓ Branch 2 (16→17) taken 2 times.
✓ Branch 4 (17→18) taken 2 times.
|
2 | PString fileModuleName = baseFileName.toLower() + "_module"; |
| 301 | |||
| 302 |
1/1✓ Branch 0 (20→21) taken 2 times.
|
2 | nanobindSources += "nanobind_add_module(\n"; |
| 303 |
3/3✓ Branch 0 (21→22) taken 2 times.
✓ Branch 2 (22→23) taken 2 times.
✓ Branch 4 (23→24) taken 2 times.
|
2 | nanobindSources += "\t" + fileModuleName + " # Name of the module\n"; |
| 304 |
1/1✓ Branch 0 (26→27) taken 2 times.
|
2 | nanobindSources += "\tSTABLE_ABI # Compatible Python 3.12+ stable ABI\n"; |
| 305 |
1/1✓ Branch 0 (27→28) taken 2 times.
|
2 | nanobindSources += "\tNB_STATIC # Static linking\n"; |
| 306 |
1/1✓ Branch 0 (28→29) taken 2 times.
|
2 | nanobindSources += "\tLTO # Link-time optimization\n"; |
| 307 |
3/3✓ Branch 0 (29→30) taken 2 times.
✓ Branch 2 (30→31) taken 2 times.
✓ Branch 4 (31→32) taken 2 times.
|
2 | nanobindSources += "\t" + bindingSource + " # Source file\n"; |
| 308 |
1/1✓ Branch 0 (34→35) taken 2 times.
|
2 | nanobindSources += ")\n"; |
| 309 |
6/6✓ Branch 0 (35→36) taken 2 times.
✓ Branch 2 (36→37) taken 2 times.
✓ Branch 4 (37→38) taken 2 times.
✓ Branch 6 (38→39) taken 2 times.
✓ Branch 8 (39→40) taken 2 times.
✓ Branch 10 (40→41) taken 2 times.
|
2 | nanobindSources += "target_link_libraries(" + fileModuleName + " PRIVATE " + projectConfig.name.toSnakeCase() + ")\n"; |
| 310 |
3/3✓ Branch 0 (46→47) taken 2 times.
✓ Branch 2 (47→48) taken 2 times.
✓ Branch 4 (48→49) taken 2 times.
|
2 | nanobindSources += "install(TARGETS " + fileModuleName + " LIBRARY DESTINATION ${LIBRARY_DIRECTORY} ARCHIVE DESTINATION ${LIBRARY_DIRECTORY})\n\n"; |
| 311 | 2 | } | |
| 312 | |||
| 313 | 1 | return nanobindSources; | |
| 314 | ✗ | } | |
| 315 | |||
| 316 | ///Generate the replacement map for placeholders | ||
| 317 | /** @param projectConfig : project configuration | ||
| 318 | * @param mode : generator mode | ||
| 319 | * @param cmakeFindBody : CMake find_package commands | ||
| 320 | * @param phoenixPullExtraModule : Phoenix pull_extra_module commands | ||
| 321 | * @param phoenixFindModule : Phoenix find module list | ||
| 322 | * @param phoenixGlobalDep : Phoenix global dependencies variable | ||
| 323 | * @param targetLinkBody : target_link_libraries command | ||
| 324 | * @param pixiBody : Pixi dependencies | ||
| 325 | * @param authorListPixi : author list for Pixi | ||
| 326 | * @param projectAuthorList : project author list | ||
| 327 | * @param projectContributorList : project contributor list | ||
| 328 | * @param maintainer : maintainer information | ||
| 329 | * @param keywordsBody : keywords list | ||
| 330 | * @param dateStr : creation date string | ||
| 331 | * @param nanobindCMakeSources : nanobind cmake sources list | ||
| 332 | * @return replacement map for placeholders | ||
| 333 | */ | ||
| 334 | 3 | PMapString generateReplacementMap(const ProjectConfig & projectConfig, const GeneratorMode & mode, const PString & cmakeFindBody, const PString & phoenixPullExtraModule, | |
| 335 | const PString & phoenixFindModule, const PString & phoenixGlobalDep, const PString & targetLinkBody, | ||
| 336 | const PString & pixiBody, const PString & markdownDepList, const PString & authorListPixi, | ||
| 337 | const PString & projectAuthorList, const PString & projectContributorList, const PString & maintainer, | ||
| 338 | const PString & keywordsBody, const PString & dateStr, const PString & nanobindCMakeSources) | ||
| 339 | { | ||
| 340 | 3 | PMapString mapReplace; | |
| 341 |
2/2✓ Branch 0 (3→4) taken 1 times.
✓ Branch 1 (3→9) taken 2 times.
|
3 | if(mode.type == ProjectType::NANOBIND_WRAPPER){ |
| 342 |
3/3✓ Branch 0 (4→5) taken 1 times.
✓ Branch 2 (5→6) taken 1 times.
✓ Branch 4 (6→7) taken 1 times.
|
1 | mapReplace["xxxnanobind_sourcesxxx"] = nanobindCMakeSources; //nanobind cmake sources |
| 343 | } | ||
| 344 |
3/3✓ Branch 0 (9→10) taken 3 times.
✓ Branch 2 (10→11) taken 3 times.
✓ Branch 4 (11→12) taken 3 times.
|
3 | mapReplace["XXXProjectNameXXX"] = projectConfig.name; //project name |
| 345 |
4/4✓ Branch 0 (13→14) taken 3 times.
✓ Branch 2 (14→15) taken 3 times.
✓ Branch 4 (15→16) taken 3 times.
✓ Branch 6 (16→17) taken 3 times.
|
3 | mapReplace["XXXPROJECT_NAMEXXX"] = projectConfig.name.toUpper(); //project name uppercase |
| 346 |
4/4✓ Branch 0 (19→20) taken 3 times.
✓ Branch 2 (20→21) taken 3 times.
✓ Branch 4 (21→22) taken 3 times.
✓ Branch 6 (22→23) taken 3 times.
|
3 | mapReplace["xxxproject_namexxx"] = projectConfig.name.toSnakeCase(); //project library |
| 347 |
3/3✓ Branch 0 (25→26) taken 3 times.
✓ Branch 2 (26→27) taken 3 times.
✓ Branch 4 (27→28) taken 3 times.
|
3 | mapReplace["XXXProjectNameDescriptionXXX"] = projectConfig.description; //description |
| 348 |
3/3✓ Branch 0 (29→30) taken 3 times.
✓ Branch 2 (30→31) taken 3 times.
✓ Branch 4 (31→32) taken 3 times.
|
3 | mapReplace["XXXProjectNameUrlXXX"] = projectConfig.url; //project url |
| 349 |
3/3✓ Branch 0 (33→34) taken 3 times.
✓ Branch 2 (34→35) taken 3 times.
✓ Branch 4 (35→36) taken 3 times.
|
3 | mapReplace["XXXProjectVersionXXX"] = projectConfig.version; //project version |
| 350 |
3/3✓ Branch 0 (37→38) taken 3 times.
✓ Branch 2 (38→39) taken 3 times.
✓ Branch 4 (39→40) taken 3 times.
|
3 | mapReplace["XXXProjectNameHomepageUrlXXX"] = projectConfig.url; //project doc url (TODO add it or deduce it from the project url for gitlab) |
| 351 |
3/3✓ Branch 0 (41→42) taken 3 times.
✓ Branch 2 (42→43) taken 3 times.
✓ Branch 4 (43→44) taken 3 times.
|
3 | mapReplace["XXXProjectNameRunnerTagXXX"] = projectConfig.runnerTag; //Project CI runner tag |
| 352 |
3/3✓ Branch 0 (45→46) taken 3 times.
✓ Branch 2 (46→47) taken 3 times.
✓ Branch 4 (47→48) taken 3 times.
|
3 | mapReplace["XXXProjectFindPackageDependenciesXXX"] = cmakeFindBody; //project find_package |
| 353 |
3/3✓ Branch 0 (49→50) taken 3 times.
✓ Branch 2 (50→51) taken 3 times.
✓ Branch 4 (51→52) taken 3 times.
|
3 | mapReplace["XXXProjectPhoenixDependenciesXXX"] = phoenixPullExtraModule; //project pull_extra_module |
| 354 |
3/3✓ Branch 0 (53→54) taken 3 times.
✓ Branch 2 (54→55) taken 3 times.
✓ Branch 4 (55→56) taken 3 times.
|
3 | mapReplace["XXXProjectNameCMakeFindDependenciesXXX"] = phoenixFindModule; //project dependencies of phoenix_create_find |
| 355 |
3/3✓ Branch 0 (57→58) taken 3 times.
✓ Branch 2 (58→59) taken 3 times.
✓ Branch 4 (59→60) taken 3 times.
|
3 | mapReplace["XXXProjectDependenciesCMakeVarXXX"] = phoenixGlobalDep; //cmake variable to hold test dependencies |
| 356 |
3/3✓ Branch 0 (61→62) taken 3 times.
✓ Branch 2 (62→63) taken 3 times.
✓ Branch 4 (63→64) taken 3 times.
|
3 | mapReplace["XXXProjectNameTargetLinkLinDependenciesXXX"] = targetLinkBody; //full target_link_library command of generated lib |
| 357 |
5/5✓ Branch 0 (65→66) taken 3 times.
✓ Branch 2 (66→67) taken 3 times.
✓ Branch 4 (67→68) taken 3 times.
✓ Branch 6 (68→69) taken 3 times.
✓ Branch 8 (69→70) taken 3 times.
|
3 | mapReplace["XXXCxxWorkflowUrlXXX"] = projectConfig.ciToolkitUrl+"@"+projectConfig.ciToolkitVersion; //Url and version of the CI workflow |
| 358 |
4/4✓ Branch 0 (73→74) taken 3 times.
✓ Branch 2 (74→75) taken 3 times.
✓ Branch 4 (75→76) taken 3 times.
✓ Branch 6 (76→77) taken 3 times.
|
3 | mapReplace["xxxphoenixprojectpixipackagenamexxx"] = projectConfig.name.toLower(); //name of the pixi package |
| 359 |
3/3✓ Branch 0 (79→80) taken 3 times.
✓ Branch 2 (80→81) taken 3 times.
✓ Branch 4 (81→82) taken 3 times.
|
3 | mapReplace["xxxprojectnamepixiextradependenciesxxx"] = pixiBody; //extra pixi dependencies |
| 360 |
3/3✓ Branch 0 (83→84) taken 3 times.
✓ Branch 2 (84→85) taken 3 times.
✓ Branch 4 (85→86) taken 3 times.
|
3 | mapReplace["XXXProjectNameMarkdownListDependenciesXXX"] = markdownDepList; //markdown list of Phoenix dependencies |
| 361 |
3/3✓ Branch 0 (87→88) taken 3 times.
✓ Branch 2 (88→89) taken 3 times.
✓ Branch 4 (89→90) taken 3 times.
|
3 | mapReplace["XXXcreationDateXXX"] = dateStr; //creation date |
| 362 |
3/3✓ Branch 0 (91→92) taken 3 times.
✓ Branch 2 (92→93) taken 3 times.
✓ Branch 4 (93→94) taken 3 times.
|
3 | mapReplace["XXXProjectAuthorListPixiXXX"] = authorListPixi; //author list for pixi.toml |
| 363 |
3/3✓ Branch 0 (95→96) taken 3 times.
✓ Branch 2 (96→97) taken 3 times.
✓ Branch 4 (97→98) taken 3 times.
|
3 | mapReplace["XXXAuthorListXXX"] = projectAuthorList; //author list for codemeta.json |
| 364 |
3/3✓ Branch 0 (99→100) taken 3 times.
✓ Branch 2 (100→101) taken 3 times.
✓ Branch 4 (101→102) taken 3 times.
|
3 | mapReplace["XXXContributorListXXX"] = projectContributorList; //contributor list for codemeta.json |
| 365 |
3/3✓ Branch 0 (103→104) taken 3 times.
✓ Branch 2 (104→105) taken 3 times.
✓ Branch 4 (105→106) taken 3 times.
|
3 | mapReplace["XXXMaintainerXXX"] = maintainer; //maintainer for codemeta.json |
| 366 |
3/3✓ Branch 0 (107→108) taken 3 times.
✓ Branch 2 (108→109) taken 3 times.
✓ Branch 4 (109→110) taken 3 times.
|
3 | mapReplace["XXXKeywordListsXXX"] = keywordsBody; //keyword list for codemeta.json |
| 367 | 3 | return mapReplace; | |
| 368 | ✗ | } | |
| 369 | |||
| 370 | ///Generate all replacement data for project generation | ||
| 371 | /** @param projectConfig : project configuration | ||
| 372 | * @return replacement map for placeholders | ||
| 373 | */ | ||
| 374 | 3 | PMapString generateAllReplacementData(const ProjectConfig & projectConfig, const GeneratorMode & mode, const PVecPath & vecClassConfigFile){ | |
| 375 | // Generate various bodies using dedicated functions | ||
| 376 |
1/1✓ Branch 0 (2→3) taken 3 times.
|
3 | PString cmakeFindBody = generateCmakeFindBody(projectConfig); |
| 377 |
1/1✓ Branch 0 (3→4) taken 3 times.
|
3 | PString phoenixPullExtraModule = generatePhoenixPullExtraModule(projectConfig); |
| 378 |
1/1✓ Branch 0 (4→5) taken 3 times.
|
3 | PString phoenixFindModule = generatePhoenixFindModule(projectConfig); |
| 379 |
1/1✓ Branch 0 (5→6) taken 3 times.
|
3 | PString phoenixGlobalDep = generatePhoenixGlobalDep(projectConfig); |
| 380 |
1/1✓ Branch 0 (6→7) taken 3 times.
|
3 | PString targetLinkBody = generateTargetLinkBody(projectConfig); |
| 381 |
1/1✓ Branch 0 (7→8) taken 3 times.
|
3 | PString pixiBody = generatePixiBody(projectConfig); |
| 382 |
1/1✓ Branch 0 (8→9) taken 3 times.
|
3 | PString markdownDepList = generateMarkdownDepList(projectConfig); |
| 383 |
1/1✓ Branch 0 (9→10) taken 3 times.
|
3 | PString authorListPixi = generateAuthorListPixi(projectConfig); |
| 384 |
1/1✓ Branch 0 (10→11) taken 3 times.
|
3 | PString projectAuthorList = generateProjectAuthorList(projectConfig); |
| 385 |
1/1✓ Branch 0 (11→12) taken 3 times.
|
3 | PString projectContributorList = generateProjectContributorList(projectConfig); |
| 386 |
1/1✓ Branch 0 (12→13) taken 3 times.
|
3 | PString maintainer = generateMaintainer(projectConfig); |
| 387 |
1/1✓ Branch 0 (13→14) taken 3 times.
|
3 | PString keywordsBody = generateKeywordsBody(projectConfig); |
| 388 |
1/1✓ Branch 0 (14→15) taken 3 times.
|
3 | PString nanobindCMakeSources; |
| 389 |
2/2✓ Branch 0 (15→16) taken 1 times.
✓ Branch 1 (15→20) taken 2 times.
|
3 | if(mode.type == ProjectType::NANOBIND_WRAPPER){ |
| 390 |
2/2✓ Branch 0 (16→17) taken 1 times.
✓ Branch 2 (17→18) taken 1 times.
|
1 | nanobindCMakeSources = generateNanobindCmakeSources(projectConfig, vecClassConfigFile, mode); |
| 391 | } | ||
| 392 | |||
| 393 | time_t timestamp; | ||
| 394 |
1/1✓ Branch 0 (22→23) taken 3 times.
|
3 | PString dateStr = ctime(&(timestamp = time(nullptr))); |
| 395 |
3/3✓ Branch 0 (23→24) taken 3 times.
✓ Branch 2 (24→25) taken 3 times.
✓ Branch 4 (25→26) taken 3 times.
|
3 | dateStr = dateStr.eraseLastChar("\n"); // Remove the trailing \n |
| 396 | |||
| 397 | // Generate the replacement map | ||
| 398 | return generateReplacementMap(projectConfig, mode, cmakeFindBody, phoenixPullExtraModule, | ||
| 399 | phoenixFindModule, phoenixGlobalDep, targetLinkBody, | ||
| 400 | pixiBody, markdownDepList, authorListPixi, projectAuthorList, | ||
| 401 |
1/1✓ Branch 0 (28→29) taken 3 times.
|
6 | projectContributorList, maintainer, keywordsBody, dateStr, nanobindCMakeSources); |
| 402 | 3 | } | |
| 403 | |||
| 404 | ///Load configuration pdata of generated sources | ||
| 405 | /** @param[out] param : ProjectParam to be updated | ||
| 406 | * @param pdataDir : directory where to save pdata configuration | ||
| 407 | * @param vecClassConfigFile : vector of class configuration files (.pdata files) | ||
| 408 | * @return true on success, false otherwise | ||
| 409 | */ | ||
| 410 | 3 | bool simple_project_load_config(ProjectParam & param, const PPath & pdataDir, const PVecPath & vecClassConfigFile){ | |
| 411 | 3 | bool b(true); | |
| 412 |
2/2✓ Branch 0 (42→4) taken 6 times.
✓ Branch 1 (42→43) taken 3 times.
|
12 | for(const PPath & classConfigFile : vecClassConfigFile){ |
| 413 |
1/1✓ Branch 0 (6→7) taken 6 times.
|
6 | PDataConfig dataConfig; |
| 414 |
2/2✓ Branch 0 (7→8) taken 6 times.
✓ Branch 2 (8→9) taken 6 times.
|
6 | dataConfig.getFileName() = classConfigFile; |
| 415 |
4/5✓ Branch 0 (9→10) taken 6 times.
✓ Branch 2 (10→11) taken 6 times.
✓ Branch 4 (11→12) taken 6 times.
✗ Branch 6 (12→13) not taken.
✓ Branch 7 (12→18) taken 6 times.
|
6 | if(!parserClassConfig(dataConfig.getVecClassConfig(), dataConfig.getVecInclude(), classConfigFile)){ |
| 416 | ✗ | std::cerr << "simple_project_load_config : can't load file '" << classConfigFile << "'" << std::endl; | |
| 417 | ✗ | b = false; //Best effort strategy | |
| 418 | } | ||
| 419 |
1/1✓ Branch 0 (18→19) taken 6 times.
|
6 | param.vecDataConfig.push_back(dataConfig); |
| 420 | |||
| 421 |
2/2✓ Branch 0 (19→20) taken 6 times.
✓ Branch 2 (20→21) taken 6 times.
|
6 | PPath destFile = pdataDir / classConfigFile.getFileName(); |
| 422 |
1/1✓ Branch 0 (22→23) taken 6 times.
|
6 | PString fileContent = classConfigFile.loadFileContent(); |
| 423 |
2/3✓ Branch 0 (23→24) taken 6 times.
✗ Branch 2 (24→25) not taken.
✓ Branch 3 (24→30) taken 6 times.
|
6 | if(!destFile.saveFileContent(fileContent)){ |
| 424 | ✗ | std::cerr << "simple_project_load_config : cannot copy pdata file to project pdata directory '"<<destFile<<"'" << std::endl; | |
| 425 | ✗ | b = false; //Best effort strategy | |
| 426 | } | ||
| 427 | 6 | } | |
| 428 | 3 | return b; | |
| 429 | } | ||
| 430 | |||
| 431 | ///Generate C++ classes with all standard traits | ||
| 432 | /** @param projectParam : ProjectParam to be used | ||
| 433 | * @return true on success, false otherwise | ||
| 434 | */ | ||
| 435 | 2 | bool generateCppClassesFull(const ProjectParam & projectParam){ | |
| 436 |
1/1✓ Branch 0 (2→3) taken 2 times.
|
2 | PTraitBackendManager manager; |
| 437 |
1/1✓ Branch 0 (3→4) taken 2 times.
|
2 | manager.addTraitBackend<CppTraitFromString>(); |
| 438 |
1/1✓ Branch 0 (4→5) taken 2 times.
|
2 | manager.addTraitBackend<CppTraitCopy>(); |
| 439 |
1/1✓ Branch 0 (5→6) taken 2 times.
|
2 | manager.addTraitBackend<CppTraitSetter>(); |
| 440 |
1/1✓ Branch 0 (6→7) taken 2 times.
|
2 | manager.addTraitBackend<CppTraitGetter>(); |
| 441 |
1/1✓ Branch 0 (7→8) taken 2 times.
|
2 | manager.addTraitBackend<CppTraitTypeStream>(); |
| 442 |
1/1✓ Branch 0 (8→9) taken 2 times.
|
2 | manager.addTraitBackend<CppTraitDataStream>(); |
| 443 |
1/1✓ Branch 0 (9→10) taken 2 times.
|
2 | manager.addTraitBackend<CppTraitConfigStream>(); |
| 444 |
1/1✓ Branch 0 (10→11) taken 2 times.
|
2 | manager.addTraitBackend<CppTraitCheckStream>(); |
| 445 |
1/1✓ Branch 0 (11→12) taken 2 times.
|
4 | return generator_class_full(manager, projectParam); |
| 446 | 2 | } | |
| 447 | |||
| 448 | ///Generate wrapper classes | ||
| 449 | /** @param projectParam : ProjectParam to be used | ||
| 450 | * @return true on success, false otherwise | ||
| 451 | */ | ||
| 452 | 1 | bool generateWrapperClassesFull(const ProjectParam & projectParam){ | |
| 453 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | PWrapperTraitBackendManager manager; |
| 454 |
1/1✓ Branch 0 (3→4) taken 1 times.
|
1 | manager.addTraitBackend<WrapperTraitGetterSetter>(); |
| 455 |
1/1✓ Branch 0 (4→5) taken 1 times.
|
1 | manager.addTraitBackend<WrapperTraitTypeStream>(); |
| 456 |
1/1✓ Branch 0 (5→6) taken 1 times.
|
1 | manager.addTraitBackend<WrapperTraitDataStream>(); |
| 457 |
1/1✓ Branch 0 (6→7) taken 1 times.
|
2 | return wrapper_generator_class_full(manager, projectParam); |
| 458 | 1 | } | |
| 459 | |||
| 460 | ///Generate nanobind wrapper classes | ||
| 461 | /** @param projectParam : ProjectParam to be used | ||
| 462 | * @return true on success, false otherwise | ||
| 463 | */ | ||
| 464 | 1 | bool generateNanobindClassesFull(const ProjectParam & projectParam){ | |
| 465 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | PNanobindTraitBackendManager manager; |
| 466 |
1/1✓ Branch 0 (3→4) taken 1 times.
|
1 | manager.addTraitBackend<NanobindTraitProperty>(); |
| 467 |
1/1✓ Branch 0 (4→5) taken 1 times.
|
1 | manager.addTraitBackend<NanobindTraitMethod>(); |
| 468 |
1/1✓ Branch 0 (5→6) taken 1 times.
|
1 | manager.addTraitBackend<NanobindTraitTypeStream>(); |
| 469 |
1/1✓ Branch 0 (6→7) taken 1 times.
|
1 | manager.addTraitBackend<NanobindTraitDataStream>(); |
| 470 |
1/1✓ Branch 0 (7→8) taken 1 times.
|
1 | manager.addTraitBackend<NanobindTraitCheckStream>(); |
| 471 |
1/1✓ Branch 0 (8→9) taken 1 times.
|
1 | manager.addTraitBackend<NanobindTraitTestSetup>(); |
| 472 |
1/1✓ Branch 0 (9→10) taken 1 times.
|
1 | manager.addTraitBackend<NanobindTraitInclude>(); |
| 473 |
1/1✓ Branch 0 (10→11) taken 1 times.
|
2 | return generator_nanobind_full(manager, projectParam); |
| 474 | 1 | } | |
| 475 | |||
| 476 | ///Save generated sources of project | ||
| 477 | /** @param projectParam : ProjectParam to be used | ||
| 478 | * @return true on success, false otherwise | ||
| 479 | */ | ||
| 480 | 3 | bool simple_project_generate_source(const ProjectParam & projectParam){ | |
| 481 |
3/4✓ Branch 0 (2→3) taken 1 times.
✓ Branch 1 (2→5) taken 1 times.
✓ Branch 2 (2→7) taken 1 times.
✗ Branch 3 (2→14) not taken.
|
3 | switch(projectParam.mode.type){ |
| 482 | 1 | case ProjectType::CPP: | |
| 483 | 1 | return generateCppClassesFull(projectParam); | |
| 484 | 1 | case ProjectType::WRAPPER: | |
| 485 | 1 | return generateWrapperClassesFull(projectParam); | |
| 486 | 1 | case ProjectType::NANOBIND_WRAPPER: | |
| 487 |
2/4✓ Branch 0 (8→9) taken 1 times.
✗ Branch 1 (8→12) not taken.
✓ Branch 2 (10→11) taken 1 times.
✗ Branch 3 (10→12) not taken.
|
1 | return generateCppClassesFull(projectParam) && generateNanobindClassesFull(projectParam); |
| 488 | ✗ | default: | |
| 489 | ✗ | return false; | |
| 490 | } | ||
| 491 | } | ||
| 492 | |||
| 493 | ///Create a simple project from a configuration | ||
| 494 | /** @param descriptionFile : description of the full project | ||
| 495 | * @param vecClassConfigFile : vector of class configuration files (.pdata files) | ||
| 496 | * @param projectType : type of the project (SimpleCpp) | ||
| 497 | * @param mode : all modes of the generator (data/check/type/config stream) | ||
| 498 | * @return true on success, false otherwise | ||
| 499 | */ | ||
| 500 | 4 | bool simple_project_generator(const PPath & descriptionFile, const PVecPath & vecClassConfigFile, const PString & projectType, | |
| 501 | const GeneratorMode & mode) | ||
| 502 | { | ||
| 503 | //First, let's read the toml config of the project | ||
| 504 |
1/1✓ Branch 0 (2→3) taken 4 times.
|
4 | ProjectConfig projectConfig; |
| 505 |
2/3✓ Branch 0 (3→4) taken 4 times.
✗ Branch 2 (4→5) not taken.
✓ Branch 3 (4→10) taken 4 times.
|
4 | if(!project_generator_loadConfig(projectConfig, descriptionFile)){ |
| 506 | ✗ | std::cerr << "simple_project_generator : cannot parse project description file '"<<descriptionFile<<"'" << std::endl; | |
| 507 | ✗ | return false; | |
| 508 | } | ||
| 509 | //Then look in the config files if the packages exists | ||
| 510 |
3/3✓ Branch 0 (10→11) taken 4 times.
✓ Branch 2 (11→12) taken 1 times.
✓ Branch 3 (11→17) taken 3 times.
|
4 | if(!project_generator_loadPackageInfo(projectConfig)){ |
| 511 |
4/4✓ Branch 0 (12→13) taken 1 times.
✓ Branch 2 (13→14) taken 1 times.
✓ Branch 4 (14→15) taken 1 times.
✓ Branch 6 (15→16) taken 1 times.
|
1 | std::cerr << "simple_project_generator : cannot find package info of project '"<<projectConfig.name<<"'" << std::endl; |
| 512 | 1 | return false; | |
| 513 | } | ||
| 514 | // Generate replacement data | ||
| 515 |
1/1✓ Branch 0 (17→18) taken 3 times.
|
3 | PMapString mapReplace = generateAllReplacementData(projectConfig, mode, vecClassConfigFile); |
| 516 |
15/15✓ Branch 0 (18→19) taken 3 times.
✓ Branch 2 (19→20) taken 3 times.
✓ Branch 4 (20→21) taken 3 times.
✓ Branch 6 (21→22) taken 3 times.
✓ Branch 8 (22→23) taken 3 times.
✓ Branch 10 (23→24) taken 3 times.
✓ Branch 12 (24→25) taken 3 times.
✓ Branch 14 (25→26) taken 3 times.
✓ Branch 16 (26→27) taken 3 times.
✓ Branch 18 (27→28) taken 3 times.
✓ Branch 20 (28→29) taken 3 times.
✓ Branch 22 (29→30) taken 3 times.
✓ Branch 24 (30→31) taken 3 times.
✓ Branch 26 (43→44) taken 3 times.
✓ Branch 28 (44→45) taken 3 times.
|
3 | PPath inputConfigPlaceholderDir = PPath(SYSTEM_INSTALL_DIR) / PPath("share") / PPath("PhoenixGenerator") / PPath("Projects") / PPath(projectType), outputPath("./"); |
| 517 |
2/3✓ Branch 0 (46→47) taken 3 times.
✗ Branch 2 (47→48) not taken.
✓ Branch 3 (47→53) taken 3 times.
|
3 | if(!directory_replace_placeholder(outputPath, inputConfigPlaceholderDir, mapReplace)){ |
| 518 | ✗ | std::cerr << "simple_project_generator : cannot replace placeholder in project generation '"<<projectConfig.name<<"'" << std::endl; | |
| 519 | ✗ | return false; | |
| 520 | } | ||
| 521 |
4/4✓ Branch 0 (53→54) taken 3 times.
✓ Branch 2 (54→55) taken 3 times.
✓ Branch 4 (55→56) taken 3 times.
✓ Branch 6 (56→57) taken 3 times.
|
3 | PPath mainPath = PPath(".") / PPath(projectConfig.name); |
| 522 |
6/6✓ Branch 0 (60→61) taken 3 times.
✓ Branch 2 (61→62) taken 3 times.
✓ Branch 4 (62→63) taken 3 times.
✓ Branch 6 (65→66) taken 3 times.
✓ Branch 8 (66→67) taken 3 times.
✓ Branch 10 (67→68) taken 3 times.
|
3 | PPath srcPath = mainPath / PPath("src"), pdataDir = mainPath / PPath("pdata"); |
| 523 |
2/3✓ Branch 0 (70→71) taken 3 times.
✗ Branch 2 (71→72) not taken.
✓ Branch 3 (71→77) taken 3 times.
|
3 | if(!pdataDir.createDirectory()){ |
| 524 | ✗ | std::cerr << "simple_project_generator : cannot create pdata directory '"<<pdataDir<<"'" << std::endl; | |
| 525 | ✗ | return false; | |
| 526 | } | ||
| 527 |
1/1✓ Branch 0 (77→78) taken 3 times.
|
3 | ProjectParam param; |
| 528 |
1/1✓ Branch 0 (78→79) taken 3 times.
|
3 | param.mode = mode; |
| 529 |
1/1✓ Branch 0 (79→80) taken 3 times.
|
3 | param.name = projectConfig.name; |
| 530 |
1/1✓ Branch 0 (80→81) taken 3 times.
|
3 | param.version = projectConfig.version; |
| 531 |
1/1✓ Branch 0 (81→82) taken 3 times.
|
3 | param.outputProjectDir = mainPath; |
| 532 |
1/1✓ Branch 0 (82→83) taken 3 times.
|
3 | param.outputSourceDir = srcPath; |
| 533 |
4/4✓ Branch 0 (83→84) taken 2 times.
✓ Branch 1 (83→85) taken 1 times.
✓ Branch 2 (84→85) taken 1 times.
✓ Branch 3 (84→93) taken 1 times.
|
3 | if(param.mode.type == ProjectType::CPP || param.mode.type == ProjectType::NANOBIND_WRAPPER){ |
| 534 |
4/4✓ Branch 0 (85→86) taken 2 times.
✓ Branch 2 (86→87) taken 2 times.
✓ Branch 4 (87→88) taken 2 times.
✓ Branch 6 (88→89) taken 2 times.
|
2 | param.outputTestDir = mainPath / PPath("TESTS"); |
| 535 |
1/2✓ Branch 0 (93→94) taken 1 times.
✗ Branch 1 (93→102) not taken.
|
1 | }else if(param.mode.type == ProjectType::WRAPPER){ |
| 536 |
4/4✓ Branch 0 (94→95) taken 1 times.
✓ Branch 2 (95→96) taken 1 times.
✓ Branch 4 (96→97) taken 1 times.
✓ Branch 6 (97→98) taken 1 times.
|
1 | param.outputTestDir = mainPath / PPath("tests"); |
| 537 | } | ||
| 538 | |||
| 539 |
2/3✓ Branch 0 (102→103) taken 3 times.
✗ Branch 2 (103→104) not taken.
✓ Branch 3 (103→109) taken 3 times.
|
3 | if(!simple_project_load_config(param, pdataDir, vecClassConfigFile)){ |
| 540 | ✗ | std::cerr << "simple_project_generator : cannot load config to generate project in '"<<srcPath<<"'" << std::endl; | |
| 541 | ✗ | return false; | |
| 542 | } | ||
| 543 |
2/3✓ Branch 0 (109→110) taken 3 times.
✗ Branch 2 (110→111) not taken.
✓ Branch 3 (110→116) taken 3 times.
|
3 | if(!simple_project_generate_source(param)){ |
| 544 | ✗ | std::cerr << "simple_project_generator : cannot generate sources in '"<<srcPath<<"'" << std::endl; | |
| 545 | ✗ | return false; | |
| 546 | } | ||
| 547 | // Generate class generator script | ||
| 548 |
2/3✓ Branch 0 (116→117) taken 3 times.
✗ Branch 2 (117→118) not taken.
✓ Branch 3 (117→123) taken 3 times.
|
3 | if(!generateClassGeneratorScript(vecClassConfigFile, pdataDir, param.mode)){ |
| 549 | ✗ | std::cerr << "simple_project_generator : cannot generate class generator script in pdata directory '"<<pdataDir<<"'" << std::endl; | |
| 550 | ✗ | return false; | |
| 551 | } | ||
| 552 | 3 | return true; | |
| 553 | 4 | } | |
| 554 | |||
| 555 | |||
| 556 |