| 1 | #! /usr/bin/env php |
|---|
| 2 | <?php |
|---|
| 3 | |
|---|
| 4 | require_once(dirname($argv[0]) . "/utilities.php"); |
|---|
| 5 | |
|---|
| 6 | if (read_bool("Rebuild dep-check.db?", false)) { |
|---|
| 7 | system(IA_ROOT_DIR . "scripts/dep-rebuild"); |
|---|
| 8 | } |
|---|
| 9 | |
|---|
| 10 | // read dependencies db |
|---|
| 11 | $exports = array(); |
|---|
| 12 | $dep_buffer = file_get_contents(IA_ROOT_DIR."scripts/dep-check.db"); |
|---|
| 13 | foreach (preg_split("/[\n\r]+/", $dep_buffer, -1, PREG_SPLIT_NO_EMPTY) as $line) { |
|---|
| 14 | if (!($line = trim($line))) { |
|---|
| 15 | continue; |
|---|
| 16 | } |
|---|
| 17 | |
|---|
| 18 | list($ident, $fname) = split("\t", $line); |
|---|
| 19 | |
|---|
| 20 | if (!isset($exports[$fname])) { |
|---|
| 21 | $exports[$fname] = array(); |
|---|
| 22 | } |
|---|
| 23 | |
|---|
| 24 | $exports[$fname][] = $ident; |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | //log_print_r($exports); |
|---|
| 28 | |
|---|
| 29 | // some modules are bound to be included anywhere so we skip them for checking |
|---|
| 30 | unset($exports['config.php']); |
|---|
| 31 | unset($exports['common/common.php']); |
|---|
| 32 | unset($exports['common/log.php']); |
|---|
| 33 | unset($exports['common/security.php']); |
|---|
| 34 | unset($exports['www/config.php']); |
|---|
| 35 | unset($exports['www/utilities.php']); |
|---|
| 36 | unset($exports['www/url.php']); |
|---|
| 37 | unset($exports['www/index.php']); |
|---|
| 38 | unset($exports['www/identity.php']); |
|---|
| 39 | unset($exports['www/views/utilities.php']); |
|---|
| 40 | unset($exports['eval/utilities.php']); |
|---|
| 41 | unset($exports['eval/config.php']); |
|---|
| 42 | unset($exports['scripts/utilities.php']); |
|---|
| 43 | |
|---|
| 44 | // some hacks |
|---|
| 45 | $exports['common/db/db.php'] = $exports['common/db/db.php'] |
|---|
| 46 | + $exports['common/db/db_mysql.php']; |
|---|
| 47 | unset($exports['common/db/db_mysql.php']); |
|---|
| 48 | |
|---|
| 49 | // grep for all identifiers |
|---|
| 50 | // this will take forever |
|---|
| 51 | foreach ($exports as $module => $idents) { |
|---|
| 52 | // log_print_r("Processing $module"); |
|---|
| 53 | foreach ($idents as $ident) { |
|---|
| 54 | // do grep |
|---|
| 55 | $fd = popen(IA_ROOT_DIR."scripts/_dcgrep {$ident} {$module} ".IA_ROOT_DIR, "r"); |
|---|
| 56 | log_assert($fd); |
|---|
| 57 | $buffer = fread($fd, 500*1024); |
|---|
| 58 | pclose($fd); |
|---|
| 59 | |
|---|
| 60 | // print |
|---|
| 61 | if ($buffer) { |
|---|
| 62 | log_print("(possible) error calling {$ident} ({$module}) from these files:\n" |
|---|
| 63 | .$buffer); |
|---|
| 64 | } |
|---|
| 65 | } |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | ?> |
|---|