44
55namespace Php \Pie \Building ;
66
7+ use Composer \IO \IOInterface ;
78use Php \Pie \ComposerIntegration \BundledPhpExtensionsRepository ;
89use Php \Pie \Downloading \DownloadedPackage ;
910use Php \Pie \File \BinaryFile ;
1011use Php \Pie \Platform \TargetPhp \PhpizePath ;
1112use Php \Pie \Platform \TargetPlatform ;
1213use Php \Pie \Util \Process ;
1314use Php \Pie \Util \ProcessFailedWithLimitedOutput ;
14- use Symfony \Component \Console \Output \OutputInterface ;
1515use Symfony \Component \Process \Exception \ProcessFailedException ;
1616use Symfony \Component \Process \Process as SymfonyProcess ;
1717
@@ -35,13 +35,13 @@ public function __invoke(
3535 DownloadedPackage $ downloadedPackage ,
3636 TargetPlatform $ targetPlatform ,
3737 array $ configureOptions ,
38- OutputInterface $ output ,
38+ IOInterface $ io ,
3939 PhpizePath |null $ phpizePath ,
4040 ): BinaryFile {
4141 $ outputCallback = null ;
42- if ($ output ->isVerbose ()) {
43- $ outputCallback = static function (string $ type , string $ outputMessage ) use ($ output ): void {
44- $ output ->write (sprintf (
42+ if ($ io ->isVerbose ()) {
43+ $ outputCallback = static function (string $ type , string $ outputMessage ) use ($ io ): void {
44+ $ io ->write (sprintf (
4545 '%s%s%s ' ,
4646 $ type === SymfonyProcess::ERR ? '<comment> ' : '' ,
4747 $ outputMessage ,
@@ -58,29 +58,29 @@ public function __invoke(
5858 * already clean anyway; however, sometimes we want to rebuild the
5959 * current ext, so this will perform a clean first
6060 */
61- $ this ->cleanup ($ phpizePath , $ downloadedPackage , $ output , $ outputCallback );
61+ $ this ->cleanup ($ phpizePath , $ downloadedPackage , $ io , $ outputCallback );
6262
6363 $ this ->phpize (
6464 $ phpizePath ,
6565 $ downloadedPackage ,
66- $ output ,
66+ $ io ,
6767 $ outputCallback ,
6868 );
6969
70- $ output -> writeln ('<info>phpize complete</info>. ' );
70+ $ io -> write ('<info>phpize complete</info>. ' );
7171
7272 $ phpConfigPath = $ targetPlatform ->phpBinaryPath ->phpConfigPath ();
7373 if ($ phpConfigPath !== null ) {
7474 $ configureOptions [] = '--with-php-config= ' . $ phpConfigPath ;
7575 }
7676
77- $ this ->configure ($ downloadedPackage , $ configureOptions , $ output , $ outputCallback );
77+ $ this ->configure ($ downloadedPackage , $ configureOptions , $ io , $ outputCallback );
7878
7979 $ optionsOutput = count ($ configureOptions ) ? ' with options: ' . implode (' ' , $ configureOptions ) : '. ' ;
80- $ output -> writeln ('<info>Configure complete</info> ' . $ optionsOutput );
80+ $ io -> write ('<info>Configure complete</info> ' . $ optionsOutput );
8181
8282 try {
83- $ this ->make ($ targetPlatform , $ downloadedPackage , $ output , $ outputCallback );
83+ $ this ->make ($ targetPlatform , $ downloadedPackage , $ io , $ outputCallback );
8484 } catch (ProcessFailedException $ p ) {
8585 throw ProcessFailedWithLimitedOutput::fromProcessFailedException ($ p );
8686 }
@@ -91,26 +91,26 @@ public function __invoke(
9191 throw ExtensionBinaryNotFound::fromExpectedBinary ($ expectedSoFile );
9292 }
9393
94- $ output -> writeln (sprintf (
94+ $ io -> write (sprintf (
9595 '<info>Build complete:</info> %s ' ,
9696 $ expectedSoFile ,
9797 ));
9898
9999 return BinaryFile::fromFileWithSha256Checksum ($ expectedSoFile );
100100 }
101101
102- private function renamesToConfigM4 (DownloadedPackage $ downloadedPackage , OutputInterface $ output ): void
102+ private function renamesToConfigM4 (DownloadedPackage $ downloadedPackage , IOInterface $ io ): void
103103 {
104104 $ configM4 = $ downloadedPackage ->extractedSourcePath . DIRECTORY_SEPARATOR . 'config.m4 ' ;
105105 if (file_exists ($ configM4 )) {
106106 return ;
107107 }
108108
109- $ output -> writeln ('config.m4 does not exist; checking alternatives ' , OutputInterface:: VERBOSITY_VERY_VERBOSE );
109+ $ io -> write ('config.m4 does not exist; checking alternatives ' , verbosity: IOInterface:: VERY_VERBOSE );
110110 foreach (['config0.m4 ' , 'config9.m4 ' ] as $ alternateConfigM4 ) {
111111 $ fullPathToAlternate = $ downloadedPackage ->extractedSourcePath . DIRECTORY_SEPARATOR . $ alternateConfigM4 ;
112112 if (file_exists ($ fullPathToAlternate )) {
113- $ output -> writeln (sprintf ('Renaming %s to config.m4 ' , $ alternateConfigM4 ), OutputInterface:: VERBOSITY_VERY_VERBOSE );
113+ $ io -> write (sprintf ('Renaming %s to config.m4 ' , $ alternateConfigM4 ), verbosity: IOInterface:: VERY_VERBOSE );
114114 rename ($ fullPathToAlternate , $ configM4 );
115115
116116 return ;
@@ -122,16 +122,17 @@ private function renamesToConfigM4(DownloadedPackage $downloadedPackage, OutputI
122122 private function phpize (
123123 PhpizePath $ phpize ,
124124 DownloadedPackage $ downloadedPackage ,
125- OutputInterface $ output ,
125+ IOInterface $ io ,
126126 callable |null $ outputCallback ,
127127 ): void {
128128 $ phpizeCommand = [$ phpize ->phpizeBinaryPath ];
129129
130- if ($ output ->isVerbose ()) {
131- $ output ->writeln ('<comment>Running phpize step using: ' . implode (' ' , $ phpizeCommand ) . '</comment> ' );
132- }
130+ $ io ->write (
131+ '<comment>Running phpize step using: ' . implode (' ' , $ phpizeCommand ) . '</comment> ' ,
132+ verbosity: IOInterface::VERBOSE ,
133+ );
133134
134- $ this ->renamesToConfigM4 ($ downloadedPackage , $ output );
135+ $ this ->renamesToConfigM4 ($ downloadedPackage , $ io );
135136
136137 Process::run (
137138 $ phpizeCommand ,
@@ -148,14 +149,15 @@ private function phpize(
148149 private function configure (
149150 DownloadedPackage $ downloadedPackage ,
150151 array $ configureOptions ,
151- OutputInterface $ output ,
152+ IOInterface $ io ,
152153 callable |null $ outputCallback ,
153154 ): void {
154155 $ configureCommand = ['./configure ' , ...$ configureOptions ];
155156
156- if ($ output ->isVerbose ()) {
157- $ output ->writeln ('<comment>Running configure step with: ' . implode (' ' , $ configureCommand ) . '</comment> ' );
158- }
157+ $ io ->write (
158+ '<comment>Running configure step with: ' . implode (' ' , $ configureCommand ) . '</comment> ' ,
159+ verbosity: IOInterface::VERBOSE ,
160+ );
159161
160162 Process::run (
161163 $ configureCommand ,
@@ -169,13 +171,13 @@ private function configure(
169171 private function make (
170172 TargetPlatform $ targetPlatform ,
171173 DownloadedPackage $ downloadedPackage ,
172- OutputInterface $ output ,
174+ IOInterface $ io ,
173175 callable |null $ outputCallback ,
174176 ): void {
175177 $ makeCommand = ['make ' ];
176178
177179 if ($ targetPlatform ->makeParallelJobs === 1 ) {
178- $ output -> writeln ('Running make without parallelization - try providing -jN to PIE where N is the number of cores you have. ' );
180+ $ io -> write ('Running make without parallelization - try providing -jN to PIE where N is the number of cores you have. ' );
179181 } else {
180182 $ makeCommand [] = sprintf ('-j%d ' , $ targetPlatform ->makeParallelJobs );
181183 }
@@ -185,9 +187,10 @@ private function make(
185187 $ downloadedPackage ,
186188 );
187189
188- if ($ output ->isVerbose ()) {
189- $ output ->writeln ('<comment>Running make step with: ' . implode (' ' , $ makeCommand ) . '</comment> ' );
190- }
190+ $ io ->write (
191+ '<comment>Running make step with: ' . implode (' ' , $ makeCommand ) . '</comment> ' ,
192+ verbosity: IOInterface::VERBOSE ,
193+ );
191194
192195 Process::run (
193196 $ makeCommand ,
@@ -201,7 +204,7 @@ private function make(
201204 private function cleanup (
202205 PhpizePath $ phpize ,
203206 DownloadedPackage $ downloadedPackage ,
204- OutputInterface $ output ,
207+ IOInterface $ io ,
205208 callable |null $ outputCallback ,
206209 ): void {
207210 /**
@@ -210,18 +213,20 @@ private function cleanup(
210213 * configure script manually...
211214 */
212215 if (! file_exists ($ downloadedPackage ->extractedSourcePath . '/configure ' )) {
213- if ($ output ->isVerbose ()) {
214- $ output ->writeln ('<comment>Skipping phpize --clean, configure does not exist</comment> ' );
215- }
216+ $ io ->write (
217+ '<comment>Skipping phpize --clean, configure does not exist</comment> ' ,
218+ verbosity: IOInterface::VERBOSE ,
219+ );
216220
217221 return ;
218222 }
219223
220224 $ phpizeCleanCommand = [$ phpize ->phpizeBinaryPath , '--clean ' ];
221225
222- if ($ output ->isVerbose ()) {
223- $ output ->writeln ('<comment>Running phpize --clean step using: ' . implode (' ' , $ phpizeCleanCommand ) . '</comment> ' );
224- }
226+ $ io ->write (
227+ '<comment>Running phpize --clean step using: ' . implode (' ' , $ phpizeCleanCommand ) . '</comment> ' ,
228+ verbosity: IOInterface::VERBOSE ,
229+ );
225230
226231 Process::run (
227232 $ phpizeCleanCommand ,
@@ -230,6 +235,6 @@ private function cleanup(
230235 $ outputCallback ,
231236 );
232237
233- $ output -> writeln ('<info>Build files cleaned up.</info> ' );
238+ $ io -> write ('<info>Build files cleaned up.</info> ' );
234239 }
235240}
0 commit comments