|
6 | 6 |
|
7 | 7 | use SPC\builder\BuilderProvider; |
8 | 8 | use SPC\exception\ExceptionHandler; |
| 9 | +use SPC\exception\RuntimeException; |
9 | 10 | use SPC\exception\WrongUsageException; |
10 | 11 | use SPC\store\Config; |
11 | 12 | use SPC\store\FileSystem; |
@@ -158,14 +159,24 @@ public function handle(): int |
158 | 159 | if ($this->input->getOption('with-upx-pack') && in_array(PHP_OS_FAMILY, ['Linux', 'Windows'])) { |
159 | 160 | $indent_texts['UPX Pack'] = 'enabled'; |
160 | 161 | } |
| 162 | + |
161 | 163 | try { |
162 | | - $ver = $builder->getPHPVersion(); |
163 | | - $indent_texts['PHP Version'] = $ver; |
164 | | - } catch (\Throwable) { |
165 | | - if (($ver = $builder->getPHPVersionFromArchive()) !== false) { |
166 | | - $indent_texts['PHP Version'] = $ver; |
| 164 | + $cleanPhpSrc = $builder->getPHPVersion() !== $builder->getPHPVersionFromArchive(); |
| 165 | + } catch (RuntimeException|WrongUsageException) { |
| 166 | + $cleanPhpSrc = true; |
| 167 | + } |
| 168 | + if ($cleanPhpSrc) { |
| 169 | + logger()->info('Cleaning previous php build due to mismatching versions...'); |
| 170 | + FileSystem::removeDir(SOURCE_PATH . '/php-src'); |
| 171 | + FileSystem::removeDir(BUILD_MODULES_PATH); |
| 172 | + $binFiles = glob(BUILD_BIN_PATH . '/php*'); |
| 173 | + $libFiles = glob(BUILD_LIB_PATH . '/libphp*'); |
| 174 | + foreach ([...$binFiles, ...$libFiles] as $file) { |
| 175 | + unlink($file); |
167 | 176 | } |
168 | 177 | } |
| 178 | + $ver = $builder->getPHPVersionFromArchive() ?: $builder->getPHPVersion(); |
| 179 | + $indent_texts['PHP Version'] = $ver; |
169 | 180 |
|
170 | 181 | if (!empty($not_included)) { |
171 | 182 | $indent_texts['Extra Exts (' . count($not_included) . ')'] = implode(', ', $not_included); |
|
0 commit comments