Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Commit

Permalink
Shell out to HHVM to execute the autoload generator
Browse files Browse the repository at this point in the history
This is required for nightlies and the next release, given that composer
(and the plugin) can not be executed with HHVM.
  • Loading branch information
fredemmott committed Jan 22, 2019
1 parent 4d66f5a commit 84a3ee1
Showing 1 changed file with 3 additions and 30 deletions.
33 changes: 3 additions & 30 deletions src/ComposerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class ComposerPlugin
/** Initialize members */
public function activate(Composer $composer, IOInterface $io) {
$this->io = $io;
$vendor = $composer->getConfig()->get('vendor-dir', '/');
$vendor = $composer->getConfig()->get('vendor-dir');

$this->vendor = $vendor;
$this->root = dirname($vendor);
Expand All @@ -57,34 +57,7 @@ public static function getSubscribedEvents() {
* Here we update our autoload map.
*/
public function onPostAutoloadDump(Event $event) {
$this->debugMessage("Loading composer autoload");
require_once($this->vendor.'/autoload.php');

$this->debugMessage("Parsing tree");
$importer = new RootImporter(
$this->root,
$event->isDevMode()
? IncludedRoots::DEV_AND_PROD
: IncludedRoots::PROD_ONLY
);

$handler = $event->isDevMode()
? $importer->getConfig()['devFailureHandler']
: $importer->getConfig()['failureHandler'];

$this->debugMessage("Writing hh_autoload.php");
(new Writer())
->setBuilder($importer)
->setRoot($this->root)
->setRelativeAutoloadRoot($importer->getConfig()['relativeAutoloadRoot'])
->setFailureHandler($handler)
->setIsDev($event->isDevMode())
->writeToFile($this->vendor.'/hh_autoload.hh');
}

private function debugMessage(\HH\string $message) {
if ($this->io->isDebug()) {
$this->io->write('hhvm-autoload: '.$message);
}
$args = $event->isDevMode() ? '' : ' --no-dev';
shell_exec('hhvm '.escapeshellarg($this->vendor.'/bin/hh-autoload').$args);
}
}

0 comments on commit 84a3ee1

Please sign in to comment.