public function run() { $buildTarget = BuildTargetFactory::get($this->buildTarget); $compileLog = fopen($buildTarget->getCompileLogPath(), "w+"); $logs = $buildTarget->compile($buildTarget->getTranspiledPath(), $buildTarget->getWorkspacePath(), $buildTarget->getArtifactsPath()); fwrite($compileLog, $logs); fclose($compileLog); }
public function run() { $buildTarget = BuildTargetFactory::get($this->buildTarget); $systemCommand = "cp -a " . $buildTarget->getTranspiledPath() . ". " . $buildTarget->getWorkspacePath(); shell_exec(escapeshellcmd($systemCommand)); $systemCommand = "cp -a " . $buildTarget->getDependenciesPath() . ". " . $buildTarget->getWorkspacePath(); shell_exec(escapeshellcmd($systemCommand)); }
public function run() { $buildTarget = BuildTargetFactory::get($this->buildTarget); $scripts = $this->dependencyGraph->getScriptsToCompile($this->script); $sourcePaths = []; $outputPaths = []; foreach ($scripts as $buildScript) { $scriptName = pathinfo($buildScript, PATHINFO_FILENAME); $sourcePath = $buildTarget->getSourceFromPath($scriptName); $outputPath = $buildTarget->getTranspileToPath($scriptName); $sourcePaths[] = $sourcePath; $outputPaths[] = $outputPath; } $buildTarget->transpile($sourcePaths, $outputPaths); }
public function run() { $buildTarget = BuildTargetFactory::get($this->buildTarget); $archiveScan = scandir($buildTarget->getArchivePath()); $latestBuild = array_reduce($archiveScan, function ($latestBuild, $proposedBuild) { $castedProposedBuild = (int) $proposedBuild >= 0 ? (int) $proposedBuild : 0; return max($latestBuild, $castedProposedBuild); }, 0); $archivedBuild = $latestBuild + 1; $systemCommand = "mkdir " . $buildTarget->getArchivedBuildPath($archivedBuild); shell_exec(escapeshellcmd($systemCommand)); $systemCommand = "cp -a " . $buildTarget->getBuildPath() . ". " . $buildTarget->getArchivedBuildPath($archivedBuild); shell_exec(escapeshellcmd($systemCommand)); $systemCommand = "./clean.sh " . $this->buildTarget; shell_exec(escapeshellcmd($systemCommand)); }
protected function execute(InputInterface $input, OutputInterface $output) { set_time_limit(60); try { $target = $input->getArgument('target'); $scriptName = $input->getArgument('scriptName'); $buildTarget = BuildTargetFactory::get($target); if (count(array_slice(scandir($buildTarget->getWorkspacePath()), 2)) > 0 || count(array_slice(scandir($buildTarget->getTranspiledPath()), 2)) > 0 || count(array_slice(scandir($buildTarget->getArtifactsPath()), 2)) > 0) { $output->writeln("Target " . $target . " current build dir not clean, archive it manually."); return; } try { $task = new TranspileScriptJob(unserialize(file_get_contents('app/graph')), $buildTarget->getTargetName(), $scriptName); $task->run(); } catch (ConversionException $e) { $output->writeln("Exception occured."); $output->writeln(get_class($e)); $output->writeln($e->getMessage()); } $output->writeln("Preparing build workspace..."); /* * * @TODO - Create a factory that will provide a PrepareWorkspaceJob based on running system, so we can provide a * native implementation for Windows */ $prepareCommand = new PrepareWorkspaceJob($buildTarget->getTargetName()); $prepareCommand->run(); $output->writeln("Workspace prepared..."); $task = new CompileScriptJob($buildTarget->getTargetName()); $task->run(); $output->writeln("Build completed."); $compileLog = file_get_contents($buildTarget->getCompileLogPath()); var_dump($compileLog); } catch (\LogicException $e) { $output->writeln("Unknown target " . $target . ", exiting."); return; } catch (\Exception $e) { var_dump($e->getMessage()); exit; } }
public function runTask(\Amp\Deferred $deferred) { $buildTarget = BuildTargetFactory::get($this->buildTarget); foreach ($this->buildPlan as $buildChunk) { $sourcePaths = []; $outputPaths = []; foreach ($buildChunk as $buildScript) { $scriptName = pathinfo($buildScript, PATHINFO_FILENAME); $sourcePath = $buildTarget->getSourceFromPath($scriptName); $outputPath = $buildTarget->getTranspileToPath($scriptName); $sourcePaths[] = $sourcePath; $outputPaths[] = $outputPath; } try { $buildTarget->transpile($sourcePaths, $outputPaths); $this->updateWorker($deferred, true, $buildChunk); } catch (\Exception $e) { $this->updateWorker($deferred, false, $buildChunk, get_class($e) . PHP_EOL . $e->getMessage() . PHP_EOL); } } $deferred->succeed(); }
protected function execute(InputInterface $input, OutputInterface $output) { set_time_limit(10800); // 3 hours is the maximum for this command. Need more? You really screwed something, full suite for all Oblivion vanilla data takes 20 minutes. :) try { $target = $input->getArgument('target'); $this->threadsNumber = $input->getArgument('threadsNumber'); $buildTarget = BuildTargetFactory::get($target); if (count(array_slice(scandir($buildTarget->getWorkspacePath()), 2)) > 0 || count(array_slice(scandir($buildTarget->getTranspiledPath()), 2)) > 0 || count(array_slice(scandir($buildTarget->getArtifactsPath()), 2)) > 0) { $output->writeln("Target " . $target . " current build dir not clean, archive it manually."); return; } $output->writeln("Starting transpiling reactor using " . $this->threadsNumber . " threads..."); $reactor = \Amp\reactor(); $reactor->run(function () use($buildTarget, $output, $reactor) { $errorLog = fopen($buildTarget->getErrorLogPath(), "w+"); $sourceFiles = array_slice(scandir($buildTarget->getSourcePath()), 2); $buildPlanBuilder = new TES5BuildPlanBuilder(unserialize(file_get_contents('app/graph'))); $buildPlan = $buildPlanBuilder->createBuildPlan($sourceFiles, $this->threadsNumber); $totalSourceFiles = count($sourceFiles); $progressBar = new CliProgressBar($totalSourceFiles); $progressBar->display(); $promises = []; foreach ($buildPlan as $threadBuildPlan) { $task = new TranspileChunkJob($buildTarget->getTargetName(), $threadBuildPlan); $deferred = new \Amp\Deferred(); \Amp\once(function () use($deferred, $task) { $task->runTask($deferred); }, 0); $promise = $deferred->promise(); $promise->when(function (\Exception $e = null, $return = null) use($output, $errorLog) { if ($e) { $output->writeln('Exception ' . get_class($e) . ' occurred in one of the threads while transpiling, progress bar will not be accurate..'); fwrite($errorLog, get_class($e) . PHP_EOL . $e->getMessage() . PHP_EOL); } }); $promise->watch(function ($data) use($progressBar, $errorLog) { $progressBar->progress(count($data['scripts'])); if (isset($data['exception'])) { fwrite($errorLog, implode(', ', $data['scripts']) . PHP_EOL . $data['exception']); } }); $promises[] = $promise; } /** * @var Promise $transpilingPromise */ $transpilingPromise = \Amp\any($promises); $transpilingPromise->when(function () use($reactor, $progressBar, $errorLog) { $progressBar->end(); fclose($errorLog); $reactor->stop(); }); }); $output->writeln("Preparing build workspace..."); /* * * @TODO - Create a factory that will provide a PrepareWorkspaceJob based on running system, so we can provide a * native implementation for Windows */ $prepareCommand = new PrepareWorkspaceJob($buildTarget->getTargetName()); $prepareCommand->run(); $output->writeln("Workspace prepared..."); $task = new CompileScriptJob($buildTarget->getTargetName()); $task->run(); $output->writeln("Build completed, archiving ..."); /* * * @TODO - Create a factory that will provide a PrepareWorkspaceJob based on running system, so we can provide a * native implementation for Windows */ $prepareCommand = new ArchiveBuildJob($buildTarget->getTargetName()); $prepareCommand->run(); } catch (\LogicException $e) { $output->writeln("Unknown target " . $target . ", exiting."); return; } catch (\Exception $e) { var_dump($e->getMessage()); exit; } }
protected function execute(InputInterface $input, OutputInterface $output) { set_time_limit(10800); $target = 'Standalone'; $errorLog = fopen("graph_error_log", "w+"); $log = fopen("graph_debug_log", "w+"); $buildTarget = BuildTargetFactory::get($target); if (count(array_slice(scandir($buildTarget->getWorkspacePath()), 2)) > 0 || count(array_slice(scandir($buildTarget->getTranspiledPath()), 2)) > 0 || count(array_slice(scandir($buildTarget->getArtifactsPath()), 2)) > 0) { $output->writeln("Target " . $target . " current build dir not clean, archive it manually."); return; } $sourceFiles = array_slice(scandir($buildTarget->getSourcePath()), 2); $inferencer = new TES5TypeInferencer(new ESMAnalyzer(new TypeMapper()), $buildTarget->getSourcePath()); $dependencyGraph = []; $usageGraph = []; $progressBar = new CliProgressBar(count($sourceFiles)); $progressBar->display(); foreach ($sourceFiles as $sourceFile) { try { $scriptName = substr($sourceFile, 0, -4); $AST = $buildTarget->getAST($buildTarget->getSourceFromPath($scriptName)); /** * @var TES4ObjectProperty[] $propertiesAccesses */ $propertiesAccesses = []; $AST->filter(function ($data) use(&$propertiesAccesses) { if ($data instanceof TES4ObjectProperty) { $propertiesAccesses[] = $data; } }); /** * @var TES5Property[] $preparedProperties */ $preparedProperties = []; /** * @var TES5Type[] $preparedPropertiesTypes */ $preparedPropertiesTypes = []; foreach ($propertiesAccesses as $property) { preg_match("#([0-9a-zA-Z]+)\\.([0-9a-zA-Z]+)#i", $property->getData(), $matches); $propertyName = $matches[1]; $propertyKeyName = strtolower($propertyName); if (!isset($preparedProperties[$propertyKeyName])) { $preparedProperty = new TES5Property($propertyName, TES5BasicType::T_FORM(), $matches[1]); $preparedProperties[$propertyKeyName] = $preparedProperty; $inferencingType = $inferencer->resolveInferenceTypeByReferenceEdid($preparedProperty); $preparedPropertiesTypes[$propertyKeyName] = $inferencingType; } else { $preparedProperty = $preparedProperties[$propertyKeyName]; $inferencingType = $inferencer->resolveInferenceTypeByReferenceEdid($preparedProperty); if ($inferencingType != $preparedPropertiesTypes[$propertyKeyName]) { throw new ConversionException("Cannot settle up the properties types - conflict."); } } } fwrite($log, $scriptName . " - " . count($preparedProperties) . " prepared" . PHP_EOL); foreach ($preparedProperties as $preparedPropertyKey => $preparedProperty) { //Only keys are lowercased. $lowerPropertyType = strtolower($preparedPropertiesTypes[$preparedPropertyKey]->value()); $lowerScriptType = strtolower($scriptName); if (!isset($dependencyGraph[$lowerPropertyType])) { $dependencyGraph[$lowerPropertyType] = []; } $dependencyGraph[$lowerPropertyType][] = $lowerScriptType; if (!isset($usageGraph[$lowerScriptType])) { $usageGraph[$lowerScriptType] = []; } $usageGraph[$lowerScriptType][] = $lowerPropertyType; fwrite($log, 'Registering a dependency from ' . $scriptName . ' to ' . $preparedPropertiesTypes[$preparedPropertyKey]->value() . PHP_EOL); } $progressBar->progress(); } catch (\Exception $e) { fwrite($errorLog, $sourceFile . PHP_EOL . $e->getMessage()); continue; } } $progressBar->end(); $graph = new TES5ScriptDependencyGraph($dependencyGraph, $usageGraph); file_put_contents('app/graph', serialize($graph)); fclose($errorLog); fclose($log); }