Build.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 5 |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2004 The PHP Group |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 3.0 of the PHP license, |
  9. // | that is bundled with this package in the file LICENSE, and is |
  10. // | available through the world-wide-web at the following url: |
  11. // | http://www.php.net/license/3_0.txt. |
  12. // | If you did not receive a copy of the PHP license and are unable to |
  13. // | obtain it through the world-wide-web, please send a note to |
  14. // | [email protected] so we can mail you a copy immediately. |
  15. // +----------------------------------------------------------------------+
  16. // | Author: Stig Bakken <[email protected]> |
  17. // | Tomas V.V.Cox <[email protected]> |
  18. // | |
  19. // +----------------------------------------------------------------------+
  20. //
  21. // $Id: Build.php,v 1.9 2004/01/08 17:33:13 sniper Exp $
  22. require_once "PEAR/Command/Common.php";
  23. require_once "PEAR/Builder.php";
  24. /**
  25. * PEAR commands for building extensions.
  26. *
  27. */
  28. class PEAR_Command_Build extends PEAR_Command_Common
  29. {
  30. // {{{ properties
  31. var $commands = array(
  32. 'build' => array(
  33. 'summary' => 'Build an Extension From C Source',
  34. 'function' => 'doBuild',
  35. 'shortcut' => 'b',
  36. 'options' => array(),
  37. 'doc' => '[package.xml]
  38. Builds one or more extensions contained in a package.'
  39. ),
  40. );
  41. // }}}
  42. // {{{ constructor
  43. /**
  44. * PEAR_Command_Build constructor.
  45. *
  46. * @access public
  47. */
  48. function PEAR_Command_Build(&$ui, &$config)
  49. {
  50. parent::PEAR_Command_Common($ui, $config);
  51. }
  52. // }}}
  53. // {{{ doBuild()
  54. function doBuild($command, $options, $params)
  55. {
  56. if (sizeof($params) < 1) {
  57. $params[0] = 'package.xml';
  58. }
  59. $builder = &new PEAR_Builder($this->ui);
  60. $this->debug = $this->config->get('verbose');
  61. $err = $builder->build($params[0], array(&$this, 'buildCallback'));
  62. if (PEAR::isError($err)) {
  63. return $err;
  64. }
  65. return true;
  66. }
  67. // }}}
  68. // {{{ buildCallback()
  69. function buildCallback($what, $data)
  70. {
  71. if (($what == 'cmdoutput' && $this->debug > 1) ||
  72. ($what == 'output' && $this->debug > 0)) {
  73. $this->ui->outputData(rtrim($data), 'build');
  74. }
  75. }
  76. // }}}
  77. }