Skip to content

Commit

Permalink
Build Phar: show more debug information
Browse files Browse the repository at this point in the history
* Number of files added for each PHAR.
* Total time the script took to run.
  • Loading branch information
jrfnl committed Dec 17, 2021
1 parent f4bec0a commit a4b5217
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion scripts/build-phar.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
exit(1);
}

$startTime = microtime(true);

$scripts = [
'phpcs',
'phpcbf',
Expand Down Expand Up @@ -51,6 +53,7 @@
$rdi = new \RecursiveDirectoryIterator($srcDir, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
$di = new \RecursiveIteratorIterator($rdi, 0, \RecursiveIteratorIterator::CATCH_GET_CHILD);

$fileCount = 0;
foreach ($di as $file) {
$filename = $file->getFilename();

Expand All @@ -66,7 +69,9 @@

$path = 'src'.substr($fullpath, $srcDirLen);
$phar->addFile($fullpath, $path);
}

++$fileCount;
}//end foreach

// Add autoloader.
$phar->addFile(realpath(__DIR__.'/../autoload.php'), 'autoload.php');
Expand All @@ -75,6 +80,7 @@
$phar->addFile(realpath(__DIR__.'/../licence.txt'), 'licence.txt');

echo 'done'.PHP_EOL;
echo "\t Added ".$fileCount.' files'.PHP_EOL;

/*
Add the stub.
Expand All @@ -93,3 +99,16 @@

echo 'done'.PHP_EOL;
}//end foreach

$timeTaken = ((microtime(true) - $startTime) * 1000);
if ($timeTaken < 1000) {
$timeTaken = round($timeTaken);
echo "DONE in {$timeTaken}ms".PHP_EOL;
} else {
$timeTaken = round(($timeTaken / 1000), 2);
echo "DONE in $timeTaken secs".PHP_EOL;
}

echo PHP_EOL;
echo 'Filesize generated phpcs.phar file: '.filesize(dirname(__DIR__).'/phpcs.phar').' bytes'.PHP_EOL;
echo 'Filesize generated phpcs.phar file: '.filesize(dirname(__DIR__).'/phpcbf.phar').' bytes'.PHP_EOL;

0 comments on commit a4b5217

Please sign in to comment.