3 if (php_sapi_name() != 'cli') {
6 // install : ln -s buildSDK/pre-commit .git/hooks/
8 // the recomendation is to check if the current commit is same as the one on any of the files/directories that need monitoring.
10 register_shutdown_function ( 'unlock');
13 trigger_action('build_docs', array('Roo.js', 'Roo/', 'Array.js', 'Function.js', 'Date.js', 'String.js', 'Number.js'));
15 $core = trigger_action_file('compile_core', 'dependancy_core.txt');
16 $ui = trigger_action_file('compile_ui', 'dependancy_ui.txt');
17 trigger_action_file('compile_bootstrap', 'dependancy_bootstrap.txt');
18 trigger_action_file('compile_mailer', 'dependancy_mailer.txt');
19 trigger_action_file('compile_calendar', 'dependancy_calendar.txt');
21 trigger_action('compile_less', array('less/'));
22 trigger_action('compile_scss', array('scss/'));
32 if (file_exists(".git/pre-commit-running")) {
33 if (file_exists(".git/pre-commit-pending")) {
36 file_put_contents(".git/pre-commit-pending","\n");
37 sleep(30); // wait 30 seconds
38 unlink(".git/pre-commit-pending");
44 file_put_contents(".git/pre-commit-running","\n");
48 unlink(".git/pre-commit-running");
51 function changed_files()
53 static $output = array();
54 if (!empty($output)) {
58 exec('git rev-parse --verify HEAD 2> /dev/null', $output, $return);
63 exec("git diff-index --cached --name-only 'HEAD'", $output);
67 function trigger_action_file($fn, $filename)
69 $ret = explode("\n",file_get_contents(__DIR__ . "/" . $filename));
74 $add[] = str_replace('.','/', $r) . ".js";
77 $ret[] = "buildSDK/".$filename;
78 return trigger_action($fn, $add);
82 function trigger_action($fn, $files)
85 foreach(changed_files() as $cg) {
86 foreach($files as $f) {
89 echo "RUNNING : $fn\n";
93 if (substr($f, -1,1) == '/' && substr($cg,0, strlen($f)) == $f) {
94 echo "RUNNING : $fn\n";
103 function build_docs()
105 exec("roojspacker -i buildSDK/dependancy_core.txt -i buildSDK/dependancy_ui.txt " .
106 "-i buildSDK/dependancy_bootstrap.txt -i buildSDK/dependancy_calendar.txt " .
107 "-i buildSDK/dependancy_svg.txt " .
108 "--doc-target=docs -D");
110 function compile_core()
112 exec("roojspacker -t roojs-core.js -T roojs-core-debug.js -i buildSDK/dependancy_core.txt ");
115 function compile_ui()
117 exec("roojspacker -t roojs-ui.js -T roojs-ui-debug.js -i buildSDK/dependancy_ui.txt");
120 function merge_files()
122 exec("cat roojs-core.js roojs-ui.js > roojs-all.js");
123 exec("cat roojs-core-debug.js roojs-ui-debug.js > roojs-debug.js");
127 function compile_bootstrap()
129 exec("roojspacker -t roojs-bootstrap.js -T roojs-bootstrap-debug.js -i buildSDK/dependancy_bootstrap.txt");
132 function compile_calendar()
134 exec("roojspacker -t roojs-calendar.js -T roojs-calendar-debug.js -i buildSDK/dependancy_calendar.txt");
138 function compile_mailer()
141 exec("roojspacker -t roojs-mailer.js -T roojs-mailer-debug.js -i buildSDK/dependancy_mailer.txt");
144 function compile_docbook()
146 exec("roojspacker -t roojs-doc.js -T roojs-doc-debug.js -i buildSDK/dependancy_doc.txt");
151 function compile_less()
153 exec("php buildSDK/less-bootstrap-complier.php");
156 function compile_scss()
158 exec("php buildSDK/scss-bootstrap.php");