4 // install : ln -s buildSDK/pre-commit .git/hooks/
6 // the recomendation is to check if the current commit is same as the one on any of the files/directories that need monitoring.
8 register_shutdown_function ( 'unlock');
11 trigger_action('build_docs', array('Roo.js', 'Roo/', 'Array.js', 'Function.js', 'Date.js', 'String.js', 'Number.js'));
13 $core = trigger_action_file('compile_core', 'dependancy_core.txt');
14 $ui = trigger_action_file('compile_ui', 'dependancy_ui.txt');
15 trigger_action_file('compile_bootstrap', 'dependancy_bootstrap.txt');
16 trigger_action_file('compile_mailer', 'dependancy_mailer.txt');
17 trigger_action_file('compile_calendar', 'dependancy_calendar.txt');
19 trigger_action('compile_less', array('less/'));
20 trigger_action('compile_scss', array('scss/'));
30 if (file_exists(".git/pre-commit-running")) {
31 if (file_exists(".git/pre-commit-pending")) {
34 file_put_contents(".git/pre-commit-pending","\n");
35 sleep(30); // wait 30 seconds
36 unlink(".git/pre-commit-pending");
42 file_put_contents(".git/pre-commit-running","\n");
46 unlink(".git/pre-commit-running");
49 function changed_files()
51 static $output = array();
52 if (!empty($output)) {
56 exec('git rev-parse --verify HEAD 2> /dev/null', $output, $return);
61 exec("git diff-index --cached --name-only 'HEAD'", $output);
65 function trigger_action_file($fn, $filename)
67 $ret = explode("\n",file_get_contents(__DIR__ . "/" . $filename));
72 $add[] = str_replace('.','/', $r) . ".js";
75 $ret[] = "buildSDK/".$filename;
76 return trigger_action($fn, $add);
80 function trigger_action($fn, $files)
83 foreach(changed_files() as $cg) {
84 foreach($files as $f) {
87 echo "RUNNING : $fn\n";
91 if (substr($f, -1,1) == '/' && substr($cg,0, strlen($f)) == $f) {
92 echo "RUNNING : $fn\n";
101 function build_docs()
103 exec("roojspacker -i buildSDK/dependancy_core.txt -i buildSDK/dependancy_ui.txt " .
104 "-i buildSDK/dependancy_bootstrap.txt -i buildSDK/dependancy_calendar.txt " .
105 "-i buildSDK/dependancy_svg.txt " .
106 "--doc-target=docs -D");
108 function compile_core()
110 exec("roojspacker -t roojs-core.js -T roojs-core-debug.js -i buildSDK/dependancy_core.txt ");
113 function compile_ui()
115 exec("roojspacker -t roojs-ui.js -T roojs-ui-debug.js -i buildSDK/dependancy_ui.txt");
118 function merge_files()
120 exec("cat roojs-core.js roojs-ui.js > roojs-all.js");
121 exec("cat roojs-core-debug.js roojs-ui-debug.js > roojs-debug.js");
125 function compile_bootstrap()
127 exec("roojspacker -t roojs-bootstrap.js -T roojs-bootstrap-debug.js -i buildSDK/dependancy_bootstrap.txt");
130 function compile_calendar()
132 exec("roojspacker -t roojs-calendar.js -T roojs-calendar-debug.js -i buildSDK/dependancy_calendar.txt");
136 function compile_mailer()
139 exec("roojspacker -t roojs-mailer.js -T roojs-mailer-debug.js -i buildSDK/dependancy_mailer.txt");
142 function compile_docbook()
144 exec("roojspacker -t roojs-doc.js -T roojs-doc-debug.js -i buildSDK/dependancy_doc.txt");
149 function compile_less()
151 exec("php buildSDK/less-bootstrap-complier.php");
154 function compile_scss()
156 exec("php buildSDK/scss-bootstrap.php");