This repository was archived by the owner on Jan 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathphpsdk_dllmap.php
117 lines (89 loc) · 1.89 KB
/
phpsdk_dllmap.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/*
- go through all zip files in the given dirs non recursively
- read all the dll filenames from those zips
- create mappings between dll filename and zip filename
Usage:
php dllmap.php [--pretty] path0 [ path1 ... ] > dllmapping.json
*/
/*$dirs = array(
"C:\\tmp\\core_deps\\vc9\\x86",
"C:\\tmp\\core_deps\\vc11\\x86",
"C:\\tmp\\core_deps\\vc11\\x64",
);*/
/*$dirs = array(
"C:\\tmp\\libs",
);*/
$sopt = "p";
$lopt = array(
"pretty",
);
$flags = 0;
$opt = getopt($sopt, $lopt);
foreach ($opt as $name => $val) {
switch ($name) {
case "p":
case "pretty":
$flags = JSON_PRETTY_PRINT;
break;
}
}
$dirs = array();
foreach (array_slice($_SERVER["argv"], (0 == $flags ? 1 : 2)) as $item) {
if (file_exists($item) && is_dir($item)) {
$dirs[] = $item;
}
}
if (empty($dirs)) {
echo "Nothing to do\n";
die;
}
$out = array();
foreach ($dirs as $path) {
$dir = new DirectoryIterator($path);
foreach ($dir as $fileinfo) {
if ($fileinfo->isDot() || $fileinfo->isDir()) {
continue;
}
$pathname = $fileinfo->getPathname();
$filename = $fileinfo->getFilename();
if (substr($filename, -3) != "zip") {
continue;
}
if (!preg_match(",.*-(vc\d+)-(x\d\d)\.zip,", $filename, $m)) {
continue;
}
$crt = $m[1];
$arch = $m[2];
if (!isset($out[$crt])) {
$out[$crt] = array();
}
if (!isset($out[$crt][$arch])) {
$out[$crt][$arch] = array();
}
$zip = new ZipArchive();
$zip->open($pathname);
$dlls = array();
for ($i = 0; $i < $zip->numFiles; $i++) {
$stat = $zip->statIndex($i);
if (substr($stat['name'], -3) != "dll") {
continue;
}
$dlls[] = basename($stat['name']);
}
$zip->close();
unset($zip);
if (!empty($dlls)) {
$out[$crt][$arch][$filename] = $dlls;
}
}
}
echo json_encode($out, $flags);
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/