-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.php
96 lines (79 loc) · 2.2 KB
/
build.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
<?php
$myecho_level=0;
function myecho_pushlevel()
{
global $myecho_level;
$myecho_level++;
}
function myecho_poplevel()
{
global $myecho_level;
if ($myecho_level>0)
$myecho_level--;
}
function myecho($type, $msg)
{
if ($type=="continuous")
{
echo $msg;
return;
}
global $myecho_level;
echo str_repeat(" ", $myecho_level*2);
if ($type=="info")
echo "--";
else if ($type=="warning")
echo "**";
else if ($type=="critical")
echo "!!";
else echo " ";
echo " " . $msg;
}
$version = file_get_contents("version.txt");
function insertMatches ($matches) {
global $basePath;
global $version;
global $transVersion;
myecho_pushlevel();
$EOL = "\n";
$js = "/***********************************************" . $EOL;
$js .= "*** IN INCLUDED FILE : ***" . $EOL;
$tmp = "*** " . $matches[1];
$tmp .= str_repeat(" ", max(45-strlen($tmp), 0)) . "***" . $EOL;
$js .= $tmp;
$js .= "***********************************************/" . $EOL . $EOL;
$js .= strtr(file_get_contents($basePath . $matches[1]), $transVersion);
$js = preg_replace_callback(
"/INCLUDE_FILE\('([^\)]+)'\);/",
'insertMatches',
$js
);
$js .= "" . $EOL . $EOL;
$js .= "/***********************************************" . $EOL;
$js .= "*** END OF INCLUDED FILE : ***" . $EOL;
$js .= $tmp;
$js .= "***********************************************/" . $EOL . $EOL;
myecho ("info", 'Include ' . $matches[1] . "...");
myecho ("continuous", ' done' . PHP_EOL);
myecho_poplevel();
return ($js);
}
myecho ("info", "Build WME-AC version: " . $version . PHP_EOL);
$basePath = 'src/';
$mainFile = 'main.js';
myecho ("info", 'Build started' . PHP_EOL);
myecho_pushlevel();
$transVersion = array ("<WMEACVERSION>" => $version);
$js = strtr(file_get_contents($basePath . $mainFile), $transVersion);
$js = preg_replace_callback(
"/INCLUDE_FILE\('([^\)]+)'\);/",
'insertMatches',
$js
);
myecho_poplevel();
myecho ("info", 'Build ended' . PHP_EOL);
myecho ("info", 'Write code...');
file_put_contents("wme-ac.js", $js);
#file_put_contents("ac-v" . $version . ".user.js", $js);
myecho ("continuous", ' done' . PHP_EOL);
?>