forked from jpdery/moobile-simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·130 lines (99 loc) · 2.56 KB
/
build
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
#!/usr/bin/env php
<?php
$stderr = fopen('php://stderr', 'w');
require dirname(__FILE__) . '/Packager/packager.php';
$executable = array_shift($argv);
$package = dirname(__FILE__);
$selected = array(
'components' => array(),
'files' => array(),
'add-packages' => array(),
'remove-packages' => array(),
'blocks' => array(),
'use-only' => null
);
$build = 'components';
$wihtout_core_more = false;
foreach ($argv as $arg){
if ($arg == '+packages'){
$build = 'add-packages';
continue;
}
if ($arg == '-blocks'){
$build = 'blocks';
continue;
}
if ($arg == '+use-only'){
$build = 'use-only';
if ($selected['use-only'] == null) $selected['use-only'] = array();
continue;
}
if ($arg == '-packages'){
$build = 'remove-packages';
continue;
}
if ($arg == '+components'){
$build = 'components';
continue;
}
if ($arg == '+files'){
$build = 'files';
continue;
}
if ($arg == '-without-core-more') {
$wihtout_core_more = true;
continue;
}
$selected[$build][] = $arg;
}
$re = "/^([^\/]+)\/\*$/";
$wildcards = array();
$files = $selected['files'];
$components = $selected['components'];
$blocks = $selected['blocks'];
foreach ($components as $component){
preg_match($re, $component, $matches);
if (!empty($matches)){
array_erase($components, $component);
array_include($wildcards, $matches[1]);
}
}
foreach ($files as $file){
preg_match($re, $file, $matches);
if (!empty($matches)){
array_erase($files, $file);
array_include($wildcards, $matches[1]);
}
}
$pkgs = array(
$package,
dirname(__FILE__) . "/Vendor/mootools-core",
dirname(__FILE__) . "/Vendor/mootools-more",
dirname(__FILE__) . "/Vendor/mootools-extras",
dirname(__FILE__) . "/Vendor/mootools-class-extras",
);
if ($wihtout_core_more) {
unset($pkgs[1]);
unset($pkgs[2]);
}
$pkg = new Packager($pkgs);
$pkg->validate($files, $components, $wildcards);
foreach ($components as $component){
$file = $pkg->component_to_file($component);
if ($file) array_include($files, $file);
}
foreach ($wildcards as $package){
$all = $pkg->get_all_files($package);
foreach ($all as $file) array_include($files, $file);
}
$files = $pkg->complete_files($files);
Packager::warn("Build using: " . implode(', ', $pkg->get_packages()) . "\n");
Packager::warn("Included Files/Components:\n");
foreach ($files as $file){
$file_name = $pkg->get_file_name($file);
$file_package = $pkg->get_file_package($file);
Packager::warn("- $file_package/$file_name: [" . implode(", ", $pkg->get_file_provides($file)) . "]\n");
}
echo $pkg->build($files, array(), array(), $blocks);
fclose($stderr);
?>