Making the build routine in PEAR_builder more generic.
| From: | Alan Knowles | Date: | Sat, 19 Oct 2002 16:05:31 +0000 |
| Subject: | Making the build routine in PEAR_builder more generic. | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-10129@lists.php.net to get a copy of this message | ||
ok, this patch enables PEAR_Builder::build() to take an option array as well as an xml file for building.
any objections to it going in..?
Regards
Alan
Index: Builder.php
===================================================================
RCS file: /repository/php4/pear/PEAR/Builder.php,v
retrieving revision 1.7
diff -u -r1.7 Builder.php
--- Builder.php 26 Aug 2002 00:37:25 -0000 1.7
+++ Builder.php 19 Oct 2002 16:06:02 -0000
@@ -64,12 +64,9 @@
* Build an extension from source on windows.
* requires msdev
*/
- function _build_win32($descfile, $callback = null)
+ function _build_win32($info, $callback = null)
{
- if (PEAR::isError($info = $this->infoFromDescriptionFile($descfile))) {
- return $info;
- }
- $dir = dirname($descfile);
+ $dir = dirname($info['dir']);
$old_cwd = getcwd();
if (!@chdir($dir)) {
@@ -157,7 +154,15 @@
* 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 $info path to XML package description file + * or configuration array
+ *
+ * info array consists of + * package // package name
+ * version // package version
+ * configure_options // bits that can be prompted from user
+ * dir // source directory location
+ *
*
* @param mixed $callback callback function used to report output,
* see PEAR_Builder::_runCommand for details
@@ -175,23 +180,45 @@
* @see PEAR_Builder::_runCommand
* @see PEAR_Common::infoFromDescriptionFile
*/
- function build($descfile, $callback = null)
+ function build($info, $callback = null)
{
- if (PEAR_OS == "Windows") {
- return $this->_build_win32($descfile,$callback);
+ + /* is info an array or desc file */
+ + if (!is_array($info)) {
+ $descfile = $info;
+ if (PEAR::isError($info = $this->infoFromDescriptionFile($descfile))) {
+ return $info;
+ }
+ $info['dir'] = dirname($descfile);
}
- if (PEAR_OS != 'Unix') {
- return $this->raiseError("building extensions not supported on this platform");
+ + if (PEAR_OS == "Windows") {
+ return $this->_build_win32($info,$callback);
}
- if (PEAR::isError($info = $this->infoFromDescriptionFile($descfile))) {
- return $info;
+ if (PEAR_OS == 'Unix') {
+ return $this->_build_unix($info,$callback);
}
- $dir = dirname($descfile);
+ return $this->raiseError("building extensions not supported on this platform");
+ }
+ // }}}
+ + + // {{{ _build_unix()
+
+ /**
+ * Build an extension from source on Unix.
+ */
+ + function _build_unix($info,$callback = null) + {
+ $dir = dirname($info['dir']);
+
$old_cwd = getcwd();
if (!@chdir($dir)) {
return $this->raiseError("could not chdir to $dir");
}
- $vdir = "$info[package]-$info[version]";
+ $vdir = $info['package'] . '-' . $info['version'];
if (is_dir($vdir)) {
chdir($vdir);
}
@@ -229,7 +256,7 @@
$user='defaultuser';
}
$build_basedir = "/var/tmp/pear-build-$user";
- $build_dir = "$build_basedir/$info[package]-$info[version]";
+ $build_dir = "$build_basedir/". $info['package'] . '-' .$info['version'];
$this->log(1, "building in $build_dir");
if (is_dir($build_dir)) {
System::rm("-rf $build_dir");