Changeset View
Changeset View
Standalone View
Standalone View
src/moduleutils/PhutilLibraryMapBuilder.php
| Show First 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | |||||
| /* -( Symbol Analysis and Caching )---------------------------------------- */ | /* -( Symbol Analysis and Caching )---------------------------------------- */ | ||||
| /** | /** | ||||
| * Load the library symbol cache, if it exists and is readable and valid. | * Load the library symbol cache, if it exists and is readable and valid. | ||||
| * | * | ||||
| * @return dict Map of content hashes to cache of output from | * @return dict Map of content hashes to cache of output from | ||||
| * `phutil_symbols.php`. | * `extract-symbols.php`. | ||||
| * | * | ||||
| * @task symbol | * @task symbol | ||||
| */ | */ | ||||
| private function loadSymbolCache() { | private function loadSymbolCache() { | ||||
| $cache_file = $this->getPathForSymbolCache(); | $cache_file = $this->getPathForSymbolCache(); | ||||
| try { | try { | ||||
| $cache = Filesystem::readFile($cache_file); | $cache = Filesystem::readFile($cache_file); | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | /* -( Symbol Analysis and Caching )---------------------------------------- */ | ||||
| * @task symbol | * @task symbol | ||||
| */ | */ | ||||
| public function dropSymbolCache() { | public function dropSymbolCache() { | ||||
| $this->log(pht('Dropping symbol cache...')); | $this->log(pht('Dropping symbol cache...')); | ||||
| Filesystem::remove($this->getPathForSymbolCache()); | Filesystem::remove($this->getPathForSymbolCache()); | ||||
| } | } | ||||
| /** | /** | ||||
| * Build a future which returns a `phutil_symbols.php` analysis of a source | * Build a future which returns a `extract-symbols.php` analysis of a source | ||||
| * file. | * file. | ||||
| * | * | ||||
| * @param string Relative path to the source file to analyze. | * @param string Relative path to the source file to analyze. | ||||
| * @return Future Analysis future. | * @return Future Analysis future. | ||||
| * | * | ||||
| * @task symbol | * @task symbol | ||||
| */ | */ | ||||
| private function buildSymbolAnalysisFuture($file) { | private function buildSymbolAnalysisFuture($file) { | ||||
| ▲ Show 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | $this->log( | ||||
| pht('Found %s files.', new PhutilNumber(count($source_map)))); | pht('Found %s files.', new PhutilNumber(count($source_map)))); | ||||
| // Load the symbol cache with existing parsed symbols. This allows us | // Load the symbol cache with existing parsed symbols. This allows us | ||||
| // to remap libraries quickly by analyzing only changed files. | // to remap libraries quickly by analyzing only changed files. | ||||
| $this->log(pht('Loading symbol cache...')); | $this->log(pht('Loading symbol cache...')); | ||||
| $symbol_cache = $this->loadSymbolCache(); | $symbol_cache = $this->loadSymbolCache(); | ||||
| // If the XHPAST binary is not up-to-date, build it now. Otherwise, | // If the XHPAST binary is not up-to-date, build it now. Otherwise, | ||||
| // `phutil_symbols.php` will attempt to build the binary and will fail | // `extract-symbols.php` will attempt to build the binary and will fail | ||||
| // miserably because it will be trying to build the same file multiple | // miserably because it will be trying to build the same file multiple | ||||
| // times in parallel. | // times in parallel. | ||||
| if (!PhutilXHPASTBinary::isAvailable()) { | if (!PhutilXHPASTBinary::isAvailable()) { | ||||
| PhutilXHPASTBinary::build(); | PhutilXHPASTBinary::build(); | ||||
| } | } | ||||
| // Build out the symbol analysis for all the files in the library. For | // Build out the symbol analysis for all the files in the library. For | ||||
| // each file, check if it's in cache. If we miss in the cache, do a fresh | // each file, check if it's in cache. If we miss in the cache, do a fresh | ||||
| ▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines | |||||