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         'variables' => "@import 'variables.less';"
24     ),
25     "{$rootDir}/roojs1/less/roojs-bootstrap/roojs-bootstrap.less" => array(
26         'baseDir' => "{$rootDir}/roojs1/css-bootstrap",
27         'name' => 'roojs-bootstrap-debug.css',
28         'minify' => 'roojs-bootstrap.css'
29     )
30 );
31
32 require_once 'HTML/Less.php';
33         
34 $less = new HTML_Less();
35
36 foreach ($files as $src => $file){
37
38     if(!file_exists($src)){
39         echo "{$less} does not exist...\n";
40         continue;
41     }
42
43     try {
44         
45         $css = "{$file['baseDir']}/{$file['name']}";
46         
47         echo "Compiling - {$src} To {$css}\n";
48         
49         $less->compileFile($src, $css);
50         
51     } catch (Exception $ex) {
52         echo "lessphp fatal error: {$ex->getMessage()}\n";
53     }
54     
55 }
56
57 require_once 'HTML/CSS/Minify.php';
58
59 foreach ($files as $src => $file){
60     
61     $css = "{$file['baseDir']}/{$file['name']}";
62     
63     if(!file_exists($css)){
64         echo "{$css} does not exist...\n";
65         continue;
66     }
67     
68     try {
69         
70         $min = "{$file['baseDir']}/{$file['minify']}";
71         
72         echo "Minifing - {$css} To {$min}\n";
73         
74         $minify = new HTML_CSS_Minify($file['baseDir'], $file['baseDir'], array($file['name']));
75     
76         $content = $minify->minify($file['baseDir']);
77
78         file_put_contents($min, $content);
79         
80     } catch (Exception $ex) {
81         echo "Minify fatal error: {$ex->getMessage()}\n";
82     }
83     
84 }