| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*************************************** | ||
| 2 | Auteur : Thibaut Oprinsen | ||
| 3 | Mail : thibaut.oprinsen@example.com | ||
| 4 | Licence : CeCILL-C | ||
| 5 | ****************************************/ | ||
| 6 | |||
| 7 | #include "simpleClassGenerator.h" | ||
| 8 | #include "phoenix_system.h" | ||
| 9 | |||
| 10 | ///Generate a bash script to re generate all the classes from their pdata configuration files | ||
| 11 | /** @param vecClassConfigFile : vector of class configuration files (.pdata files) | ||
| 12 | * @param scriptDir : directory where to save the script | ||
| 13 | * @param mode : mode of the generator | ||
| 14 | * @return true on success, false otherwise | ||
| 15 | */ | ||
| 16 | 2 | bool generateClassGeneratorScript(const PVecPath & vecClassConfigFile, const PPath & scriptDir, const GeneratorMode & mode){ | |
| 17 |
1/1✓ Branch 0 (2→3) taken 2 times.
|
2 | PString scriptContent; |
| 18 |
1/1✓ Branch 0 (3→4) taken 2 times.
|
2 | scriptContent += "#!/bin/bash\n\n"; |
| 19 |
1/1✓ Branch 0 (4→5) taken 2 times.
|
2 | scriptContent += "echo \"Regenerating classes from pdata configuration files...\"\n\n"; |
| 20 |
2/2✓ Branch 0 (48→7) taken 4 times.
✓ Branch 1 (48→49) taken 2 times.
|
8 | for(const PPath & classConfigFile : vecClassConfigFile){ |
| 21 |
2/2✓ Branch 0 (9→10) taken 4 times.
✓ Branch 2 (10→11) taken 4 times.
|
4 | PString fileName = classConfigFile.getFileName(); |
| 22 |
3/3✓ Branch 0 (12→13) taken 4 times.
✓ Branch 2 (13→14) taken 4 times.
✓ Branch 4 (14→15) taken 4 times.
|
4 | PString className = classConfigFile.getFileName().eraseExtension(); |
| 23 |
2/2✓ Branch 0 (16→17) taken 4 times.
✓ Branch 2 (17→18) taken 4 times.
|
4 | PPath pdataFileInProject = scriptDir / classConfigFile.getFileName(); |
| 24 |
5/5✓ Branch 0 (19→20) taken 4 times.
✓ Branch 2 (20→21) taken 4 times.
✓ Branch 4 (21→22) taken 4 times.
✓ Branch 6 (22→23) taken 4 times.
✓ Branch 8 (23→24) taken 4 times.
|
4 | scriptContent += "echo \"Generating class " + className + " from " + pdataFileInProject + "\"\n"; |
| 25 | //TODO : update the given option by repect to the future options defined in PhoenixFileGenerator | ||
| 26 |
3/3✓ Branch 0 (28→29) taken 4 times.
✓ Branch 2 (29→30) taken 4 times.
✓ Branch 4 (30→31) taken 4 times.
|
4 | scriptContent += "phoenix_filegenerator class -c " + fileName + " -o ../src -u -d ../"; |
| 27 |
2/2✓ Branch 0 (33→34) taken 2 times.
✓ Branch 1 (33→35) taken 2 times.
|
4 | if(mode.type == ProjectType::WRAPPER){ |
| 28 |
1/1✓ Branch 0 (34→35) taken 2 times.
|
2 | scriptContent += " --wrapper"; |
| 29 | } | ||
| 30 |
1/1✓ Branch 0 (35→36) taken 4 times.
|
4 | scriptContent += "\n\n"; |
| 31 | 4 | } | |
| 32 |
1/1✓ Branch 0 (49→50) taken 2 times.
|
2 | scriptContent += "echo \"Class regeneration completed.\"\n"; |
| 33 | |||
| 34 |
3/3✓ Branch 0 (50→51) taken 2 times.
✓ Branch 2 (51→52) taken 2 times.
✓ Branch 4 (52→53) taken 2 times.
|
2 | PPath scriptPath = scriptDir / PPath("generate_class.sh"); |
| 35 |
1/1✓ Branch 0 (55→56) taken 2 times.
|
2 | scriptPath.saveFileContent(scriptContent); |
| 36 | // Make the script executable | ||
| 37 |
6/7✓ Branch 0 (56→57) taken 2 times.
✓ Branch 2 (57→58) taken 2 times.
✓ Branch 4 (58→59) taken 2 times.
✓ Branch 6 (59→60) taken 2 times.
✓ Branch 8 (60→61) taken 2 times.
✗ Branch 10 (65→66) not taken.
✓ Branch 11 (65→71) taken 2 times.
|
2 | if(!phoenix_popen(PPath("project_path_test.log"), PString("chmod +x " + scriptPath), true)){ |
| 38 | ✗ | std::cerr << "generateClassGeneratorScript : cannot make script executable '"<<scriptPath<<"'" << std::endl; | |
| 39 | ✗ | return false; | |
| 40 | } | ||
| 41 | 2 | return true; | |
| 42 | 2 | } | |
| 43 | |||
| 44 |