buildSDK/less-bootstrap-compiler.php
[roojs1] / buildSDK / less-bootstrap-compiler.php
1 <?php
2
3 $cwd = getcwd();
4
5 if (array_pop(explode('/', $cwd)) !== 'roojs1') {
6     echo "this should be run in roojs1 directory...\n";
7     exit;
8 }
9
10 ini_set('include_path', 
11     dirname(__FILE__) . '/../:' .
12     dirname(__FILE__) . '/../../pear:' .
13     ini_get('include_path')
14 );
15
16 $rootDir = dirname(__FILE__) . '/../..';
17
18 $files = array(
19     "{$rootDir}/roojs1/less/bootstrap/bootstrap.less" => array(
20         'baseDir' => "{$rootDir}/roojs1/css-bootstrap",
21         'name' => 'bootstrap.css',
22         'minify' => 'bootstrap.min.css'
23     ),
24     "{$rootDir}/roojs1/less/roojs-bootstrap/roojs-bootstrap.less" => array(
25         'baseDir' => "{$rootDir}/roojs1/css-bootstrap",
26         'name' => 'roojs-bootstrap-debug.css',
27         'minify' => 'roojs-bootstrap.css'
28     )
29 );
30
31 require_once 'HTML/Less.php';
32         
33 $less = new HTML_Less();
34
35 foreach ($files as $src => $file){
36
37     if(!file_exists($src)){
38         echo "{$less} does not exist...\n";
39         continue;
40     }
41
42     try {
43         
44         $css = "{$file['baseDir']}/{$file['name']}";
45         
46         echo "Compiling - {$src} To {$css}\n";
47         
48         $less->compileFile($src, $css);
49         
50     } catch (Exception $ex) {
51         echo "lessphp fatal error: {$ex->getMessage()}\n";
52     }
53     
54 }
55
56 require_once 'HTML/CSS/Minify.php';
57
58 foreach ($files as $src => $file){
59     
60     $css = "{$file['baseDir']}/{$file['name']}";
61     
62     if(!file_exists($css)){
63         echo "{$css} does not exist...\n";
64         continue;
65     }
66     
67     try {
68         
69         $min = "{$file['baseDir']}/{$file['minify']}";
70         
71         echo "Minifing - {$css} To {$min}\n";
72         
73         $minify = new HTML_CSS_Minify($file['baseDir'], $file['baseDir'], array($file['name']));
74     
75         $content = $minify->minify();
76
77         file_put_contents($min, $content);
78         
79     } catch (Exception $ex) {
80         echo "Minify fatal error: {$ex->getMessage()}\n";
81     }
82     
83 }