Build.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * PEAR_Command_Auth (build command)
  4. *
  5. * PHP versions 4 and 5
  6. *
  7. * @category pear
  8. * @package PEAR
  9. * @author Stig Bakken <ssb@php.net>
  10. * @author Tomas V.V.Cox <cox@idecnet.com>
  11. * @author Greg Beaver <cellog@php.net>
  12. * @copyright 1997-2009 The Authors
  13. * @license http://opensource.org/licenses/bsd-license.php New BSD License
  14. * @link http://pear.php.net/package/PEAR
  15. * @since File available since Release 0.1
  16. */
  17. /**
  18. * base class
  19. */
  20. require_once 'PEAR/Command/Common.php';
  21. /**
  22. * PEAR commands for building extensions.
  23. *
  24. * @category pear
  25. * @package PEAR
  26. * @author Stig Bakken <ssb@php.net>
  27. * @author Tomas V.V.Cox <cox@idecnet.com>
  28. * @author Greg Beaver <cellog@php.net>
  29. * @copyright 1997-2009 The Authors
  30. * @license http://opensource.org/licenses/bsd-license.php New BSD License
  31. * @version Release: 1.10.10
  32. * @link http://pear.php.net/package/PEAR
  33. * @since Class available since Release 0.1
  34. */
  35. class PEAR_Command_Build extends PEAR_Command_Common
  36. {
  37. var $commands = array(
  38. 'build' => array(
  39. 'summary' => 'Build an Extension From C Source',
  40. 'function' => 'doBuild',
  41. 'shortcut' => 'b',
  42. 'options' => array(
  43. 'configureoptions' => array(
  44. 'shortopt' => 'D',
  45. 'arg' => 'OPTION1=VALUE[ OPTION2=VALUE]',
  46. 'doc' => 'space-delimited list of configure options',
  47. ),
  48. ),
  49. 'doc' => '[package.xml]
  50. Builds one or more extensions contained in a package.'
  51. ),
  52. );
  53. /**
  54. * PEAR_Command_Build constructor.
  55. *
  56. * @access public
  57. */
  58. function __construct(&$ui, &$config)
  59. {
  60. parent::__construct($ui, $config);
  61. }
  62. function doBuild($command, $options, $params)
  63. {
  64. require_once 'PEAR/Builder.php';
  65. if (sizeof($params) < 1) {
  66. $params[0] = 'package.xml';
  67. }
  68. $configureoptions = empty($options['configureoptions']) ? '' : $options['configureoptions'];
  69. $builder = new PEAR_Builder($configureoptions, $this->ui);
  70. $this->debug = $this->config->get('verbose');
  71. $err = $builder->build($params[0], array(&$this, 'buildCallback'));
  72. if (PEAR::isError($err)) {
  73. return $err;
  74. }
  75. return true;
  76. }
  77. function buildCallback($what, $data)
  78. {
  79. if (($what == 'cmdoutput' && $this->debug > 1) ||
  80. ($what == 'output' && $this->debug > 0)) {
  81. $this->ui->outputData(rtrim($data), 'build');
  82. }
  83. }
  84. }