Skip to content

Commit

Permalink
Switched to Google Closure compiler.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Gorbatchev committed Jul 2, 2010
1 parent 04fc240 commit 682bf8c
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 85 deletions.
12 changes: 8 additions & 4 deletions build/build.xml
Expand Up @@ -48,11 +48,12 @@
<copy todir="${output.bin.scripts.dir}">
<fileset dir="${sh.scripts.dir}">
<include name="sh*.js" />
<include name="*.swf" />
<exclude name="shCore.js" />
</fileset>
</copy>

<append destFile="${output.bin.scripts.dir}/shCore.js" file="${sh.scripts.dir}/XRegExp.js" />
<append destFile="${output.bin.scripts.dir}/shCore.js" file="${sh.scripts.dir}/shCore.js" />

<copy todir="${output.src.scripts.dir}">
<fileset dir="${sh.scripts.dir}">
Expand All @@ -65,16 +66,19 @@
<copy todir="${output.styles.dir}">
<fileset dir="${sh.styles.dir}">
<include name="sh*.css" />
<include name="*.png" />
</fileset>
</copy>

<copy todir="${output.dir}">
<fileset dir="${sh.dir}">
<include name="*.html" />
<include name="*.txt" />
<include name="demoes/**" />
<include name="tests/**" />
<include name="compass/**" />
<include name="*-LICENSE" />
</fileset>
</copy>

<delete dir="${output.dir}/compass/.sass-cache" />
</target>

<!-- Replace VERSION and ABOUT tokens in the JS and CSS files -->
Expand Down
162 changes: 81 additions & 81 deletions build/ext/PackerTask.php
@@ -1,81 +1,81 @@
<?php
require_once("phing/tasks/system/CopyTask.php");
require_once(dirname(__FILE__)."/packer/class.JavaScriptPacker.php");

class PackerTask extends CopyTask
{
protected $filesets = array(); // all fileset objects assigned to this task

/**
* Nested creator, creates a FileSet for this task
*
* @access public
* @return object The created fileset object
*/
function createFileSet()
{
$num = array_push($this->filesets, new FileSet());
return $this->filesets[$num-1];
}

/**
* Validates attributes coming in from XML
*
* @access private
* @return void
* @throws BuildException
*/
protected function validateAttributes()
{
if (count($this->filesets) === 0)
throw new BuildException("PackerTask. Specify a fileset.");
}

public function init()
{
}

public function pack($file)
{
$file = realpath($file);
$home = dirname(__FILE__);
$jar = realpath("$home/custom_rhino.jar");

$java = "java";
exec("$java -version", &$output, &$result);
if ($result != 0)
throw new BuildException("Java not found.");

// first we pack the file using DOJO shrinksafe
$cmd = "$java -jar \"$jar\" -c \"$file\" > \"$file.tmp\"";
exec($cmd, &$output, &$result);

if ($result != 0)
throw new BuildException("Java error.");

unlink($file);
rename("$file.tmp", $file);

// after DOJO, we use the Packer to tighten it up.
$script = file_get_contents($file);
$packer = new JavaScriptPacker($script, 62, true, false);
$packed = $packer->pack();
file_put_contents($file, $packed);

$this->log("$file packed.", Project::MSG_INFO);
}

public function main()
{
foreach($this->filesets as $fs)
{
$ds = $fs->getDirectoryScanner($this->project);
$files = $ds->getIncludedFiles();

$dir = $fs->getDir($this->project);

foreach($files as $file)
$this->pack("$dir/$file");
}
}
}
<?php
require_once("phing/tasks/system/CopyTask.php");
require_once(dirname(__FILE__)."/packer/class.JavaScriptPacker.php");

class PackerTask extends CopyTask
{
protected $filesets = array(); // all fileset objects assigned to this task

/**
* Nested creator, creates a FileSet for this task
*
* @access public
* @return object The created fileset object
*/
function createFileSet()
{
$num = array_push($this->filesets, new FileSet());
return $this->filesets[$num-1];
}

/**
* Validates attributes coming in from XML
*
* @access private
* @return void
* @throws BuildException
*/
protected function validateAttributes()
{
if (count($this->filesets) === 0)
throw new BuildException("PackerTask. Specify a fileset.");
}

public function init()
{
}

public function pack($file)
{
$file = realpath($file);
$home = dirname(__FILE__);
$jar = realpath("$home/compiler.jar");

$java = "java";
exec("$java -version", &$output, &$result);
if ($result != 0)
throw new BuildException("Java not found.");

// first we pack the file using DOJO shrinksafe
$cmd = "$java -jar \"$jar\" --js=\"$file\" --js_output_file=\"$file.tmp\"";
exec($cmd, &$output, &$result);

if ($result != 0)
throw new BuildException("Java error.");

unlink($file);
rename("$file.tmp", $file);

// after DOJO, we use the Packer to tighten it up.
$script = file_get_contents($file);
$packer = new JavaScriptPacker($script, 62, true, false);
$packed = $packer->pack();
file_put_contents($file, $packed);

$this->log("$file packed.", Project::MSG_INFO);
}

public function main()
{
foreach($this->filesets as $fs)
{
$ds = $fs->getDirectoryScanner($this->project);
$files = $ds->getIncludedFiles();

$dir = $fs->getDir($this->project);

foreach($files as $file)
$this->pack("$dir/$file");
}
}
}
Binary file added build/ext/compiler.jar
Binary file not shown.
Binary file removed build/ext/custom_rhino.jar
Binary file not shown.

0 comments on commit 682bf8c

Please sign in to comment.