4 * wrapper code around js builder...
6 * -- we will use this later to compile on the fly...
8 require_once 'Pman.php';
11 class Pman_Builder_JsCompiler extends Pman
16 // command line only ATM
17 $this->cli = HTML_FlexyFramework::get()->cli;
18 // var_dump($this->cli);
26 function get($proj, $args=array())
29 die("missing action : eg. build or install");
32 if (empty($args[1])) {
33 $ar = $this->gatherProjects();
47 case 'install' : // needed for install on remote sites..
57 echo "Building $proj\n";
60 $this->err = "no project";
61 if ($this->cli) echo $this->err;
64 $src = realpath(dirname(__FILE__).'/../'. $proj);
65 if (!file_exists(dirname(__FILE__).'/../../_compiled_tmp_/'.$proj)) {
66 mkdir(dirname(__FILE__).'/../../_compiled_tmp_/'.$proj, 0755, true);
70 $tmp = realpath(dirname(__FILE__).'/../../_compiled_tmp_');
71 //$tmp = ini_get('session.save_path')."/{$proj}_". posix_getuid(). '_'.md5($src);
72 require_once 'System.php';
73 $roolite = System::which('roolite');
74 $svn = System::which('svn');
76 $this->err ="no roolite";
77 if ($this->cli) echo $this->err;
80 $o = PEAR::getStaticProperty('Pman_Builder','options');
81 if (empty($o['jstoolkit'])) {
82 $this->err ="no jstoolkit path";
83 if ($this->cli) echo $this->err;
87 // should we be more specirfic!??!?!?
89 $buildjs = realpath(dirname(__FILE__) .'/jsbuilder/build.js');
90 $cmd = "$roolite $buildjs -L{$o['jstoolkit']} -- ".
91 escapeshellarg( $src) . " " . escapeshellarg($tmp);
95 // copy into the revision controlled area.
97 $src = realpath(dirname(__FILE__).'/../../_compiled_tmp_/'.$proj .'.js');
101 $pdir = realpath(dirname(__FILE__).'/../'. $proj);
102 if (!file_exists($pdir.'/compiled')) {
103 mkdir($pdir.'/compiled', 0755, true);
106 copy($src , $pdir.'/compiled/'. $proj .'.js');
108 // copy the translation strings.
109 $src = realpath(dirname(__FILE__).'/../../_compiled_tmp_/'.$proj .'/build/_translation_.js');
112 $pdir = realpath(dirname(__FILE__).'/../'. $proj);
114 copy($src , $pdir.'/compiled/_translation_.js');
119 $cmd = "$svn add compiled";
121 $cmd = "$svn add ". escapeshellarg('compiled/'.$proj .'.js');
122 $cmd = "$svn add ". escapeshellarg('compiled/_translation_.js');
125 `$svn commit -m 'update compiled version'`;
133 $ret = $tmp . '/'. $proj . '.js';
135 echo "BUILT: $ret \n";
142 // link {PROJECT}/compiled/{PROJECT}.js to _compiled_ folder to make it live.
144 function install($proj)
147 $base = dirname(realpath($_SERVER["SCRIPT_FILENAME"]));
151 var_dump($base .'/Pman/'. $proj.'/compiled/'.$proj .'.js');
152 $src = realpath($base .'/Pman/'. $proj.'/compiled/'.$proj .'.js');
154 echo "SKIP : no js file $proj\n";
157 if (!file_exists("$base/_compiled_")) {
158 mkdir ("$base/_compiled_", 0755, true);
160 $target = "$base/_compiled_/".$proj .'.js';
161 print_R(array($src,$target));
162 if (file_exists($target)) {
163 return; // already installed.
166 symlink($src, $target);
171 function gatherProjects() {
172 $src = realpath(dirname(__FILE__).'/../');
174 foreach(scandir($src) as $f) {
175 if (!strlen($f) || $f[0] == '.') {
183 if ($f == 'templates') {