@@ -18,11 +18,12 @@ final class IntegrationFailure extends RuntimeException
1818{
1919}
2020
21- /** @return array{compiler: string, php: string, php_fpm: string, keep: bool, suite: string} */
21+ /** @return array{compiler: string, compiler_ini_scan_dir: string, php: string, php_fpm: string, keep: bool, suite: string} */
2222function parseIntegrationOptions (array $ argv ): array
2323{
2424 $ options = [
2525 'compiler ' => TYPEPHP_INTEGRATION_ROOT . '/tpc ' ,
26+ 'compiler_ini_scan_dir ' => '' ,
2627 'php ' => PHP_BINARY ,
2728 'php_fpm ' => '' ,
2829 'keep ' => false ,
@@ -38,7 +39,7 @@ function parseIntegrationOptions(array $argv): array
3839 $ options ['suite ' ] = substr ($ argument , strlen ('--suite= ' ));
3940 continue ;
4041 }
41- foreach (['compiler ' , 'php ' , 'php-fpm ' ] as $ name ) {
42+ foreach (['compiler ' , 'compiler-ini-scan-dir ' , ' php ' , 'php-fpm ' ] as $ name ) {
4243 $ prefix = '-- ' . $ name . '= ' ;
4344 if (str_starts_with ($ argument , $ prefix )) {
4445 $ key = str_replace ('- ' , '_ ' , $ name );
@@ -61,6 +62,16 @@ function parseIntegrationOptions(array $argv): array
6162 $ options [$ name ] = $ path ;
6263 }
6364
65+ if ($ options ['compiler_ini_scan_dir ' ] !== '' ) {
66+ $ path = realpath ($ options ['compiler_ini_scan_dir ' ]);
67+ if ($ path === false || !is_dir ($ path )) {
68+ throw new IntegrationFailure (
69+ 'compiler ini scan directory does not exist: ' . $ options ['compiler_ini_scan_dir ' ],
70+ );
71+ }
72+ $ options ['compiler_ini_scan_dir ' ] = $ path ;
73+ }
74+
6475 if ($ options ['suite ' ] !== 'lib ' ) {
6576 if ($ options ['php_fpm ' ] === '' ) {
6677 $ prefix = integrationPhpPrefix ($ options ['php ' ]);
@@ -185,6 +196,18 @@ function integrationEnvironment(): array
185196 return getenv ();
186197}
187198
199+ /**
200+ * @param array{compiler_ini_scan_dir: string} $options
201+ * @return array<string, string>
202+ */
203+ function integrationCompilerEnvironment (array $ options ): array
204+ {
205+ if ($ options ['compiler_ini_scan_dir ' ] === '' ) {
206+ return [];
207+ }
208+ return ['PHP_INI_SCAN_DIR ' => $ options ['compiler_ini_scan_dir ' ]];
209+ }
210+
188211function assertIntegrationSame (string $ expected , string $ actual , string $ message ): void
189212{
190213 if ($ expected !== $ actual ) {
@@ -461,7 +484,7 @@ function runExtIntegration(array $options, string $temporaryRoot): void
461484 '--build-dir ' , $ temporaryRoot . '/ext-build- ' . $ name ,
462485 '--job ' , '1 ' ,
463486 '--no-progress ' ,
464- ]);
487+ ], environment: integrationCompilerEnvironment ( $ options ) );
465488 assertIntegrationTrue (is_file ($ extension ), 'Extension artifact was not generated: ' . $ extension );
466489 $ extensions [$ name ] = $ extension ;
467490 }
@@ -601,7 +624,7 @@ function runLibIntegration(array $options, string $temporaryRoot): void
601624 $ options ['compiler ' ], $ providerRoot . '/project.yml ' ,
602625 '--output ' , $ providerRoot . '/ ' . $ target . '. ' . PHP_SHLIB_SUFFIX ,
603626 '--build-dir ' , $ providerRoot . '/build ' , '--job ' , '1 ' , '--no-progress ' ,
604- ]);
627+ ], environment: integrationCompilerEnvironment ( $ options ) );
605628
606629 $ library = $ providerRoot . '/ ' . $ target . '. ' . PHP_SHLIB_SUFFIX ;
607630 $ stub = $ providerRoot . '/ ' . $ target . '.stub.php ' ;
@@ -648,7 +671,7 @@ function runLibIntegration(array $options, string $temporaryRoot): void
648671 '--build-dir ' , $ consumerRoot . '/build ' ,
649672 '--link-path ' , $ linkRoot ,
650673 '--job ' , '1 ' , '--no-progress ' ,
651- ]);
674+ ], environment: integrationCompilerEnvironment ( $ options ) );
652675 $ libraryPath = $ linkRoot ;
653676 $ environment = PHP_OS_FAMILY === 'Darwin '
654677 ? ['DYLD_LIBRARY_PATH ' => $ libraryPath . ': ' . (getenv ('DYLD_LIBRARY_PATH ' ) ?: '' )]
0 commit comments