Merge remote-tracking branch 'origin/v3-refactor/libs' into v3-refactor/libs

This commit is contained in:
crazywhalecc 2026-02-04 15:28:36 +08:00
commit 8f44b07a12
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
3 changed files with 22 additions and 19 deletions

View File

@ -22,9 +22,9 @@ class curl
{
shell()->cd($lib->getSourceDir())->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ./CMakeLists.txt');
if (SystemTarget::getTargetOS() === 'Darwin') {
FileSystem::replaceFileRegex("{$lib->getSourceDir()}/curl/CMakeLists.txt", '/NOT COREFOUNDATION_FRAMEWORK/m', 'FALSE');
FileSystem::replaceFileRegex("{$lib->getSourceDir()}/curl/CMakeLists.txt", '/NOT SYSTEMCONFIGURATION_FRAMEWORK/m', 'FALSE');
FileSystem::replaceFileRegex("{$lib->getSourceDir()}/curl/CMakeLists.txt", '/NOT CORESERVICES_FRAMEWORK/m', 'FALSE');
FileSystem::replaceFileRegex("{$lib->getSourceDir()}/CMakeLists.txt", '/NOT COREFOUNDATION_FRAMEWORK/m', 'FALSE');
FileSystem::replaceFileRegex("{$lib->getSourceDir()}/CMakeLists.txt", '/NOT SYSTEMCONFIGURATION_FRAMEWORK/m', 'FALSE');
FileSystem::replaceFileRegex("{$lib->getSourceDir()}/CMakeLists.txt", '/NOT CORESERVICES_FRAMEWORK/m', 'FALSE');
}
return true;
}

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace StaticPHP\Command;
use StaticPHP\Artifact\DownloaderOptions;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Util\V2CompatLayer;
use Symfony\Component\Console\Attribute\AsCommand;
@ -23,6 +24,8 @@ class BuildLibsCommand extends BaseCommand
new InputOption('no-download', null, null, 'Skip downloading artifacts (use existing cached files)'),
...V2CompatLayer::getLegacyBuildOptions(),
]);
// Downloader options (with 'dl-' prefix to avoid conflicts)
$this->getDefinition()->addOptions(DownloaderOptions::getConsoleOptions('dl'));
}
public function handle(): int

View File

@ -63,7 +63,7 @@ class LicenseDumper
}
}
// Generate LICENSE-SUMMARY.json (read-modify-write)
// Generate SUMMARY.json (read-modify-write)
$this->generateSummary($target_dir, $license_summary);
logger()->info("Successfully dumped {$dumped_count} license(s) to: {$target_dir}");
@ -198,7 +198,7 @@ class LicenseDumper
}
/**
* Generate LICENSE-SUMMARY.json file with read-modify-write support.
* Generate SUMMARY.json file with read-modify-write support.
*
* @param string $target_dir Target directory
* @param array<string, array> $license_summary License summary data (license_type => [artifacts])
@ -210,14 +210,14 @@ class LicenseDumper
return;
}
$summary_file = "{$target_dir}/LICENSE-SUMMARY.json";
$summary_file = "{$target_dir}/SUMMARY.json";
// Read existing summary if exists
$existing_data = [];
if (file_exists($summary_file)) {
$content = file_get_contents($summary_file);
$existing_data = json_decode($content, true) ?? [];
logger()->debug('Loaded existing LICENSE-SUMMARY.json');
logger()->debug('Loaded existing SUMMARY.json');
}
// Initialize structure
@ -225,7 +225,7 @@ class LicenseDumper
$existing_data['artifacts'] = [];
}
if (!isset($existing_data['summary'])) {
$existing_data['summary'] = ['license_types' => []];
$existing_data['summary'] = ['license-types' => []];
}
// Merge new license information
@ -234,30 +234,30 @@ class LicenseDumper
// Add/update artifact info
$existing_data['artifacts'][$artifact_name] = [
'license' => $license_type,
'dumped_at' => date('Y-m-d H:i:s'),
'dumped-at' => date('Y-m-d H:i:s'),
];
// Update license_types summary
if (!isset($existing_data['summary']['license_types'][$license_type])) {
$existing_data['summary']['license_types'][$license_type] = [];
if (!isset($existing_data['summary']['license-types'][$license_type])) {
$existing_data['summary']['license-types'][$license_type] = [];
}
if (!in_array($artifact_name, $existing_data['summary']['license_types'][$license_type])) {
$existing_data['summary']['license_types'][$license_type][] = $artifact_name;
if (!in_array($artifact_name, $existing_data['summary']['license-types'][$license_type])) {
$existing_data['summary']['license-types'][$license_type][] = $artifact_name;
}
}
}
// Sort license types and artifacts
ksort($existing_data['summary']['license_types']);
foreach ($existing_data['summary']['license_types'] as &$artifacts) {
ksort($existing_data['summary']['license-types']);
foreach ($existing_data['summary']['license-types'] as &$artifacts) {
sort($artifacts);
}
ksort($existing_data['artifacts']);
// Update totals
$existing_data['summary']['total_artifacts'] = count($existing_data['artifacts']);
$existing_data['summary']['total_license_types'] = count($existing_data['summary']['license_types']);
$existing_data['summary']['last_updated'] = date('Y-m-d H:i:s');
$existing_data['summary']['total-artifacts'] = count($existing_data['artifacts']);
$existing_data['summary']['total-license-types'] = count($existing_data['summary']['license-types']);
$existing_data['summary']['last-updated'] = date('Y-m-d H:i:s');
// Write JSON file
file_put_contents(
@ -265,6 +265,6 @@ class LicenseDumper
json_encode($existing_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)
);
logger()->info('Generated LICENSE-SUMMARY.json with ' . $existing_data['summary']['total_artifacts'] . ' artifact(s)');
logger()->info('Generated SUMMARY.json with ' . $existing_data['summary']['total-artifacts'] . ' artifact(s)');
}
}