Skip to content

Commit

Permalink
optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Aug 23, 2024
1 parent 5ea2822 commit 224225d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
28 changes: 0 additions & 28 deletions sapi/scripts/DownloadPHPSourceCode.php

This file was deleted.

29 changes: 29 additions & 0 deletions sapi/scripts/download-php-src-archive.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

$poject_dir = realpath(__DIR__ . '/../../');
$php_version_tag = trim(file_get_contents($poject_dir . '/sapi/PHP-VERSION.conf'));
$php_source_folder = $poject_dir . "/pool/php-src/php-{$php_version_tag}";
$php_archive_file = $poject_dir . "/pool/php-tar/php-{$php_version_tag}.tar.gz";
$download_dir = dirname($php_archive_file);

# 下载 PHP 源码
$download_cmd = "curl -L https://github.com/php/php-src/archive/refs/tags/php-{$php_version_tag}.tar.gz -o {$php_archive_file}";
echo $download_cmd . PHP_EOL;
if (!file_exists($php_archive_file)) {
`test -d {$download_dir} || mkdir -p {$download_dir}`;
`{$download_cmd}`;
}

# 若不存在则解压 PHP 源码包
# tar -zxvf 文件名.tar.gz --strip-components=1 -C 指定解压目录

$extract_tar_cmd = <<<EOF
set -x
# test -d {$php_source_folder} && rm -rf {$php_source_folder}
mkdir -p {$php_source_folder}
test -f {$php_source_folder}/configure.ac || tar -zxf {$php_archive_file} --strip-components=1 -C {$php_source_folder}
EOF;

`{$extract_tar_cmd}`;

return $php_source_folder;
3 changes: 1 addition & 2 deletions sync-source-code.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
declare(strict_types=1);

$project_dir = __DIR__;
require_once __DIR__ . '/sapi/scripts/DownloadPHPSourceCode.php';
$php_source_folder = PHP_SRC_DIR;
$php_source_folder = require_once __DIR__ . '/sapi/scripts/download-php-src-archive.php';
$sync_dest_dir = $project_dir . '/var/sync-source-code-tmp';

$scanned_directory_source = array_diff(scandir($php_source_folder . '/ext/'), array('..', '.'));
Expand Down

0 comments on commit 224225d

Please sign in to comment.