/
BuildCommand.php
90 lines (77 loc) · 2.9 KB
/
BuildCommand.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
* This file is part of the Zephir.
*
* (c) Zephir Team <team@zephir-lang.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Zephir\Command;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Zephir\Command\BuildCommand
*
* Generates/Compiles/Installs a Zephir extension.
*
* @package Zephir\Command
*/
class BuildCommand extends ContainerAwareCommand implements DevelopmentModeAwareInterface
{
use DevelopmentModeAwareTrait;
protected function configure()
{
$this
->setName('build')
->setDescription('Generates/Compiles/Installs a Zephir extension')
->addOption(
'backend',
null,
InputOption::VALUE_REQUIRED,
'Used backend to build extension',
'ZendEngine3'
)
->addOption('dev', null, InputOption::VALUE_NONE, 'Build the extension in development mode')
->addOption('no-dev', null, InputOption::VALUE_NONE, 'Build the extension in production mode')
->setHelp($this->getDevelopmentModeHelp());
}
protected function execute(InputInterface $input, OutputInterface $output)
{
/** TODO: Process flags
-f([a-z0-9\-]+) Enables compiler optimizations
-fno-([a-z0-9\-]+) Disables compiler optimizations
-w([a-z0-9\-]+) Turns a warning on
-W([a-z0-9\-]+) Turns a warning off
*/
$command = $this->getApplication()->find('install');
$arguments = [
'command' => 'install',
'--backend' => $input->getOption('backend'),
'--dev' => $this->isDevelopmentModeEnabled($input),
];
return $command->run(new ArrayInput($arguments), $output);
}
/**
* {@inheritdoc}
*
* @return string
*/
public function getDevelopmentModeHelp()
{
return <<<EOT
Generates/Compiles/Installs a Zephir extension.
Just a meta command that just calls "generate", "compile" and "install" commands.
Using "--dev" option will force building and installing the extension in development mode
(debug symbols and no optimizations). An extension compiled with debugging symbols means
you can run a program or library through a debugger and the debugger's output will be user
friendlier. These debugging symbols also enlarge the program or library significantly.
Note: Zephir development mode will be enabled silently if your PHP binary was compiled in
a debug configuration.
In some cases, we would like to get production ready extension even if the PHP binary was
compiled in a debug configuration. Use "--no-dev" option to achieve this behavior.
EOT;
}
}