]> granicus.if.org Git - php/commitdiff
* update 0.11 release notes
authorStig Bakken <ssb@php.net>
Tue, 28 May 2002 01:01:43 +0000 (01:01 +0000)
committerStig Bakken <ssb@php.net>
Tue, 28 May 2002 01:01:43 +0000 (01:01 +0000)
* move build logic into PEAR_Builder

pear/PEAR/Builder.php [new file with mode: 0644]
pear/PEAR/Command/Build.php
pear/package-PEAR.xml

diff --git a/pear/PEAR/Builder.php b/pear/PEAR/Builder.php
new file mode 100644 (file)
index 0000000..8cf44b5
--- /dev/null
@@ -0,0 +1,106 @@
+<?php
+//
+// +----------------------------------------------------------------------+
+// | PHP Version 4                                                        |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2002 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/2_02.txt.                                 |
+// | If you did not receive a copy of the PHP license and are unable to   |
+// | obtain it through the world-wide-web, please send a note to          |
+// | license@php.net so we can mail you a copy immediately.               |
+// +----------------------------------------------------------------------+
+// | Authors: Stig Sæther Bakken <ssb@fast.no>                            |
+// +----------------------------------------------------------------------+
+//
+// $Id$
+
+require_once 'PEAR/Common.php';
+
+/**
+ * Class to handle building (compiling) extensions.
+ *
+ * @author Stig Sæther Bakken <ssb@fast.no>
+ */
+class PEAR_Builder extends PEAR_Common
+{
+    // {{{ properties
+
+    // }}}
+
+    // {{{ constructor
+
+    /**
+     * PEAR_Builder constructor.
+     *
+     * @param object $ui user interface object (instance of PEAR_Frontend_*)
+     *
+     * @access public
+     */
+    function PEAR_Builder(&$ui)
+    {
+        $this->PEAR_Common();
+        $this->setFrontendObject($ui);
+    }
+
+    function build($descfile, $callback = null)
+    {
+        if (PEAR::isError($info = $this->infoFromDescriptionFile($descfile))) {
+            return $info;
+        }
+        $configure_command = "./configure";
+        if (isset($info['configure_options'])) {
+            foreach ($info['configure_options'] as $o) {
+                $r = $this->ui->userDialog($o['prompt'], 'text', @$o['default']);
+                if (substr($o['name'], 0, 5) == 'with-' &&
+                    ($r == 'yes' || $r == 'autodetect')) {
+                    $configure_command .= " --$o[name]";
+                } else {
+                    $configure_command .= " --$o[name]=$r";
+                }
+            }
+        }
+        if (isset($_ENV['MAKE'])) {
+            $make_command = $_ENV['MAKE'];
+        } else {
+            $make_command = 'make';
+        }
+        $to_run = array(
+            "phpize",
+            $configure_command,
+            $make_command,
+            );
+        foreach ($to_run as $cmd) {
+            $err = $this->_runCommand($cmd, $callback);
+            if (PEAR::isError($err)) {
+                return $err;
+            }
+            if (!$err) {
+                break;
+            }
+        }
+        return true;
+
+    }
+
+    // }}}
+
+
+    function _runCommand($command, $callback = null)
+    {
+        $pp = @popen($command, "r");
+        if (!$pp) {
+            return $this->raiseError("failed to run `$command'");
+        }
+        while ($line = fgets($pp, 1024)) {
+            call_user_func($callback, 'output', $line);
+        }
+        pclose($pp);
+        return true;
+    }
+}
+
+?>
index 6a661eb9f47b2153ff1bbb12b23ed8d33b3cb142..ee03d092018277c0cc051e9737e5dc5f315946ba 100644 (file)
@@ -21,6 +21,7 @@
 // $Id$
 
 require_once "PEAR/Command/Common.php";
+require_once "PEAR/Builder.php";
 
 /**
  * PEAR commands for building extensions.
@@ -54,49 +55,20 @@ Builds one or more extensions contained in a package.'
         if (sizeof($params) < 1) {
             $params[0] = 'package.xml';
         }
-        $obj = &new PEAR_Common();
-        if (PEAR::isError($info = $obj->infoFromAny($params[0]))) {
-            return $info;
-        }
-        $configure_command = "./configure";
-        if (isset($info['configure_options'])) {
-            foreach ($info['configure_options'] as $o) {
-                $r = $this->ui->userDialog($o['prompt'], 'text', @$o['default']);
-                if ($r == 'yes' && substr($o['name'], 0, 5) == 'with-') {
-                    $configure_command .= " --$o[name]";
-                } else {
-                    $configure_command .= " --$o[name]=$r";
-                }
-            }
-        }
-        if (isset($_ENV['MAKE'])) {
-            $make_command = $_ENV['MAKE'];
-        } else {
-            $make_command = 'make';
-        }
-        $to_run = array(
-            "phpize",
-            $configure_command,
-            $make_command,
-            );
-        foreach ($to_run as $cmd) {
-            if (PEAR::isError($err = $this->_runCommand($cmd))) {
-                return $err;
-            }
+        $builder = &new PEAR_Builder($this->ui);
+        $err = $builder->build($params[0], array(&$this, 'buildCallback'));
+        if (PEAR::isError($err)) {
+            return $err;
         }
         return true;
     }
 
-    function _runCommand($command)
+    function buildCallback($what, $data)
     {
-        $pp = @popen($command, "r");
-        if (!$pp) {
-            return $this->raiseError("failed to run `$command'");
-        }
-        while ($line = fgets($pp, 1024)) {
-            $this->ui->displayLine(rtrim($line));
+        switch ($what) {
+            case 'output':
+                $this->ui->displayLine(rtrim($data));
+                break;
         }
-        pclose($pp);
-        
     }
 }
index a049d6895bc69249e6007d3912ad394c78a801a8..ae5a41ca55b53c18f66e05c2004f1ac06b061fa5 100644 (file)
     <state>beta</state>
     <date>YYYY-MM-DD</date>
     <notes>
-* fixed broken "help" command
+* fix: "help" command was broken
 * new command: "info"
 * new command: "config-help"
 * un-indent multi-line data from xml description files
 * new command: "build"
+* fix: config-set did not work with "set" parameters
+* disable magic_quotes_runtime
 </notes>
     <filelist>
       <file role="data" name="package.dtd"/>
@@ -65,6 +67,7 @@
           <file role="php" name="CLI.php"/>
           <file role="php" name="Gtk.php"/>
         </dir>
+        <file role="php" name="Builder.php"/>
         <file role="php" name="Installer.php"/>
         <file role="php" name="Packager.php"/>
         <file role="php" name="Registry.php"/>