forked from qcubed/orm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodegen.cli.php
69 lines (51 loc) · 1.98 KB
/
codegen.cli.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
use QCubed\Project\Codegen\CodegenBase as Codegen;
/* This includes library file is used by the codegen.cli and codegen.phpexe scripts
* to simply fire up and run the CodeGen object, itself.
*
* Depends on QCUBED_PROJECT_INCLUDES_DIR and QCUBED_CONFIG_DIR defines
*/
$strOrmPath = dirname(__DIR__);
$strQCubedPath = dirname($strOrmPath);
function PrintInstructions() {
global $strCommandName;
print('QCubed Code Generator (Command Line Interface)
Copyright (c) 2001 - 2009, QuasIdea Development, LLC, QCubed Project
This program is free software with ABSOLUTELY NO WARRANTY; you may
redistribute it under the terms of The MIT License.
Usage: ' . $strCommandName . ' CODEGEN_SETTINGS
Where CODEGEN_SETTINGS is the absolute filepath of the codegen_settings.xml
file, containing the code generator settings.
For more information, please go to http://qcu.be
');
exit();
}
\QCubed\Database\Service::InitializeDatabaseConnections();
$settingsFile = QCUBED_CONFIG_DIR . '/codegen_settings.xml';
if (!is_file($settingsFile)) {
echo "Settings file: " . $settingsFile;
PrintInstructions();
}
/////////////////////
// Run Code Gen
CodeGen::run($settingsFile);
/////////////////////
if ($strErrors = CodeGen::$RootErrors) {
printf("The following ROOT ERRORS were reported:\r\n%s\r\n\r\n", $strErrors);
} else {
printf("CodeGen settings (as evaluted from %s):\r\n%s\r\n\r\n", $settingsFile, CodeGen::GetSettingsXml());
}
print ("Template files:\r\n");
$strFiles = Codegen::$TemplatePaths;
echo implode("\r\n", $strFiles);
foreach (CodeGen::$CodeGenArray as $objCodeGen) {
printf("%s\r\n---------------------------------------------------------------------\r\n", $objCodeGen->GetTitle());
printf("%s\r\n", $objCodeGen->GetReportLabel());
printf("%s\r\n", $objCodeGen->GenerateAll());
if ($strErrors = $objCodeGen->Errors)
printf("The following errors were reported:\r\n%s\r\n", $strErrors);
print("\r\n");
}
foreach (CodeGen::GenerateAggregate() as $strMessage) {
printf("%s\r\n\r\n", $strMessage);
}