-
Notifications
You must be signed in to change notification settings - Fork 4
/
ggen.php
executable file
·110 lines (95 loc) · 3.28 KB
/
ggen.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env php
<?php
/**
* ggen.php - command line tool for exension generation
*
* This is released under the MIT, see LICENSE for details
*
* @author Elizabeth M Smith <[email protected]>
* @copyright Elizabeth M Smith (c) 2012-2013
* @link http://gtkforphp.net
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @since Php 5.4.0
* @package G\Generator
* @subpackage cli
*/
/**
* PHP Environment testing
*
* There are a few requirements for the PHP environment that this
* script needs in order to run. Fatal errors will be output to
* stderr if this stuff doesn't' work
*
* Current sanity checks
* 1. PHP version (5.4)
* 2. PHP SAPI (MUST be cli)
* 3. PHP extensions (spl, date, pcre, reflection and standard)
* 4. argv/argc
*
* Note this file doesn't use namespaces but instead includes the actual run file
* Should run on any 5+ version of PHP...and bail properly
*/
if (version_compare(PHP_VERSION, "5.4.0", "<")) {
fwrite(STDERR,
<<<BAD_PHP_ERROR
+-----------------------------------------------------------+
| ! ERROR ! |
| ggen requires PHP 5.4.0 or higher to run. Please update |
| to a more recent PHP version to continue. |
+-----------------------------------------------------------+
BAD_PHP_ERROR
);
exit(1);
}
if (PHP_SAPI != 'cli') {
fwrite(STDERR,
<<<BAD_SAPI_ERROR
+-----------------------------------------------------------+
| ! ERROR ! |
| ggen must be run using the php cli. On windows this is |
| php.exe or php-win.exe. On linux systems you may need to |
| install a package php5-cli or something similar. |
+-----------------------------------------------------------+
BAD_SAPI_ERROR
);
exit(1);
}
if (!extension_loaded('reflection') ||
!extension_loaded('pcre') ||
!extension_loaded('date') ||
!extension_loaded('spl') ||
!extension_loaded('standard')) {
fwrite(STDERR,
<<<BAD_EXT_ERROR
+-----------------------------------------------------------+
| ! ERROR ! |
| ggen requires spl, date, pcre, reflection and standard to |
| be loaded in order to run. These extensions are normally |
| built into PHP by default but at least one is missing. |
| Please rebuild your PHP to include these extensions, or |
| load them via your php.ini file. |
+-----------------------------------------------------------+
BAD_EXT_ERROR
);
exit(1);
}
if (!isset($argv) || !isset($argc)) {
fwrite(STDERR,
<<<BAD_ARGV_ERROR
+-----------------------------------------------------------+
| ! ERROR ! |
| ggen requires both argv and argc (command line argument |
| information) to be available in order to run. Please |
| enable register_argv_argc in your command line php.ini |
+-----------------------------------------------------------+
BAD_ARGV_ERROR
);
exit(1);
}
/**
* Include all our classes with an include all file
* Run the extension tool with a run file
*/
define('G_GEN_LIBPATH', __DIR__ . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR, true);
include __DIR__ . DIRECTORY_SEPARATOR . 'include.php';
include __DIR__ . DIRECTORY_SEPARATOR . 'run.php';