8e11ac7acdb52dbb6f932c3b69303c524377e7c5
[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' => array("@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         'variables' => array("@import '../bootstrap/variables.less';")
30     )
31 );
32
33 require_once 'HTML/Less.php';
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         $less = new HTML_Less();
45         
46         $less->setOptions(array(
47             'variables' => $file['variables'],
48             'sourceMap' => true,
49             'sourceMapWriteTo' => "{$file['baseDir']}/{$file['name']}.map",
50             'sourceMapURL' => "{$file['name']}.map"
51         ));
52         
53         $css = "{$file['baseDir']}/{$file['name']}";
54         
55         echo "Compiling - {$src} To {$css}\n";
56         
57         $less->compileFile($src, $css);
58         
59         $min = "{$file['baseDir']}/{$file['minify']}";
60         
61         $less->setOption('compress', true);
62         
63         echo "Minifing - {$src} To {$min}\n";
64         
65         $less->compileFile($src, $min);
66         
67     } catch (Exception $ex) {
68         echo "lessphp fatal error: {$ex->getMessage()}\n";
69     }
70     
71 }