buildSDK/less-bootstrap-compiler.php
[roojs1] / buildSDK / less-bootstrap-compiler.php
index 0ae6733..3664746 100644 (file)
@@ -2,11 +2,72 @@
 
 $cwd = getcwd();
 
-if(array_pop(explode('/', $cwd)) !== 'roojs1'){
+if (array_pop(explode('/', $cwd)) !== 'roojs1') {
     echo "this should be run in roojs1 directory...\n";
     exit;
 }
 
+ini_set('include_path', 
+    dirname(__FILE__) . '/../:' .
+    dirname(__FILE__) . '/../../pear:' .
+    ini_get('include_path')
+);
+
+$rootDir = dirname(__FILE__) . '/../..';
+
+$files = array(
+    "{$rootDir}/roojs1/less/bootstrap/bootstrap.less" => array(
+        'baseDir' => "/home/edward/Downloads/css-compiled", //"{$rootDir}/roojs1/css-bootstrap",
+        'name' => 'bootstrap.css',
+        'minify' => 'bootstrap.min.css'
+    ),
+    "{$rootDir}/roojs1/less/roojs-bootstrap/roojs-bootstrap.less" => array(
+        'baseDir' => "/home/edward/Downloads/css-compiled", //"{$rootDir}/roojs1/css-bootstrap",
+        'name' => 'roojs-bootstrap-debug.css',
+        'minify' => 'roojs-bootstrap.css'
+    )
+);
+
 require_once 'HTML/Less.php';
+        
+$less = new HTML_Less();
+
+foreach ($files as $src => $file){
+
+    if(!file_exists($src)){
+        echo "{$less} does not exist...\n";
+        continue;
+    }
 
-$less = new HTML_Less();
\ No newline at end of file
+    try {
+        
+        $css = "{$file['baseDir']}/{$file['name']}";
+        
+        echo "Compiling - {$src} To {$css}\n";
+        
+        $less->compileFile($src, $css);
+        
+    } catch (Exception $ex) {
+        echo "lessphp fatal error: {$ex->getMessage()}\n";
+    }
+    
+}
+
+require_once 'HTML/CSS/Minify.php';
+
+foreach ($files as $src => $file){
+    
+    $css = "{$file['baseDir']}/{$file['name']}";
+    
+    if(!file_exists($css)){
+        echo "{$css} does not exist...\n";
+        continue;
+    }
+    
+    $minify = new HTML_CSS_Minify($file['baseDir'], $file['baseDir'], array($file['name']));
+    
+    $content = $minify->minify();
+    
+    print_R($content);exit;
+    
+}