Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Merge pull request #41 from paulbiss/file-cache
Browse files Browse the repository at this point in the history
fixes for filecache
  • Loading branch information
fredemmott committed Jun 4, 2015
2 parents 601acd5 + 991fed7 commit bf6e593
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions base/HHVMDaemon.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,16 @@ protected function getPidFilePath(): string {
public function start(): void {
if ($this->options->precompile) {
$sourceRoot = $this->getTarget()->getSourceRoot();
$fileList = $this->options->tempDir . '/files.txt';
$hhvm = $this->options->hhvm;
invariant(!is_null($hhvm), "Must have hhvm path");
$args = Vector {
$hhvm,
'--hphp',
'--input-list', $fileList,
'--target', 'hhbc',
'--output-dir', $this->options->tempDir,
'--input-dir', $sourceRoot,
'--module', $sourceRoot,
'--module', '/',
'--cmodule', '/',
'-l3',
'-k1',
};
Expand All @@ -151,15 +150,18 @@ public function start(): void {

invariant(is_dir($sourceRoot), 'Could not find valid source root');

$files = Vector{};
$dir_iter = new RecursiveDirectoryIterator($sourceRoot);
$iter = new RecursiveIteratorIterator($dir_iter);
foreach ($iter as $path => $_) {
if (is_file($path)) {
$files->add(ltrim(substr($path, strlen($sourceRoot)), '/'));
// Source files not ending in .php need to be specifically included
if (is_file($path) && substr($path, -4) !== '.php') {
$contents = file_get_contents($path);
if (strpos($contents, '<?php') !== false) {
$arg = "--ffile=" . ltrim(substr($path, strlen($sourceRoot)), '/');
$args->add($arg);
}
}
}
file_put_contents($fileList, implode("\n", $files));

$bcRepo = $this->options->tempDir . '/hhvm.hhbc';
$staticContent = $this->options->tempDir . '/static.content';
Expand Down

0 comments on commit bf6e593

Please sign in to comment.