From 903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 Mon Sep 17 00:00:00 2001 From: ctrlaltca <> Date: Thu, 12 Jul 2012 11:21:01 +0000 Subject: standardize the use of unix eol; use svn properties to enforce native eol --- buildscripts/phpbuilder/build.php | 294 +++++++++++++++++++------------------- 1 file changed, 147 insertions(+), 147 deletions(-) (limited to 'buildscripts/phpbuilder/build.php') diff --git a/buildscripts/phpbuilder/build.php b/buildscripts/phpbuilder/build.php index 1df70b58..17e02806 100644 --- a/buildscripts/phpbuilder/build.php +++ b/buildscripts/phpbuilder/build.php @@ -1,148 +1,148 @@ -#!/usr/bin/php - - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Id$ - * @package Tools - */ - -/** - * The framework directory - */ -define('FRAMEWORK_DIR',realpath(dirname(__FILE__).'/../../framework')); -/** - * The merged file name - */ -define('OUTPUT_FILE','pradolite.php'); - - -if(FRAMEWORK_DIR===false || !is_file(FRAMEWORK_DIR.'/prado.php')) - die('Unable to determine the installation directory of Prado Framework.'); - -$lastupdate=date('Y/m/d H:i:s'); -$comments=" -/** - * File Name: pradolite.php - * Last Update: $lastupdate - * Generated By: buildscripts/phpbuilder/build.php - * - * This file is used in lieu of prado.php to boost PRADO application performance. - * It is generated by expanding prado.php with included files. - * Comments and trace statements are stripped off. - * - * Do not modify this file manually. - */ -"; - -$content=unfold_file(FRAMEWORK_DIR.'/prado.php'); -$content="|<\?php)/mu','',$content)."\n?>"; -$content=strip_comments($content); -$content=preg_replace('/^\s*Prado::trace.*\s*;\s*$/mu','',$content); -$content=strip_empty_lines($content); -$content=substr_replace($content,$comments,5,0); -file_put_contents(FRAMEWORK_DIR.'/'.OUTPUT_FILE,$content); -echo "Done.\n"; - -exit(); - -function strip_comments($source) -{ - $tokens = token_get_all($source); - /* T_ML_COMMENT does not exist in PHP 5. - * The following three lines define it in order to - * preserve backwards compatibility. - * - * The next two lines define the PHP 5-only T_DOC_COMMENT, - * which we will mask as T_ML_COMMENT for PHP 4. - */ - if (!defined('T_ML_COMMENT')) { - @define('T_ML_COMMENT', T_COMMENT); - } else { - @define('T_DOC_COMMENT', T_ML_COMMENT); - } - $output = ''; - foreach ($tokens as $token) { - if (is_string($token)) { - // simple 1-character token - $output .= $token; - } else { - // token array - list($id, $text) = $token; - switch ($id) { - case T_COMMENT: - case T_ML_COMMENT: // we've defined this - case T_DOC_COMMENT: // and this - // no action on comments - break; - default: - // anything else -> output "as is" - $output .= $text; - break; - } - } - } - return $output; -} - -function strip_empty_lines($string) -{ - $string = preg_replace("/[\r\n]+[\s\t]*[\r\n]+/", "\n", $string); - $string = preg_replace("/^[\s\t]*[\r\n]+/", "", $string); - return $string; -} - -function unfold_file($fileName) -{ - static $unfoldedFiles=array(); - $pattern='^(Prado::using|require_once|include_once)\s*\(([^\*]*?)\);'; - echo "adding $fileName...\n"; - $content=file_get_contents($fileName); - while(preg_match("/$pattern/m",$content,$matches,PREG_OFFSET_CAPTURE)) - { - $offset=$matches[0][1]; - $length=strlen($matches[0][0]); - $type=$matches[1][0]; - $file=trim($matches[2][0],"'\""); - if($type==='Prado::using') - { - $file=substr_replace(strtr($file,'.','/'),FRAMEWORK_DIR,0,6).'.php'; - } - else - { - $file=strtr($file,'"',"'"); - if(($pos=strpos($file,"'"))!==false) - $file=FRAMEWORK_DIR.'/'.substr($file,$pos+1); - else - die('Unable to process file '.$fileName.' about '.$matches[0][0]); - } - if(($file=realpath($file))===false || !is_file($file)) - die('Unable to process file '.$fileName.' about '.$matches[0][0]); - if(isset($unfoldedFiles[$file])) - { - $content=substr_replace($content,'',$offset,$length); - } - else - { - $unfoldedFiles[$file]=true; - $content=substr_replace($content,unfold_file($file),$offset,$length); - } - } - return $content; -} - +#!/usr/bin/php + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + * @package Tools + */ + +/** + * The framework directory + */ +define('FRAMEWORK_DIR',realpath(dirname(__FILE__).'/../../framework')); +/** + * The merged file name + */ +define('OUTPUT_FILE','pradolite.php'); + + +if(FRAMEWORK_DIR===false || !is_file(FRAMEWORK_DIR.'/prado.php')) + die('Unable to determine the installation directory of Prado Framework.'); + +$lastupdate=date('Y/m/d H:i:s'); +$comments=" +/** + * File Name: pradolite.php + * Last Update: $lastupdate + * Generated By: buildscripts/phpbuilder/build.php + * + * This file is used in lieu of prado.php to boost PRADO application performance. + * It is generated by expanding prado.php with included files. + * Comments and trace statements are stripped off. + * + * Do not modify this file manually. + */ +"; + +$content=unfold_file(FRAMEWORK_DIR.'/prado.php'); +$content="|<\?php)/mu','',$content)."\n?>"; +$content=strip_comments($content); +$content=preg_replace('/^\s*Prado::trace.*\s*;\s*$/mu','',$content); +$content=strip_empty_lines($content); +$content=substr_replace($content,$comments,5,0); +file_put_contents(FRAMEWORK_DIR.'/'.OUTPUT_FILE,$content); +echo "Done.\n"; + +exit(); + +function strip_comments($source) +{ + $tokens = token_get_all($source); + /* T_ML_COMMENT does not exist in PHP 5. + * The following three lines define it in order to + * preserve backwards compatibility. + * + * The next two lines define the PHP 5-only T_DOC_COMMENT, + * which we will mask as T_ML_COMMENT for PHP 4. + */ + if (!defined('T_ML_COMMENT')) { + @define('T_ML_COMMENT', T_COMMENT); + } else { + @define('T_DOC_COMMENT', T_ML_COMMENT); + } + $output = ''; + foreach ($tokens as $token) { + if (is_string($token)) { + // simple 1-character token + $output .= $token; + } else { + // token array + list($id, $text) = $token; + switch ($id) { + case T_COMMENT: + case T_ML_COMMENT: // we've defined this + case T_DOC_COMMENT: // and this + // no action on comments + break; + default: + // anything else -> output "as is" + $output .= $text; + break; + } + } + } + return $output; +} + +function strip_empty_lines($string) +{ + $string = preg_replace("/[\r\n]+[\s\t]*[\r\n]+/", "\n", $string); + $string = preg_replace("/^[\s\t]*[\r\n]+/", "", $string); + return $string; +} + +function unfold_file($fileName) +{ + static $unfoldedFiles=array(); + $pattern='^(Prado::using|require_once|include_once)\s*\(([^\*]*?)\);'; + echo "adding $fileName...\n"; + $content=file_get_contents($fileName); + while(preg_match("/$pattern/m",$content,$matches,PREG_OFFSET_CAPTURE)) + { + $offset=$matches[0][1]; + $length=strlen($matches[0][0]); + $type=$matches[1][0]; + $file=trim($matches[2][0],"'\""); + if($type==='Prado::using') + { + $file=substr_replace(strtr($file,'.','/'),FRAMEWORK_DIR,0,6).'.php'; + } + else + { + $file=strtr($file,'"',"'"); + if(($pos=strpos($file,"'"))!==false) + $file=FRAMEWORK_DIR.'/'.substr($file,$pos+1); + else + die('Unable to process file '.$fileName.' about '.$matches[0][0]); + } + if(($file=realpath($file))===false || !is_file($file)) + die('Unable to process file '.$fileName.' about '.$matches[0][0]); + if(isset($unfoldedFiles[$file])) + { + $content=substr_replace($content,'',$offset,$length); + } + else + { + $unfoldedFiles[$file]=true; + $content=substr_replace($content,unfold_file($file),$offset,$length); + } + } + return $content; +} + ?> \ No newline at end of file -- cgit v1.2.3