Changeset 322
- Timestamp:
- 12/20/07 03:00:35 (7 months ago)
- Files:
-
- branches/2.3/bin/phing.php (modified) (2 diffs)
- branches/2.3/classes/phing/Phing.php (modified) (11 diffs)
- branches/2.3/classes/phing/parser/AbstractSAXParser.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2.3/bin/phing.php
r123 r322 11 11 // --------------------------- 12 12 13 ini_set('track_errors', 1);14 15 13 /* set classpath */ 16 14 if (getenv('PHP_CLASSPATH')) { … … 23 21 require_once 'phing/Phing.php'; 24 22 25 /* Setup Phing environment */ 26 Phing::startup(); 23 try { 24 25 /* Setup Phing environment */ 26 Phing::startup(); 27 27 28 /* 29 find phing home directory 30 -- if Phing is installed from PEAR this will probably be null, 31 which is fine (I think). Nothing uses phing.home right now. 32 */ 33 Phing::setProperty('phing.home', getenv('PHING_HOME')); 28 // Set phing.home property to the value from environment 29 // (this may be NULL, but that's not a big problem.) 30 Phing::setProperty('phing.home', getenv('PHING_HOME')); 34 31 35 36 /* polish CLI arguments */ 37 $args = isset($argv) ? $argv : $_SERVER['argv']; // $_SERVER['argv'] seems not to work when argv is registered (PHP5b4) 38 array_shift($args); // 1st arg is script name, so drop it 39 40 /* fire main application */ 41 Phing::fire($args); 42 43 /* 44 exit OO system if not already called by Phing 45 -- basically we should not need this due to register_shutdown_function in Phing 46 */ 47 Phing::halt(0); 32 // Grab and clean up the CLI arguments 33 $args = isset($argv) ? $argv : $_SERVER['argv']; // $_SERVER['argv'] seems not to work when argv is registered (PHP5b4) 34 array_shift($args); // 1st arg is script name, so drop it 35 36 // Invoke the commandline entry point 37 Phing::fire($args); 38 39 // Invoke any shutdown routines. 40 Phing::shutdown(); 41 42 } catch (Exception $x) { 43 // There was a problem; it should have already been reported as part of the build 44 // results, so we just need to return the result code. 45 if ($x->getCode() != 0) { 46 exit($x->getCode()); 47 } else { 48 exit(1); 49 } 50 } 48 51 49 52 ?> branches/2.3/classes/phing/Phing.php
r295 r322 137 137 * @param array $additionalUserProperties Any additional properties to be passed to Phing (alternative front-end might implement this). 138 138 * These additional properties will be available using the getDefinedProperty() method and will 139 * be added to the project's "user" properties. 140 * @return void 139 * be added to the project's "user" properties 141 140 * @see execute() 142 141 * @see runBuild() 142 * @throws Exception - if there is an error during build 143 143 */ 144 144 public static function start(&$args, $additionalUserProperties = null) { … … 150 150 self::handleLogfile(); // clean up log file before attempting to print message 151 151 $m->printMessage($exc); 152 self::halt(-1); // Parameter error152 throw $exc; 153 153 } 154 154 … … 173 173 } 174 174 self::handleLogfile(); 175 self::halt(1); // Errors occured175 throw $exc; 176 176 } 177 177 178 178 // everything fine, shutdown 179 179 self::handleLogfile(); 180 self::halt(0);181 180 } 182 181 … … 371 370 } elseif (substr($arg,0,1) == "-") { 372 371 // we don't have any more args 373 self::$err->write("Unknown argument: $arg" );372 self::$err->write("Unknown argument: $arg" . PHP_EOL); 374 373 self::printUsage(); 375 374 return; … … 776 775 $versionPath = self::getResourcePath("etc/VERSION.TXT"); 777 776 } 777 if ($versionPath === null) { 778 throw new ConfigurationException("No VERSION.TXT file found; try setting phing.home environment variable."); 779 } 778 780 try { // try to read file 779 781 $buffer = null; … … 1000 1002 1001 1003 foreach (self::$importPaths as $prefix) { 1002 $ foo_path = $prefix . DIRECTORY_SEPARATOR . $path;1003 if (file_exists($ foo_path)) {1004 return $ foo_path;1004 $testPath = $prefix . DIRECTORY_SEPARATOR . $path; 1005 if (file_exists($testPath)) { 1006 return $testPath; 1005 1007 } 1006 1008 } 1007 1009 1008 1010 // Check for the property phing.home 1009 $home_dir = self::getProperty('phing.home'); 1010 1011 if ($home_dir) 1012 { 1013 $home_path = $home_dir . DIRECTORY_SEPARATOR . $path; 1014 1015 if (file_exists($home_path)) 1016 { 1017 return $home_path; 1011 $homeDir = self::getProperty('phing.home'); 1012 if ($homeDir) { 1013 $testPath = $homeDir . DIRECTORY_SEPARATOR . $path; 1014 if (file_exists($testPath)) { 1015 return $testPath; 1018 1016 } 1019 1017 } … … 1022 1020 // This is a bit of a hack, but works better than previous solution of assuming 1023 1021 // data_dir is on the include_path. 1024 $data_dir = '@DATA-DIR@'; 1025 if ($data_dir{0} != '@') { // if we're using PEAR then the @ DATA-DIR @ token will have been substituted. 1026 $data_path = $data_dir . DIRECTORY_SEPARATOR . $path; 1027 if (file_exists($data_path)) { 1028 return $data_path; 1022 $dataDir = '@DATA-DIR@'; 1023 if ($dataDir{0} != '@') { // if we're using PEAR then the @ DATA-DIR @ token will have been substituted. 1024 $testPath = $dataDir . DIRECTORY_SEPARATOR . $path; 1025 if (file_exists($testPath)) { 1026 return $testPath; 1027 } 1028 } else { 1029 // We're not using PEAR, so do one additional check based on path of 1030 // current file (Phing.php) 1031 $maybeHomeDir = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); 1032 $testPath = $maybeHomeDir . DIRECTORY_SEPARATOR . $path; 1033 if (file_exists($testPath)) { 1034 return $testPath; 1029 1035 } 1030 1036 } … … 1181 1187 * Sets the include path based on PHP_CLASSPATH constant (set in phing.php). 1182 1188 * @return void 1189 * @throws BuildException - if the include_path could not be set (for some bizarre reason) 1183 1190 */ 1184 1191 private static function setIncludePaths() { … … 1193 1200 1194 1201 if ($success === false) { 1195 self::$err->write("SYSTEM FAILURE: Could not set PHP include path"); 1196 self::halt(-1); 1202 throw new BuildException("Could not set PHP include path"); 1197 1203 } 1198 1204 } … … 1210 1216 ini_set('register_globals', 'off'); 1211 1217 ini_set('allow_call_time_pass_reference', 'on'); 1212 1218 ini_set('track_errors', 1); 1219 1213 1220 // should return memory limit in MB 1214 1221 $mem_limit = (int) ini_get('memory_limit'); … … 1264 1271 public static function shutdown($exitcode = 0) { 1265 1272 self::getTimer()->stop(); 1266 exit($exitcode); // final point where everything stops1273 //exit($exitcode); // final point where everything stops 1267 1274 } 1268 1275 branches/2.3/classes/phing/parser/AbstractSAXParser.php
r186 r322 28 28 * @author Andreas Aderhold <andi@binarycloud.com> 29 29 * @author Hans Lellelid <hans@xmpl.org> 30 * @copyright ©2001,2002 THYRELL. All rights reserved30 * @copyright ᅵ 2001,2002 THYRELL. All rights reserved 31 31 * @version $Revision: 1.13 $ 32 32 * @package phing.parser … … 66 66 * <code>startElement()</code> method. 67 67 * 68 * BECAUSE OF PROBLEMS WITH EXCEPTIONS BUBBLING UP THROUGH xml_parse() THIS69 * METHOD WILL CALL Phing::halt(-1) ON EXCEPTION.70 *71 68 * @param object the php's internal parser handle 72 69 * @param string the open tag name 73 70 * @param array the tag's attributes if any 71 * @throws Exception - Exceptions may be thrown by the Handler 74 72 */ 75 73 function startElement($parser, $name, $attribs) { 76 try { 77 $this->handler->startElement($name, $attribs); 78 } catch (Exception $e) { 79 print "[Exception in XML parsing]\n"; 80 print $e; 81 Phing::halt(-1); 82 } 74 $this->handler->startElement($name, $attribs); 83 75 } 84 76 … … 92 84 * <code>endElement()</code> method. 93 85 * 94 * BECAUSE OF PROBLEMS WITH EXCEPTIONS BUBBLING UP THROUGH xml_parse() THIS95 * METHOD WILL CALL Phing::halt(-1) ON EXCEPTION.96 *97 86 * @param object the php's internal parser handle 98 87 * @param string the closing tag name 88 * @throws Exception - Exceptions may be thrown by the Handler 99 89 */ 100 90 function endElement($parser, $name) { 101 try { 102 $this->handler->endElement($name); 103 } catch (Exception $e) { 104 print "[Exception in XML parsing]\n"; 105 print $e; 106 Phing::halt(-1); 107 } 91 $this->handler->endElement($name); 108 92 } 109 93 … … 117 101 * <code>characters()</code> method. That processes the given CDATA. 118 102 * 119 * BECAUSE OF PROBLEMS WITH EXCEPTIONS BUBBLING UP THROUGH xml_parse() THIS120 * METHOD WILL CALL Phing::halt(-1) ON EXCEPTION.121 *122 103 * @param resource $parser php's internal parser handle. 123 104 * @param string $data the CDATA 105 * @throws Exception - Exceptions may be thrown by the Handler 124 106 */ 125 107 function characters($parser, $data) { 126 try { 127 $this->handler->characters($data); 128 } catch (Exception $e) { 129 print "[Exception in XML parsing]\n"; 130 print $e; 131 Phing::halt(-1); 132 } 108 $this->handler->characters($data); 133 109 } 134 110
