mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-07 16:55:38 +08:00
Add clang finder for Windows
This commit is contained in:
@@ -85,6 +85,44 @@ class WindowsUtil
|
|||||||
return intval($result);
|
return intval($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find Clang compiler from the Visual Studio LLVM toolchain.
|
||||||
|
*
|
||||||
|
* Checks the CC environment variable first (user override), then searches
|
||||||
|
* the VS2022/VS2019 installation via vswhere.
|
||||||
|
*
|
||||||
|
* @return array{clang: string, clangpp: string}|false False if not found
|
||||||
|
*/
|
||||||
|
public static function findClang(): array|false
|
||||||
|
{
|
||||||
|
// Allow user to override via CC environment variable
|
||||||
|
if ($cc = getenv('CC')) {
|
||||||
|
if (file_exists($cc)) {
|
||||||
|
$clangpp = dirname($cc) . DIRECTORY_SEPARATOR . 'clang++.exe';
|
||||||
|
return [
|
||||||
|
'clang' => $cc,
|
||||||
|
'clangpp' => file_exists($clangpp) ? $clangpp : $cc,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$vs = self::findVisualStudio();
|
||||||
|
if ($vs === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$clang = $vs['dir'] . '\VC\Tools\Llvm\x64\bin\clang.exe';
|
||||||
|
$clangpp = $vs['dir'] . '\VC\Tools\Llvm\x64\bin\clang++.exe';
|
||||||
|
if (!file_exists($clang)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'clang' => $clang,
|
||||||
|
'clangpp' => file_exists($clangpp) ? $clangpp : $clang,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create CMake toolchain file.
|
* Create CMake toolchain file.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user