-
Notifications
You must be signed in to change notification settings - Fork 1
/
deps.php
110 lines (97 loc) · 3.9 KB
/
deps.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
<?php
/* https://www.if-not-true-then-false.com/2010/php-class-for-coloring-php-command-line-cli-scripts-output-php-output-colorizing-using-bash-shell-colors */
class Colors {
private $foreground_colors = array();
private $background_colors = array();
public function __construct() {
// Set up shell colors
$this->foreground_colors['black'] = '0;30';
$this->foreground_colors['dark_gray'] = '1;30';
$this->foreground_colors['blue'] = '0;34';
$this->foreground_colors['light_blue'] = '1;34';
$this->foreground_colors['green'] = '0;32';
$this->foreground_colors['light_green'] = '1;32';
$this->foreground_colors['cyan'] = '0;36';
$this->foreground_colors['light_cyan'] = '1;36';
$this->foreground_colors['red'] = '0;31';
$this->foreground_colors['light_red'] = '1;31';
$this->foreground_colors['purple'] = '0;35';
$this->foreground_colors['light_purple'] = '1;35';
$this->foreground_colors['brown'] = '0;33';
$this->foreground_colors['yellow'] = '1;33';
$this->foreground_colors['light_gray'] = '0;37';
$this->foreground_colors['white'] = '1;37';
$this->background_colors['black'] = '40';
$this->background_colors['red'] = '41';
$this->background_colors['green'] = '42';
$this->background_colors['yellow'] = '43';
$this->background_colors['blue'] = '44';
$this->background_colors['magenta'] = '45';
$this->background_colors['cyan'] = '46';
$this->background_colors['light_gray'] = '47';
}
// Returns colored string
public function getColoredString($string, $foreground_color = null, $background_color = null) {
$colored_string = "";
// Check if given foreground color found
if (isset($this->foreground_colors[$foreground_color])) {
$colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m";
}
// Check if given background color found
if (isset($this->background_colors[$background_color])) {
$colored_string .= "\033[" . $this->background_colors[$background_color] . "m";
}
// Add string and end coloring
$colored_string .= $string . "\033[0m";
return $colored_string;
}
// Returns all foreground color names
public function getForegroundColors() {
return array_keys($this->foreground_colors);
}
// Returns all background color names
public function getBackgroundColors() {
return array_keys($this->background_colors);
}
}
$colors = new Colors();
$toolchain = "/home/striker/android/cm10/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin/arm-linux-androideabi-";
$vendor_dir = "/home/striker/android/cm10/device/samsung/delos3geur/system/lib";
$out_dir = "/home/striker/android/cm10/out/target/product/delos3geur/system/lib";
$ven = array();
$bld = array();
$unk = array();
function scandeps($path, $rev = false) {
global $ven, $bld, $unk, $toolchain, $vendor_dir, $out_dir;
$dir = scandir($path);
foreach($dir as $file) {
if($file == "." || $file == "..") continue;
//print $file."\n";
if(is_dir($path."/".$file) && $rev) {
//print"Going to $file\n";
scandeps($path."/".$file);
}
elseif(is_file($path."/".$file) && substr($file, -3) == ".so") {
$out = array();
//print "Checking $path/$file\n";
exec($toolchain."readelf -a ".$path."/".$file." | grep \"Shared library:\"", $out, $ret);
foreach($out as $line) {
preg_match('~Shared library: \[(.*?)\]~s', $line, $m);
$filename = $m[1];
if(file_exists($vendor_dir."/".$filename)) $ven[] = $filename;
elseif(file_exists($out_dir."/".$filename)) $bld[] = $filename;
else $unk[] = $filename;
}
}
}
}
scandeps($vendor_dir, true);
natsort($ven);
natsort($bld);
natsort($unk);
echo"\nExisting dependencies: \n";
foreach(array_unique($ven) as $f) { echo $colors->getColoredString($f."\n", "green"); }
echo"Existing in build, may be incosistent: \n";
foreach(array_unique($bld) as $f) { echo $colors->getColoredString($f."\n", "light_purple"); }
echo"Missing dependencies: \n";
foreach(array_unique($unk) as $f) { echo $colors->getColoredString($f."\n", "red"); }