summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2005-12-10 18:06:51 +0000
committerxue <>2005-12-10 18:06:51 +0000
commit974959a59b7e857ba72772f23ee4d2540195378c (patch)
tree5c9fa31f704f49cf762a80a233d5cc41af599d26
parentc2e61e72d621020691309d5478e58e4df540e53f (diff)
Moved JavaScript build script to tools directory.
Modified JavaScript build script to reflect the above path changing. Added Prado Script build script that merges core script files into one to save script inclusion time for Prado applications.
-rw-r--r--.gitattributes4
-rw-r--r--tools/jsbuilder/build.php150
-rw-r--r--tools/jsbuilder/custom_rhino.jarbin0 -> 731885 bytes
-rw-r--r--tools/phpbuilder/build.php55
-rw-r--r--tools/phpbuilder/files.txt25
5 files changed, 234 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes
index fd9a35e0..f860df16 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -385,3 +385,7 @@ tests/UnitTests/simpletest/url.php -text
tests/UnitTests/simpletest/user_agent.php -text
tests/UnitTests/simpletest/web_tester.php -text
tests/UnitTests/simpletest/xml.php -text
+tools/jsbuilder/build.php -text
+tools/jsbuilder/custom_rhino.jar -text
+tools/phpbuilder/build.php -text
+tools/phpbuilder/files.txt -text
diff --git a/tools/jsbuilder/build.php b/tools/jsbuilder/build.php
new file mode 100644
index 00000000..28d809c1
--- /dev/null
+++ b/tools/jsbuilder/build.php
@@ -0,0 +1,150 @@
+#!/usr/bin/php
+<?php
+/**
+ * Javascript build file.
+ *
+ * This script compresses a list of javascript source files
+ * and merges them into a few for redistribution.
+ *
+ * This script should be run from command line with PHP.
+ * JRE 1.4 or above is required in order to run the js compression program.
+ *
+ * By default, all libraries will be built.
+ * You may, however, specify one or several to be built (to save time during development).
+ * To do so, pass the library names (without .js) as command line arguments.
+ * For example: php build.php base dom
+ *
+ * @author Xiang Wei Zhuo <weizhuo@gmail.com>, Qiang Xue <qiang.xue@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Revision: $ $Date: $
+ * @package Tools
+ */
+
+/**
+ * The compression command line
+ */
+define('COMPRESS_COMMAND','java -jar '.dirname(__FILE__).'/custom_rhino.jar -c %s > %s');
+/**
+ * The root directory for storing all source js files
+ */
+define('SOURCE_DIR',realpath(dirname(__FILE__).'/../../framework/Web/JavaScripts'));
+/**
+ * The directory for storing compressed js files
+ */
+define('TARGET_DIR',realpath(dirname(__FILE__).'/../../framework/Web/JavaScripts/js'));
+
+if(SOURCE_DIR===false || TARGET_DIR===false)
+ die('Unable to determine the build path.');
+if(!is_writable(TARGET_DIR))
+ die('Unable to create files under '.TARGET_DIR.'.');
+
+/**
+ * list of js library files to be compressed and built
+ */
+$libraries = array(
+ //base javascript functions
+ 'base.js' => array(
+ 'prototype/prototype.js',
+ 'prototype/compat.js',
+ 'prototype/base.js',
+ 'extended/base.js',
+ 'extended/util.js',
+ 'prototype/string.js',
+ 'extended/string.js',
+ 'prototype/enumerable.js',
+ 'prototype/array.js',
+ 'extended/array.js',
+ 'prototype/hash.js',
+ 'prototype/range.js',
+ 'extended/functional.js',
+ 'base/prado.js',
+ 'base/postback.js',
+ 'base/focus.js',
+ 'base/scroll.js'
+ ),
+ //dom functions
+ 'dom.js' => array(
+ 'prototype/dom.js',
+ 'extended/dom.js',
+ 'prototype/form.js',
+ 'prototype/event.js',
+ 'extended/event.js',
+ 'prototype/position.js',
+ 'extra/getElementsBySelector.js',
+ 'extra/behaviour.js',
+ 'effects/util.js'
+ ),
+ //effects
+ 'effects.js' => array(
+ 'effects/effects.js'
+ ),
+ //controls
+ 'controls.js' => array(
+ 'effects/controls.js',
+ 'effects/dragdrop.js',
+ 'base/controls.js'
+ ),
+ //logging
+ 'logger.js' => array(
+ 'extra/logger.js',
+ ),
+ //ajax
+ 'ajax.js' => array(
+ 'prototype/ajax.js',
+ 'base/ajax.js',
+ 'base/json.js'
+ ),
+ //rico
+ 'rico.js' => array(
+ 'effects/rico.js'
+ ),
+ //javascript templating
+ 'template.js' => array(
+ 'extra/tp_template.js'
+ ),
+ //validator
+ 'validator.js' => array(
+ 'base/validation.js',
+ 'base/validators.js'
+ ),
+ //date picker
+ 'datepicker.js' => array(
+ 'base/datepicker.js'
+ )
+);
+
+/**
+ * Collect specific libraries to be built from command line
+ */
+$requestedLibs=array();
+for($i=1;$i<$argc;++$i)
+ $requestedLibs[]=$argv[$i].'.js';
+
+/**
+ * loop through all target files and build them one by one
+ */
+foreach($libraries as $libFile => $sourceFiles)
+{
+ if(!empty($requestedLibs) && !in_array($libFile,$requestedLibs))
+ continue;
+ $libFile=TARGET_DIR.'/'.$libFile;
+ echo "\nBuilding $libFile...\n";
+ $contents='';
+ foreach($sourceFiles as $sourceFile)
+ {
+ $sourceFile=SOURCE_DIR.'/'.$sourceFile;
+ if(!is_file($sourceFile))
+ echo "Source file not found: $sourceFile\n";
+ $tempFile=$sourceFile.'.tmp';
+ $command=sprintf(COMPRESS_COMMAND,$sourceFile,$tempFile);
+ echo "...adding $sourceFile\n".
+ system($command);
+ $contents.=file_get_contents($tempFile);
+ @unlink($tempFile);
+ }
+ file_put_contents($libFile,$contents);
+}
+
+?> \ No newline at end of file
diff --git a/tools/jsbuilder/custom_rhino.jar b/tools/jsbuilder/custom_rhino.jar
new file mode 100644
index 00000000..4a97cdeb
--- /dev/null
+++ b/tools/jsbuilder/custom_rhino.jar
Binary files differ
diff --git a/tools/phpbuilder/build.php b/tools/phpbuilder/build.php
new file mode 100644
index 00000000..a96ab12f
--- /dev/null
+++ b/tools/phpbuilder/build.php
@@ -0,0 +1,55 @@
+#!/usr/bin/php
+<?php
+/**
+ * Prado build file.
+ *
+ * This script compresses a list of Prado PHP script files
+ * and merges them into one for performance redistribution.
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Revision: $ $Date: $
+ * @package Tools
+ */
+
+/**
+ * The merged file name
+ */
+define('OUTPUT_FILE','pradolite.php');
+/**
+ * The framework directory
+ */
+define('FRAMEWORK_DIR',realpath(dirname(__FILE__).'/../../framework'));
+/**
+ * The file containing script list to be built
+ */
+define('SCRIPT_FILES',dirname(__FILE__).'/files.txt');
+
+if(FRAMEWORK_DIR===false)
+ die('Unable to determine the installation directory of Prado Framework.');
+if(!is_file(SCRIPT_FILES))
+ die('Unable to read '.SCRIPT_FILES.'.');
+
+$output='';
+
+$lines=file(SCRIPT_FILES);
+foreach($lines as $line)
+{
+ $line=trim($line);
+ if($line==='')
+ continue;
+ echo 'adding '.FRAMEWORK_DIR.'/'.$line."\n";
+ $input=file_get_contents(FRAMEWORK_DIR.'/'.$line);
+ $input=strtr($input,"\r",'');
+ $input=preg_replace('/\/\*.*?\*\//s','',$input);
+ $input=preg_replace('/^Prado::using\([^\*]*?\);/m','',$input);
+ $input=preg_replace('/^(require|require_once)\s*\(.*?;/m','',$input);
+ $input=preg_replace('/^(include|include_once)\s*\(.*?;/m','',$input);
+ $output.=$input;
+}
+
+file_put_contents(FRAMEWORK_DIR.'/'.OUTPUT_FILE,$output);
+
+?> \ No newline at end of file
diff --git a/tools/phpbuilder/files.txt b/tools/phpbuilder/files.txt
new file mode 100644
index 00000000..22218685
--- /dev/null
+++ b/tools/phpbuilder/files.txt
@@ -0,0 +1,25 @@
+TComponent.php
+Exceptions/TException.php
+Collections/TList.php
+Collections/TMap.php
+Data/TXmlDocument.php
+Web/THttpUtility.php
+core.php
+prado.php
+TApplication.php
+Exceptions/TErrorHandler.php
+Web/THttpRequest.php
+Web/THttpResponse.php
+Web/THttpSession.php
+Security/TAuthorizationRule.php
+Web/Services/TPageService.php
+Web/UI/TTemplateManager.php
+Web/UI/TThemeManager.php
+Web/UI/TAssetManager.php
+Web/UI/THiddenFieldPageStatePersister.php
+Web/UI/TControl.php
+Web/UI/TTemplateControl.php
+Web/UI/TForm.php
+Web/UI/TClientScriptManager.php
+Web/UI/THtmlWriter.php
+Web/UI/TPage.php \ No newline at end of file