Allow build/gen_stub.php to process multiple CLI file args (#7179)

E.g. `build/gen_stub.php *.stub.php` will generate `*_arginfo.h`
from multiple files.

Previously, gen_stub.php would silently ignore files after the first file.

Invoking gen_stub.php with no arguments will continue to process the entire
directory.
This commit is contained in:
Tyson Andre 2021-06-20 15:14:01 -04:00 committed by GitHub
parent 28a1a6be08
commit e748dcacad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2311,18 +2311,20 @@ if (isset($options["h"]) || isset($options["help"])) {
}
$fileInfos = [];
$location = $argv[$optind] ?? ".";
if (is_file($location)) {
// Generate single file.
$fileInfo = processStubFile($location, $context);
if ($fileInfo) {
$fileInfos[] = $fileInfo;
$locations = array_slice($argv, $optind) ?: ['.'];
foreach (array_unique($locations) as $location) {
if (is_file($location)) {
// Generate single file.
$fileInfo = processStubFile($location, $context);
if ($fileInfo) {
$fileInfos[] = $fileInfo;
}
} else if (is_dir($location)) {
array_push($fileInfos, ...processDirectory($location, $context));
} else {
echo "$location is neither a file nor a directory.\n";
exit(1);
}
} else if (is_dir($location)) {
$fileInfos = processDirectory($location, $context);
} else {
echo "$location is neither a file nor a directory.\n";
exit(1);
}
if ($printParameterStats) {