This repository was archived by the owner on Feb 1, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathbuild.php
More file actions
executable file
·173 lines (151 loc) · 3.74 KB
/
build.php
File metadata and controls
executable file
·173 lines (151 loc) · 3.74 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/usr/bin/env php
<?php
/**
* simple buildscript, see ./build -h
*
* declare a target is easy as prefixing a function with "target_"
*
* PHP version 5.2.6+
*
* @file build
* @author Patrick C. Engel <info@pc-e.org>
* @copyright 2011 info@pc-e.org
* @license MIT http://www.opensource.org/licenses/mit-license.html
* @link https://github.com/pce/config_lite
*/
function target_phpcs()
{
$cs = 'phpcs';
// pear install PHP_CodeSniffer
$target = 'Config/Lite.php';
printf("== %s\n", 'Coding Standard');
system($cs .' -v '.$target);
printf("\n");
}
function target_test()
{
$phpunit = 'phpunit';
$test_target = 'tests/Config_LiteTest.php';
printf("== %s\n", 'Unit Tests');
system($phpunit . ' ' . $test_target);
printf("\n");
}
function target_doc()
{
printf("== %s\n", __FUNCTION__);
$target = 'Config/Lite.php';
system('phpdoc -o HTML:Smarty:PHP -f '.$target.' -t phpdocs');
printf("\n");
}
function target_clean()
{
printf("== %s\n", __FUNCTION__);
$quiet = ' 2> /dev/null';
system('rm -r ./phpdocs'.$quiet);
system('rm *.tgz'.$quiet);
printf("\n");
}
function target_beautify()
{
printf("== %s\n", __FUNCTION__);
// system('php_beautifier -f Config/Lite.php -o Config/Lite_.php');
printf("\n");
}
function target_md()
{
printf("== %s\n", __FUNCTION__);
/* uses phpmd from http://phpmd.org/ */
system('phpmd Config text codesize,unusedcode,naming,design');
printf("\n");
}
function target_package()
{
printf("== %s\n", __FUNCTION__);
/*
# edited /usr/bin/pear
# since i compiled env php without zlib:
PHP_PEAR_PHP_BIN="/usr/bin/php"
$pear = "/usr/bin/pear";
*/
$pear = "pear";
system($pear.' package ./package.xml');
printf("\n");
}
function target_pirum()
{
printf("== %s\n", __FUNCTION__);
$pear = '/usr/bin/pear';
system($pear.' package ./pirum-package.xml');
printf("\n");
}
function target_pirum_add()
{
printf("== %s\n", __FUNCTION__);
$package = isset($argv[2]) ? basename($argv[2]) : 'Config_Lite-0.1.0.tgz';
system('pirum add pear '.$package);
printf("\n");
}
function target_validate()
{
$pear = "/usr/bin/pear";
printf("== %s\n", 'validate pear package');
system('find ./ -name \'*.tgz\' -exec '
. $pear .' package-validate "{}" \;');
printf("\n");
}
function target_default()
{
target_phpcs();
target_test();
}
// task to sync fork with remote (update)
function target_gitup()
{
// git remote add upstream git://github.com/<user>/<repo>.git
system('git fetch upstream');
system('git merge upstream/master');
}
// ---------------------------------------------------------------------
// build script
// ---------------------------------------------------------------------
function print_usage($prg, $err=false)
{
fprintf($err?STDERR:STDOUT, "Usage: %s [<target>]\n\n", $prg);
$err && fprintf(STDERR, " run with -h too see all targets\n\n");
fprintf($err?STDERR:STDOUT, " without any target, %s invokes the `task_default'.\n", $prg);
fprintf($err?STDERR:STDOUT, " Example: %s default\n\n", $prg);
$err && exit(1);
}
function main($argc, $argv)
{
if ($argc == 1 ) {
if (function_exists('target_default')) {
target_default();
} else {
print_usage($argv[0], true);
}
}
if ($argc > 1) {
$target = 'target_'.$argv[1];
if (function_exists($target)) {
$target();
} elseif ($argv[1] == '-h' || $argv[1] == '--help') {
print_usage($argv[0]);
$avail_targets = array();
$funcs = get_defined_functions();
foreach ($funcs['user'] as $func) {
if ('target_' === substr($func, 0, 7)) {
$avail_targets[] = str_replace('target_', '', $func);
}
}
printf("\n %s\n\n", 'available targets:');
foreach ($avail_targets as $option) {
printf(" %s\n", $option);
}
printf("\n");
} else {
print_usage($argv[0], true);
}
}
}
main($argc, $argv);