mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-25 16:22:42 +01:00
Improve library resolution chain for 'arc'
Summary: We currently look: - In the working copy - Alongside libphutil/ - In PHP include_path Before checking next to libphutil/, check next to the working copy. The problem right now is that javelin/ references diviner/, but it won't find it next to javelin/, only next to the libphutil/ instance which is loaded off /home/engshare/devtools. Test Plan: Moved javelin to tmp/javelin and diviner to tmp/divinerx. Ran 'arc list' and got a library load error. Moved 'divinerx' to 'diviner' and ran 'arc list'. It loaded correctly. Ran '--trace' to verify load location. Reviewed By: cpojer Reviewers: cpojer, jungejason CC: aran, cpojer Differential Revision: 568
This commit is contained in:
parent
8234dd8088
commit
5ebfa50db3
1 changed files with 35 additions and 3 deletions
|
@ -81,15 +81,47 @@ try {
|
||||||
}
|
}
|
||||||
if ($libs) {
|
if ($libs) {
|
||||||
foreach ($libs as $name => $location) {
|
foreach ($libs as $name => $location) {
|
||||||
if ($config_trace_mode) {
|
|
||||||
echo "Loading phutil library '{$name}' from '{$location}'...\n";
|
// Try to resolve the library location. We look in several places, in
|
||||||
}
|
// order:
|
||||||
|
//
|
||||||
|
// 1. Inside the working copy. This is for phutil libraries within the
|
||||||
|
// project. For instance "library/src" will resolve to
|
||||||
|
// "./library/src" if it exists.
|
||||||
|
// 2. In the same directory as the working copy. This allows you to
|
||||||
|
// check out a library alongside a working copy and reference it.
|
||||||
|
// If we haven't resolved yet, "library/src" will try to resolve to
|
||||||
|
// "../library/src" if it exists.
|
||||||
|
// 3. Using normal libphutil resolution rules. Generally, this means
|
||||||
|
// that it checks for libraries next to libphutil, then libraries
|
||||||
|
// in the PHP include_path.
|
||||||
|
|
||||||
|
$resolved = false;
|
||||||
|
|
||||||
|
// Check inside the working copy.
|
||||||
$resolved_location = Filesystem::resolvePath(
|
$resolved_location = Filesystem::resolvePath(
|
||||||
$location,
|
$location,
|
||||||
$working_copy->getProjectRoot());
|
$working_copy->getProjectRoot());
|
||||||
if (Filesystem::pathExists($resolved_location)) {
|
if (Filesystem::pathExists($resolved_location)) {
|
||||||
$location = $resolved_location;
|
$location = $resolved_location;
|
||||||
|
$resolved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we didn't find anything, check alongside the working copy.
|
||||||
|
if (!$resolved) {
|
||||||
|
$resolved_location = Filesystem::resolvePath(
|
||||||
|
$location,
|
||||||
|
dirname($working_copy->getProjectRoot()));
|
||||||
|
if (Filesystem::pathExists($resolved_location)) {
|
||||||
|
$location = $resolved_location;
|
||||||
|
$resolved = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($config_trace_mode) {
|
||||||
|
echo "Loading phutil library '{$name}' from '{$location}'...\n";
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
phutil_load_library($location);
|
phutil_load_library($location);
|
||||||
} catch (PhutilBootloaderException $ex) {
|
} catch (PhutilBootloaderException $ex) {
|
||||||
|
|
Loading…
Reference in a new issue