Changeset View
Changeset View
Standalone View
Standalone View
support/ArcanistRuntime.php
<?php | <?php | ||||
final class ArcanistRuntime { | final class ArcanistRuntime { | ||||
public function execute(array $argv) { | public function execute(array $argv) { | ||||
$err = $this->checkEnvironment(); | $err = $this->checkEnvironment(); | ||||
if ($err) { | if ($err) { | ||||
return $err; | return $err; | ||||
} | } | ||||
$err = $this->includeCoreLibraries(); | |||||
if ($err) { | |||||
return $err; | |||||
} | |||||
PhutilTranslator::getInstance() | PhutilTranslator::getInstance() | ||||
->setLocale(PhutilLocale::loadLocale('en_US')) | ->setLocale(PhutilLocale::loadLocale('en_US')) | ||||
->setTranslations(PhutilTranslation::getTranslationMapForLocale('en_US')); | ->setTranslations(PhutilTranslation::getTranslationMapForLocale('en_US')); | ||||
try { | try { | ||||
return $this->executeCore($argv); | return $this->executeCore($argv); | ||||
} catch (PhutilArgumentUsageException $ex) { | } catch (PhutilArgumentUsageException $ex) { | ||||
fwrite( | fwrite( | ||||
STDERR, | STDERR, | ||||
tsprintf( | tsprintf( | ||||
"**%s:** %s\n", | "**%s:** %s\n", | ||||
pht('Usage Exception'), | pht('Usage Exception'), | ||||
$ex->getMessage())); | $ex->getMessage())); | ||||
return 77; | return 77; | ||||
} | } | ||||
} | } | ||||
private function executeCore(array $argv) { | private function executeCore(array $argv) { | ||||
$config_args = array( | $config_args = array( | ||||
array( | array( | ||||
'name' => 'library', | 'name' => 'library', | ||||
▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | final class ArcanistRuntime { | ||||
private function fatalError($message) { | private function fatalError($message) { | ||||
echo "CONFIGURATION ERROR\n\n"; | echo "CONFIGURATION ERROR\n\n"; | ||||
echo $message; | echo $message; | ||||
echo "\n\n"; | echo "\n\n"; | ||||
return 1; | return 1; | ||||
} | } | ||||
private function includeCoreLibraries() { | |||||
// Adjust 'include_path' to add locations where we'll search for libphutil. | |||||
// We look in these places: | |||||
// | |||||
// - Next to 'arcanist/'. | |||||
// - Anywhere in the normal PHP 'include_path'. | |||||
// - Inside 'arcanist/externals/includes/'. | |||||
// | |||||
// When looking in these places, we expect to find a 'libphutil/' directory. | |||||
// The 'arcanist/' directory. | |||||
$arcanist_dir = dirname(dirname(__FILE__)); | |||||
// The parent directory of 'arcanist/'. | |||||
$parent_dir = dirname($arcanist_dir); | |||||
// The 'arcanist/externals/includes/' directory. | |||||
$include_dir = implode( | |||||
DIRECTORY_SEPARATOR, | |||||
array( | |||||
$arcanist_dir, | |||||
'externals', | |||||
'includes', | |||||
)); | |||||
$php_include_path = ini_get('include_path'); | |||||
$php_include_path = implode( | |||||
PATH_SEPARATOR, | |||||
array( | |||||
$parent_dir, | |||||
$php_include_path, | |||||
$include_dir, | |||||
)); | |||||
ini_set('include_path', $php_include_path); | |||||
return 0; | |||||
} | |||||
private function loadConfiguration(PhutilArgumentParser $args) { | private function loadConfiguration(PhutilArgumentParser $args) { | ||||
$configuration_manager = new ArcanistConfigurationManager(); | $configuration_manager = new ArcanistConfigurationManager(); | ||||
$cwd = getcwd(); | $cwd = getcwd(); | ||||
$working_copy = ArcanistWorkingCopyIdentity::newFromPath($cwd); | $working_copy = ArcanistWorkingCopyIdentity::newFromPath($cwd); | ||||
$configuration_manager->setWorkingCopyIdentity($working_copy); | $configuration_manager->setWorkingCopyIdentity($working_copy); | ||||
$configuration_manager->applyRuntimeArcConfig($args); | $configuration_manager->applyRuntimeArcConfig($args); | ||||
▲ Show 20 Lines • Show All 317 Lines • Show Last 20 Lines |