|
1 | 1 | #!/usr/bin/env php
|
2 | 2 | <?php
|
3 | 3 |
|
| 4 | +$package_spec = array( |
| 5 | + 'core.pkg.css' => array( |
| 6 | + 'phabricator-core-css', |
| 7 | + 'phabricator-core-buttons-css', |
| 8 | + 'phabricator-standard-page-view', |
| 9 | + 'aphront-dialog-view-css', |
| 10 | + 'aphront-form-view-css', |
| 11 | + 'aphront-panel-view-css', |
| 12 | + 'aphront-side-nav-view-css', |
| 13 | + 'aphront-table-view-css', |
| 14 | + 'aphront-tokenizer-control-css', |
| 15 | + 'aphront-typeahead-control-css', |
| 16 | + |
| 17 | + 'phabricator-directory-css', |
| 18 | + ), |
| 19 | + 'differential.pkg.css' => array( |
| 20 | + 'differential-core-view-css', |
| 21 | + 'differential-changeset-view-css', |
| 22 | + 'differential-revision-detail-css', |
| 23 | + 'differential-revision-history-css', |
| 24 | + 'differential-table-of-contents-css', |
| 25 | + ), |
| 26 | +); |
| 27 | + |
| 28 | + |
4 | 29 | require_once dirname(__FILE__).'/__init_script__.php';
|
5 | 30 |
|
6 | 31 | if ($argc != 2) {
|
|
39 | 64 |
|
40 | 65 | $runtime_map = array();
|
41 | 66 |
|
| 67 | +$hash_map = array(); |
| 68 | + |
42 | 69 | $parser = new PhutilDocblockParser();
|
43 | 70 | foreach ($file_map as $path => $info) {
|
44 | 71 | $data = Filesystem::readFile($info['disk']);
|
|
69 | 96 | $type = 'css';
|
70 | 97 | }
|
71 | 98 |
|
72 |
| - $path = '/res/'.substr($info['hash'], 0, 8).$path; |
| 99 | + $uri = '/res/'.substr($info['hash'], 0, 8).$path; |
| 100 | + |
| 101 | + $hash_map[$provides] = $info['hash']; |
73 | 102 |
|
74 | 103 | $runtime_map[$provides] = array(
|
75 |
| - 'path' => $path, |
| 104 | + 'uri' => $uri, |
76 | 105 | 'type' => $type,
|
77 | 106 | 'requires' => $requires,
|
| 107 | + 'disk' => $path, |
| 108 | + ); |
| 109 | +} |
| 110 | + |
| 111 | +$package_map = array(); |
| 112 | +foreach ($package_spec as $name => $package) { |
| 113 | + $hashes = array(); |
| 114 | + foreach ($package as $symbol) { |
| 115 | + if (empty($hash_map[$symbol])) { |
| 116 | + throw new Exception( |
| 117 | + "Package specification for '{$name}' includes '{$symbol}', but that ". |
| 118 | + "symbol is not defined anywhere."); |
| 119 | + } |
| 120 | + $hashes[] = $symbol.':'.$hash_map[$symbol]; |
| 121 | + } |
| 122 | + $key = substr(md5(implode("\n", $hashes)), 0, 8); |
| 123 | + $package_map['packages'][$key] = array( |
| 124 | + 'name' => $name, |
| 125 | + 'symbols' => $package, |
| 126 | + 'uri' => '/res/pkg/'.$key.'/'.$name, |
| 127 | + 'type' => 'css', // TODO LOL |
78 | 128 | );
|
| 129 | + foreach ($package as $symbol) { |
| 130 | + $package_map['reverse'][$symbol] = $key; |
| 131 | + } |
79 | 132 | }
|
| 133 | + |
80 | 134 |
|
81 | 135 | $runtime_map = var_export($runtime_map, true);
|
82 | 136 | $runtime_map = preg_replace('/\s+$/m', '', $runtime_map);
|
83 | 137 | $runtime_map = preg_replace('/array \(/', 'array(', $runtime_map);
|
84 | 138 |
|
| 139 | +$package_map = var_export($package_map, true); |
| 140 | +$pacakge_map = preg_replace('/\s+$/m', '', $package_map); |
| 141 | +$package_map = preg_replace('/array \(/', 'array(', $package_map); |
| 142 | + |
85 | 143 | $resource_map = <<<EOFILE
|
86 | 144 | <?php
|
87 | 145 |
|
|
91 | 149 | * @generated
|
92 | 150 | */
|
93 | 151 |
|
94 |
| -celerity_register_resource_map({$runtime_map}); |
| 152 | +celerity_register_resource_map({$runtime_map}, {$pacakge_map}); |
95 | 153 |
|
96 | 154 | EOFILE;
|
97 | 155 |
|
|
0 commit comments