diff --git a/tools/cli/bundle.php b/tools/cli/bundle.php index d3082094c..ed2386e7f 100644 --- a/tools/cli/bundle.php +++ b/tools/cli/bundle.php @@ -1,26 +1,58 @@ . + * + * Small command line script to bundle Doctrine classes in a single file. + * + * @author Nicolas BĂ©rard-Nault + * @author Konsta Vesterinen + * @package Doctrine + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @version $Revision$ + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 */ + if (count($argv) < 2) { - echo "Usage: bundle.php [Target directory] \n\n". - "Note: If the library directory is ommited, the path will be deducted\n"; + echo "Usage: bundle.php [Target file] \n\n". + "Note: If the library directory is ommited, the path will be deducted if possible\n"; exit(1); } else if (count($argv) == 3) { $doctrineBaseDir = $argv[2]; } else { - $doctrineBaseDir = str_replace('tools/cli', 'lib', $_SERVER['PWD'], $Cnt); - + $pathInfos = pathinfo($_SERVER['PHP_SELF']); + + $doctrineBaseDir = str_replace('tools/cli/'. $pathInfos['basename'], + 'lib', getcwd() .'/'. $_SERVER['SCRIPT_NAME'], $Cnt); + if ($Cnt != 1) { echo "Can't find library directory, please specify it as an argument\n"; exit(1); } } -$targetDir = $argv[1]; +$targetFile = $argv[1]; -echo "Target directory: $targetDir\n"; -echo "Base directory: $doctrineBaseDir\n\n"; +echo "Target file: $targetFile" . PHP_EOL; +echo "Base directory: $doctrineBaseDir" . PHP_EOL; +echo PHP_EOL; set_include_path(get_include_path() . PATH_SEPARATOR . $doctrineBaseDir); @@ -29,11 +61,12 @@ require_once 'Doctrine/Compiler.php'; spl_autoload_register(array('Doctrine', 'autoload')); -echo "Bundling classes ..." . PHP_EOL; +echo "Bundling classes and interfaces..." . PHP_EOL; -Doctrine_Compiler::compile($targetDir); +Doctrine_Compiler::compile($targetFile); -echo "Bundle complete." . PHP_EOL; +echo PHP_EOL . "Bundle complete." . PHP_EOL; +echo "File: $targetFile (size: ". number_format(filesize($targetFile) / 1024, 2, '.', '') ." kb)." . PHP_EOL; exit(0); ?>