Page MenuHomePhabricator

D19690.id47066.diff
No OneTemporary

D19690.id47066.diff

diff --git a/resources/php_compat_info.json b/resources/php/php_compat_info.json
rename from resources/php_compat_info.json
rename to resources/php/php_compat_info.json
diff --git a/scripts/phutil_rebuild_map.php b/scripts/library/library-map.php
rename from scripts/phutil_rebuild_map.php
rename to scripts/library/library-map.php
--- a/scripts/phutil_rebuild_map.php
+++ b/scripts/library/library-map.php
@@ -1,7 +1,7 @@
#!/usr/bin/env php
<?php
-require_once dirname(__FILE__).'/__init_script__.php';
+require_once dirname(dirname(__FILE__)).'/init/init-script.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('rebuild the library map file'));
diff --git a/scripts/phutil_symbols.php b/scripts/library/library-symbols.php
rename from scripts/phutil_symbols.php
rename to scripts/library/library-symbols.php
--- a/scripts/phutil_symbols.php
+++ b/scripts/library/library-symbols.php
@@ -5,12 +5,12 @@
// built-in symbol list through introspection.
$builtins = phutil_symbols_get_builtins();
-require_once dirname(__FILE__).'/__init_script__.php';
+require_once dirname(dirname(__FILE__)).'/init/init-script.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('identify symbols in a PHP source file'));
$args->setSynopsis(<<<EOHELP
- **phutil_symbols.php** [__options__] __path.php__
+ **library-symbols.php** [__options__] __path.php__
Identify the symbols (clases, functions and interfaces) in a PHP
source file. Symbols are divided into "have" symbols (symbols the file
declares) and "need" symbols (symbols the file depends on). For example,
@@ -524,7 +524,7 @@
$compat = json_decode(
file_get_contents(
- dirname(__FILE__).'/../resources/php_compat_info.json'),
+ dirname(dirname(__FILE__)).'/../resources/php/php_compat_info.json'),
true);
foreach (array('functions', 'classes', 'interfaces') as $type) {
diff --git a/src/moduleutils/PhutilLibraryMapBuilder.php b/src/moduleutils/PhutilLibraryMapBuilder.php
--- a/src/moduleutils/PhutilLibraryMapBuilder.php
+++ b/src/moduleutils/PhutilLibraryMapBuilder.php
@@ -183,7 +183,7 @@
* Load the library symbol cache, if it exists and is readable and valid.
*
* @return dict Map of content hashes to cache of output from
- * `phutil_symbols.php`.
+ * `library-symbols.php`.
*
* @task symbol
*/
@@ -256,7 +256,7 @@
}
/**
- * Build a future which returns a `phutil_symbols.php` analysis of a source
+ * Build a future which returns a `library-symbols.php` analysis of a source
* file.
*
* @param string Relative path to the source file to analyze.
@@ -266,9 +266,11 @@
*/
private function buildSymbolAnalysisFuture($file) {
$absolute_file = $this->getPath($file);
- $bin = dirname(__FILE__).'/../../scripts/phutil_symbols.php';
- return new ExecFuture('php %s --ugly -- %s', $bin, $absolute_file);
+ $root = dirname(dirname(dirname(__FILE__)));
+ $bin = $root.'/scripts/library/library-symbols.php';
+
+ return new ExecFuture('php %R --ugly -- %R', $bin, $absolute_file);
}
@@ -439,7 +441,7 @@
$symbol_cache = $this->loadSymbolCache();
// 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
+ // `library-symbols.php` will attempt to build the binary and will fail
// miserably because it will be trying to build the same file multiple
// times in parallel.
if (!PhutilXHPASTBinary::isAvailable()) {
diff --git a/src/workflow/ArcanistLiberateWorkflow.php b/src/workflow/ArcanistLiberateWorkflow.php
--- a/src/workflow/ArcanistLiberateWorkflow.php
+++ b/src/workflow/ArcanistLiberateWorkflow.php
@@ -73,51 +73,50 @@
if (count($argv) > 1) {
throw new ArcanistUsageException(
pht(
- "Provide only one path to '%s'. The path should be a directory ".
- "where you want to create or update a libphutil library.",
- 'arc liberate'));
- } else if (count($argv) == 0) {
- $path = getcwd();
+ 'Provide only one path to "arc liberate". The path should identify '.
+ 'a directory where you want to create or update a library.'));
+ } else if (!$argv) {
+ $init_files = id(new FileFinder(getcwd()))
+ ->withPath('*/__phutil_library_init__.php')
+ ->find();
+
+ if (!$init_files) {
+ throw new ArcanistUsageException(
+ pht(
+ 'Unable to find any libraries under the current working '.
+ 'directory. To create a library, provide a path.'));
+ }
+
+ $paths = array();
+ foreach ($init_files as $init) {
+ $paths[] = Filesystem::resolvePath(dirname($init));
+ }
} else {
- $path = reset($argv);
+ $paths = array(
+ Filesystem::resolvePath(head($argv)),
+ );
}
$is_remap = $this->getArgument('remap');
$is_verify = $this->getArgument('verify');
- $path = Filesystem::resolvePath($path);
-
- if (Filesystem::pathExists($path) && is_dir($path)) {
- $init = id(new FileFinder($path))
- ->withPath('*/__phutil_library_init__.php')
- ->find();
- } else {
- $init = null;
+ foreach ($paths as $path) {
+ $this->liberatePath($path);
}
- if ($init) {
- if (count($init) > 1) {
- throw new ArcanistUsageException(
- pht(
- 'Specified directory contains more than one libphutil library. '.
- 'Use a more specific path.'));
- }
- $path = Filesystem::resolvePath(dirname(reset($init)), $path);
- } else {
- $found = false;
- foreach (Filesystem::walkToRoot($path) as $dir) {
- if (Filesystem::pathExists($dir.'/__phutil_library_init__.php')) {
- $path = $dir;
- $found = true;
- break;
- }
- }
- if (!$found) {
- echo pht("No library currently exists at that path...\n");
- $this->liberateCreateDirectory($path);
- $this->liberateCreateLibrary($path);
- return;
- }
+ return 0;
+ }
+
+ private function liberatePath($path) {
+ if (!Filesystem::pathExists($path.'/__phutil_library_init__.php')) {
+ echo tsprintf(
+ "%s\n",
+ pht(
+ 'No library currently exists at the path "%s"...',
+ $path));
+ $this->liberateCreateDirectory($path);
+ $this->liberateCreateLibrary($path);
+ return;
}
$version = $this->getLibraryFormatVersion($path);
@@ -161,7 +160,7 @@
}
private function liberateVersion2($path) {
- $bin = $this->getScriptPath('scripts/phutil_rebuild_map.php');
+ $bin = $this->getScriptPath('scripts/library/library-map.php');
return phutil_passthru(
'php %s %C %s',
@@ -244,7 +243,7 @@
private function getScriptPath($script) {
- $root = dirname(phutil_get_library_root('phutil'));
+ $root = dirname(phutil_get_library_root('arcanist'));
return $root.'/'.$script;
}

File Metadata

Mime Type
text/plain
Expires
Wed, Oct 16, 12:32 PM (3 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6713787
Default Alt Text
D19690.id47066.diff (6 KB)

Event Timeline