forked from datastax/php-driver
-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathgenerate-presets.php
97 lines (82 loc) · 2.58 KB
/
generate-presets.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
declare(strict_types=1);
enum BuildType: string
{
case Debug = 'Debug';
case Release = 'Release';
case ReleaseWithDebugInfo = 'RelWithDebugInfo';
}
enum PHPVersion: string
{
case PHP81 = '8.1';
case PHP82 = '8.2';
case PHP83 = '8.3';
case PHP84 = '8.4';
}
enum PHPTS: string
{
case ZTS = 'zts';
case NTS = 'nts';
}
function preset(
string $name,
bool $useCassandra = true,
BuildType $buildType = BuildType::Debug,
PHPVersion $phpVersion = PHPVersion::PHP84,
PHPTS $phpTS = PHPTS::NTS,
): array {
$fullName = $name . 'PHP' . $phpVersion->value . strtoupper($phpTS->value) . ($useCassandra ? 'Cassandra' : '');
return [
"name" => $fullName,
"displayName" => $fullName,
"description" => "",
"generator" => "Ninja",
"binaryDir" => './out/' . $fullName,
"cacheVariables" => [
"CMAKE_BUILD_TYPE" => "Debug",
"CMAKE_INSTALL_PREFIX" => './out/' . $fullName . '/install',
"ENABLE_SANITIZERS" => $buildType === BuildType::Debug ? 'ON' : 'OFF',
'SANITIZE_UNDEFINED' => $buildType === BuildType::Debug ? 'ON' : 'OFF',
'SANITIZE_ADDRESS' => $buildType === BuildType::Debug ? 'ON' : 'OFF',
'USE_LIBCASSANDRA' => $useCassandra ? 'ON' : 'OFF',
'PHP_VERSION_FOR_PHP_CONFIG' => $phpVersion->value,
'LINK_LIBUV_STATIC' => 'ON',
'PHP_DRIVER_STATIC' => 'ON',
'PHP_THREAD_SAFE' => $phpTS === PHPTS::ZTS ? 'ON' : 'OFF',
],
];
}
function main()
{
$presetNames = ['Debug', 'Release', 'RelWithDebugInfo'];
$useCassandra = [true, false];
$buildTypes = BuildType::cases();
$phpVersions = PHPVersion::cases();
$phpTS = PHPTS::cases();
$presets = [];
foreach ($presetNames as $presetName) {
foreach ($useCassandra as $useCassandraValue) {
foreach ($buildTypes as $buildType) {
foreach ($phpVersions as $phpVersion) {
foreach ($phpTS as $ts) {
$presets[] = preset($presetName, $useCassandraValue, $buildType, $phpVersion, $ts);
}
}
}
}
}
$cmakePresets = [
'version' => 2,
"configurePresets" => $presets,
];
$result = @file_put_contents(
__DIR__ . DIRECTORY_SEPARATOR . 'CMakePresets.json',
json_encode($cmakePresets, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES),
LOCK_EX,
);
if ($result === false) {
echo 'Failed to write CMakePresets.json';
exit(1);
}
}
main();