-
Notifications
You must be signed in to change notification settings - Fork 16
/
build.php
58 lines (47 loc) · 1.32 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
<?php
if (php_sapi_name() != 'cli') {
print ("Builders can only be runned as cli\n") ;
exit( 1 );
}
require_once (__DIR__ . "/src/op5/ninja_sdk/Ninja_Builder.php");
$builder = new Ninja_Builder();
$modules = false;
/* First, get module names from command line */
if($modules === false && count($argv) > 1) {
$rules = array_slice($argv, 1);
}
/* If no rules is specified, load everything */
if(empty($rules)) {
$rules = array(':');
}
/* If no modules found on command line, scan modules dir */
$all_modules = array();
foreach( scandir( "modules" ) as $module ) {
if( $module[0] == '.' )
continue;
$all_modules[$module] = 'modules/'.$module;
};
$all_modules['application'] = 'application';
$all_modules['system'] = 'system';
foreach ( $rules as $rule ) {
$parts = explode(':', $rule);
/* If module is specified, only use that, otherwise all */
if(!empty($parts[0])) {
if( !isset($all_modules[$parts[0]]) ) {
print "Ignoring unknown module {$parts[0]}\n";
continue;
}
$moduledirs = array( $all_modules[$parts[0]] );
} else {
$moduledirs = array_values( $all_modules );
}
/* If target is specified, only use that */
$target = null;
if(count($parts) >= 2)
$target = $parts[1];
/* Add rule to builder */
foreach($moduledirs as $moduledir) {
$builder->add_module( $moduledir, $target );
}
}
$builder->generate();