cvs: php4(NEW_UI_API) /pear/PEAR Builder.php
| From: | Stig Bakken | Date: | Sat, 01 Jun 2002 20:45:51 +0000 |
| Subject: | cvs: php4(NEW_UI_API) /pear/PEAR Builder.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4342@lists.php.net to get a copy of this message | ||
ssb Sat Jun 1 16:45:51 2002 EDT
Modified files: (Branch: NEW_UI_API)
/php4/pear/PEAR Builder.php
Log:
* add some phpdoc
Index: php4/pear/PEAR/Builder.php
diff -u php4/pear/PEAR/Builder.php:1.1.2.1 php4/pear/PEAR/Builder.php:1.1.2.2
--- php4/pear/PEAR/Builder.php:1.1.2.1 Tue May 28 23:38:19 2002
+++ php4/pear/PEAR/Builder.php Sat Jun 1 16:45:46 2002
@@ -16,7 +16,7 @@
// | Authors: Stig Sæther Bakken <ssb@fast.no> |
// +----------------------------------------------------------------------+
//
-// $Id: Builder.php,v 1.1.2.1 2002/05/29 03:38:19 ssb Exp $
+// $Id: Builder.php,v 1.1.2.2 2002/06/01 20:45:46 ssb Exp $
require_once 'PEAR/Common.php';
@@ -38,7 +38,6 @@
var $current_callback = null;
// }}}
-
// {{{ constructor
/**
@@ -54,8 +53,37 @@
$this->setFrontendObject($ui);
}
+ // }}}
+ // {{{ build()
+
+ /**
+ * Build an extension from source. Runs "phpize" in the source
+ * directory, but compiles in a temporary directory
+ * (/var/tmp/pear-build-USER/PACKAGE-VERSION).
+ *
+ * @param string $descfile path to XML package description file
+ *
+ * @param mixed $callback callback function used to report output,
+ * see PEAR_Builder::_runCommand for details
+ *
+ * @return array an array of associative arrays with built files,
+ * format:
+ * array( array( 'name' => '/path/to/ext.so',
+ * 'php_api' => YYYYMMDD,
+ * 'zend_mod_api' => YYYYMMDD,
+ * 'zend_ext_api' => YYYYMMDD ),
+ * ... )
+ *
+ * @access public
+ *
+ * @see PEAR_Builder::_runCommand
+ * @see PEAR_Common::infoFromDescriptionFile
+ */
function build($descfile, $callback = null)
{
+ if (PEAR_OS != 'Unix') {
+ return $this->raiseError("building extensions not supported on this
platform");
+ }
if (PEAR::isError($info = $this->infoFromDescriptionFile($descfile))) {
return $info;
}
@@ -126,12 +154,20 @@
chdir($old_cwd);
return $this->raiseError("no `modules' directory found");
}
+ $built_files = array();
while ($ent = readdir($dp)) {
if ($ent{0} == '.' || substr($ent, -3) == '.la') {
continue;
}
// harvest!
if (@copy("modules/$ent", "$dir/$ent")) {
+ $built_files[] = array(
+ 'file' => "$dir/$ent",
+ 'php_api' => $this->php_api_version,
+ 'zend_mod_api' => $this->zend_module_api_no,
+ 'zend_ext_api' => $this->zend_extension_api_no,
+ );
+
$this->log(1, "$ent copied to $dir/$ent");
} else {
chdir($old_cwd);
@@ -140,11 +176,24 @@
}
closedir($dp);
chdir($old_cwd);
- return true;
+ return $built_files;
}
// }}}
+ // {{{ phpizeCallback()
+ /**
+ * Message callback function used when running the "phpize"
+ * program. Extracts the API numbers used. Ignores other message
+ * types than "cmdoutput".
+ *
+ * @param string $what the type of message
+ * @param mixed $data the message
+ *
+ * @return void
+ *
+ * @access public
+ */
function phpizeCallback($what, $data)
{
if ($what != 'cmdoutput') {
@@ -165,6 +214,25 @@
}
}
+ // }}}
+ // {{{ _runCommand()
+
+ /**
+ * Run an external command, using a message callback to report
+ * output. The command will be run through popen and output is
+ * reported for every line with a "cmdoutput" message with the
+ * line string, including newlines, as payload.
+ *
+ * @param string $command the command to run
+ *
+ * @param mixed $callback (optional) function to use as message
+ * callback
+ *
+ * @return bool whether the command was successful (exit code 0
+ * means success, any other means failure)
+ *
+ * @access private
+ */
function _runCommand($command, $callback = null)
{
$this->log(1, "running: $command");
@@ -183,6 +251,9 @@
return ($exitcode == 0);
}
+ // }}}
+ // {{{ log()
+
function log($level, $msg)
{
if ($this->current_callback) {
@@ -193,6 +264,8 @@
}
return PEAR_Common::log($level, $msg);
}
+
+ // }}}
}
?>