diff --git a/src/Php/Constants.php b/src/Php/Constants.php index 4c2572be..5e60c78a 100644 --- a/src/Php/Constants.php +++ b/src/Php/Constants.php @@ -107,7 +107,7 @@ class Constants 'force' => [ 'prefix' => 'f', 'longPrefix' => 'force', - 'description' => 'Force compile even if cache exists', + 'description' => 'Force recompile phpx misc files (ignore cache)', 'required' => false, 'noValue' => true, ], diff --git a/src/Php/Preprocessor.php b/src/Php/Preprocessor.php index 164472ea..ea60e5d1 100644 --- a/src/Php/Preprocessor.php +++ b/src/Php/Preprocessor.php @@ -26,8 +26,6 @@ use PhpParser\NodeTraverser; class Preprocessor extends CompilerBase { - protected bool $enableCache = false; - public function sortFiles(array &$list): void { $sorter = new StringSort(); @@ -87,27 +85,8 @@ class Preprocessor extends CompilerBase return $info['dirname'] . $this->getPlatform()->getPathSeparator() . $info['filename'] . $ext; } - public function hasCppFileCache(string $file): bool - { - if (!$this->enableCache or $this->climate->arguments->defined('force')) { - return false; - } - $cppFile = $this->getCppFile($file); - if (file_exists($cppFile) and filemtime($cppFile) > filemtime($file)) { - return true; - } - - return false; - } - public function prepareFile(string $file): void { - if ($this->hasCppFileCache($file)) { - $this->climate->darkGray('skip: ' . $file . ', cache exists'); - - return; - } - $phpCode = $this->loadFile($file); $this->symbolCallInFile[$this->file] = []; $this->resetFile(); diff --git a/src/Php/Translator.php b/src/Php/Translator.php index 139264c0..2b73679a 100644 --- a/src/Php/Translator.php +++ b/src/Php/Translator.php @@ -119,7 +119,7 @@ class Translator extends Preprocessor $climate->tab()->out('-o, --output Output binary name (default: input basename)'); $climate->tab()->out('-v, --version Show version'); $climate->tab()->out('-h, --help Show this help message'); - $climate->tab()->out('-f, --force Force compile even if cache exists'); + $climate->tab()->out('-f, --force Force recompile phpx misc files (ignore cache)'); $climate->tab()->out('-m, --mode Compilation mode, -m bin(binary) or -m ext(extension), default: bin'); $climate->tab()->out('-r, --run Run the compiled binary after build'); $climate->tab()->out('-j, --job Number of parallel compilation jobs (default: 4)'); @@ -206,11 +206,6 @@ class Translator extends Preprocessor public function convertFile(string $file): string { $file = realpath($file); - if ($this->hasCppFileCache($file)) { - $this->climate->darkGray('skip: ' . $file . ', cache exists'); - - return $this->getCppFile($file); - } $phpCode = $this->loadFile($file); $this->localHeaders = []; while (true) { @@ -693,22 +688,8 @@ CODE; return self::MODULE_NAME_PREFIX . $this->targetName; } - public function hasObjectFileCache(string $cppFile): bool - { - if (!$this->enableCache or $this->climate->arguments->defined('force')) { - return false; - } - $objectFile = $this->getObjectFile($cppFile); - if (file_exists($objectFile) and filemtime($objectFile) > filemtime($cppFile)) { - return true; - } - - return false; - } - /** - * 检查 phpx/src/misc/ 下的源文件是否已有有效缓存。 - * 独立于 enableCache,始终生效(除非指定 --force)。 + * 检查 phpx/src/misc/ 下的源文件是否已有有效缓存,始终生效(除非指定 --force)。 * 仅检查 .o 文件是否比源文件和 phpx 头文件更新。 */ public function hasMiscObjectFileCache(string $cppFile): bool @@ -798,14 +779,6 @@ CODE; return; } - if ($this->hasObjectFileCache($cppFile)) { - if (!$parallel) { - $this->climate->darkGray('skip: ' . $cppFile . ', cache exists'); - } - - return; - } - // 检测文件语言类型 $language = $this->getLanguageFromExtension($cppFile);