From: epriestley Date: Fri, 1 Jul 2011 02:20:41 +0000 (-0700) Subject: Improve library resolution chain for 'arc' X-Git-Tag: conduit-4~293 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=5ebfa50db363c35f64df0fac64270199f5aa75c3;p=arcanist.git 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 --- diff --git a/scripts/arcanist.php b/scripts/arcanist.php index 1b190c1d..47284178 100755 --- a/scripts/arcanist.php +++ b/scripts/arcanist.php @@ -81,15 +81,47 @@ try { } if ($libs) { 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( $location, $working_copy->getProjectRoot()); if (Filesystem::pathExists($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 { phutil_load_library($location); } catch (PhutilBootloaderException $ex) {