buildSDK/less-bootstrap-compiler.php
[roojs1] / buildSDK / less-bootstrap-compiler.php
index 3ac00fa..4016da1 100644 (file)
@@ -1,8 +1,69 @@
 <?php
 
-/* 
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
+$cwd = getcwd();
 
+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' => "/tmp/css-compiled", //"{$rootDir}/roojs1/css-bootstrap",
+        'name' => 'bootstrap.css',
+        'minify' => 'bootstrap.min.css'
+    ),
+    "{$rootDir}/roojs1/less/roojs-bootstrap/roojs-bootstrap.less" => array(
+        'baseDir' => "/tmp/css-compiled", //"{$rootDir}/roojs1/css-bootstrap",
+        'name' => 'roojs-bootstrap-debug.css',
+        'minify' => 'roojs-bootstrap.css'
+    )
+);
+
+require_once 'HTML/Less.php';
+        
+$less = new HTML_Less();
+
+//require_once 'HTML/CSS/Minify.php';
+//
+//$minify = new HTML_CSS_Minify();
+
+$minify = array();
+
+foreach ($files as $less => $file){
+
+    if(!file_exists($less)){
+        echo "{$less} does not exist...\n";
+        continue;
+    }
+
+    try {
+        
+        $css = "{$file['baseDir']}/{$file['name']}";
+        
+        echo "Compiling - {$less} To {$css}\n";
+        
+        $less->compileFile($less, $css);
+        
+        if(!file_exists($css)){
+            echo "Compile failed?!\n";
+            continue;
+        }
+        
+        $minify[$file['mimify']] = $css;
+
+    } catch (Exception $ex) {
+        echo "lessphp fatal error: {$ex->getMessage()}\n";
+    }
+    
+}
+
+print_R($minify);
\ No newline at end of file