2012-05-27 21:57:27 +02:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once dirname(__FILE__).'/__init_script__.php';
|
2012-06-14 21:02:27 +02:00
|
|
|
require_once dirname(__FILE__).'/lib/PhutilLibraryMapBuilder.php';
|
2012-05-27 21:57:27 +02:00
|
|
|
|
|
|
|
$args = new PhutilArgumentParser($argv);
|
|
|
|
$args->setTagline('rebuild the library map file');
|
|
|
|
$args->setSynopsis(<<<EOHELP
|
|
|
|
**phutil_rebuild_map.php** [__options__] __root__
|
|
|
|
Rebuild the library map file for a libphutil library.
|
|
|
|
|
|
|
|
EOHELP
|
|
|
|
);
|
|
|
|
|
|
|
|
$args->parseStandardArguments();
|
|
|
|
$args->parse(
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'name' => 'quiet',
|
|
|
|
'help' => 'Do not write status messages to stderr.',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'name' => 'drop-cache',
|
|
|
|
'help' => 'Drop the symbol cache and rebuild the entire map from '.
|
|
|
|
'scratch.',
|
|
|
|
),
|
Export extends/implements information in the new libphutil library map
Summary:
For `PhutilSymbolLoader` queries which include `setAncestorClass()`, we need the map of which classes/interfaces things extend/implement to issue the query efficiently.
Without this map, we need to load //every// class/interface and then do `is_subclass_of()`. This is doable, but not very performant if we don't have php-fpm warmup. There are a few performance-sensitive interfaces where we run queries like this, including some in Arcanist, where we'll never have warmup.
This map isn't particularly difficult to generate or maintain, so just include it in symbol generation and in the library map.
Also set parallelism with a flag, since it was arbitrarily hard-coded and adding flags is easy. 8 actually seems approximately optimal on my machine at least, though.
Test Plan: Ran "phutil_rebuild_map.php", opened library map, got a reasonable extension map.
Reviewers: vrana, btrahan
Reviewed By: vrana
CC: aran
Maniphest Tasks: T1103
Differential Revision: https://secure.phabricator.com/D2585
2012-05-29 20:17:34 +02:00
|
|
|
array(
|
|
|
|
'name' => 'limit',
|
|
|
|
'param' => 'N',
|
|
|
|
'default' => 8,
|
|
|
|
'help' => 'Controls the number of symbol mapper subprocesses run '.
|
|
|
|
'at once. Defaults to 8.',
|
|
|
|
),
|
2012-05-30 16:25:09 +02:00
|
|
|
array(
|
|
|
|
'name' => 'show',
|
|
|
|
'help' => 'Print symbol map to stdout instead of writing it to the '.
|
|
|
|
'map file.',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'name' => 'ugly',
|
|
|
|
'help' => 'Use faster but less readable serialization for --show.',
|
|
|
|
),
|
2012-05-27 21:57:27 +02:00
|
|
|
array(
|
|
|
|
'name' => 'root',
|
|
|
|
'wildcard' => true,
|
|
|
|
)
|
|
|
|
));
|
|
|
|
|
|
|
|
$root = $args->getArg('root');
|
|
|
|
if (count($root) !== 1) {
|
|
|
|
throw new Exception("Provide exactly one library root!");
|
|
|
|
}
|
|
|
|
$root = Filesystem::resolvePath(head($root));
|
|
|
|
|
|
|
|
$builder = new PhutilLibraryMapBuilder($root);
|
|
|
|
|
|
|
|
$builder->setQuiet($args->getArg('quiet'));
|
Export extends/implements information in the new libphutil library map
Summary:
For `PhutilSymbolLoader` queries which include `setAncestorClass()`, we need the map of which classes/interfaces things extend/implement to issue the query efficiently.
Without this map, we need to load //every// class/interface and then do `is_subclass_of()`. This is doable, but not very performant if we don't have php-fpm warmup. There are a few performance-sensitive interfaces where we run queries like this, including some in Arcanist, where we'll never have warmup.
This map isn't particularly difficult to generate or maintain, so just include it in symbol generation and in the library map.
Also set parallelism with a flag, since it was arbitrarily hard-coded and adding flags is easy. 8 actually seems approximately optimal on my machine at least, though.
Test Plan: Ran "phutil_rebuild_map.php", opened library map, got a reasonable extension map.
Reviewers: vrana, btrahan
Reviewed By: vrana
CC: aran
Maniphest Tasks: T1103
Differential Revision: https://secure.phabricator.com/D2585
2012-05-29 20:17:34 +02:00
|
|
|
$builder->setSubprocessLimit($args->getArg('limit'));
|
2012-05-27 21:57:27 +02:00
|
|
|
|
|
|
|
if ($args->getArg('drop-cache')) {
|
|
|
|
$builder->dropSymbolCache();
|
|
|
|
}
|
|
|
|
|
2012-05-30 16:25:09 +02:00
|
|
|
if ($args->getArg('show')) {
|
|
|
|
$builder->setShowMap(true);
|
|
|
|
$builder->setUgly($args->getArg('ugly'));
|
|
|
|
}
|
|
|
|
|
2012-05-27 21:57:27 +02:00
|
|
|
$builder->buildMap();
|
|
|
|
|
|
|
|
exit(0);
|