public function __construct() { parent::__construct('Mesamatrix CLI', \Mesamatrix::$config->getValue('info', 'version')); $dispatcher = new EventDispatcher(); // Install CLI logger $dispatcher->addListener(ConsoleEvents::COMMAND, function (ConsoleCommandEvent $e) { $logger = new \Monolog\Logger('cli.' . $e->getCommand()->getName(), \Mesamatrix::$logger->getHandlers()); $logger->pushHandler(new \Symfony\Bridge\Monolog\Handler\ConsoleHandler($e->getOutput())); \Mesamatrix::$logger = $logger; }); $this->setDispatcher($dispatcher); }
public function __construct(array $arguments = array()) { array_unshift($arguments, 'git'); $gitDir = \Mesamatrix::path(\Mesamatrix::$config->getValue("info", "private_dir")) . "/"; $gitDir .= \Mesamatrix::$config->getValue("git", "mesa_dir", "mesa.git"); foreach ($arguments as &$arg) { $arg = str_replace('@gitDir@', $gitDir, $arg); } parent::__construct($arguments); $this->setWorkingDirectory($gitDir); }
public static function init() { date_default_timezone_set('UTC'); $dir = str_replace("\\", '/', __DIR__); self::$serverRoot = implode('/', array_slice(explode('/', $dir), 0, -1)); self::$autoloader = (require self::path('vendor/autoload.php')); self::$logger = new Logger('logger'); self::$logger->pushHandler(new ErrorLogHandler(ErrorLogHandler::OPERATING_SYSTEM, Logger::NOTICE)); ErrorHandler::register(self::$logger); self::$configDir = self::path('config'); self::$config = new \Mesamatrix\Config(self::$configDir); // attempt to create the private dir $privateDir = self::path(self::$config->getValue('info', 'private_dir')); if (!is_dir($privateDir)) { mkdir($privateDir); } // register the log file $logLevel = self::$config->getValue('info', 'log_level', Logger::WARNING); $logPath = $privateDir . '/mesamatrix.log'; if (!file_exists($logPath) && is_dir($privateDir)) { touch($logPath); } if (is_writable($logPath)) { self::$logger->popHandler(); self::$logger->pushHandler(new StreamHandler($logPath, $logLevel)); } else { self::$logger->error('Error log ' . $logPath . ' is not writable!'); } if ($logLevel < Logger::INFO) { ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); } // initialise request self::$request = HTTPRequest::createFromGlobals(); self::$logger->debug('Base initialisation complete'); }
</td> <?php } } ?> </tr> </tfoot> </table> <?php } } } ///////////////////////////////////////////////// // Load XML. // $gl3Path = Mesamatrix::path(Mesamatrix::$config->getValue("info", "xml_file")); // Read "xml_file". $xml = simplexml_load_file($gl3Path); if (!$xml) { \Mesamatrix::$logger->critical("Can't read " . $gl3Path); exit; } // Set all the versions in an array so that it can be sorted out. $glVersions = array(); foreach ($xml->gl as $glVersion) { $glVersions[] = $glVersion; } // Sort the versions. usort($glVersions, function ($a, $b) { // Sort OpenGL before OpenGLES and higher versions before lower ones. if ((string) $a["name"] === (string) $b["name"]) {
/** * Take all the parsed commits and merged them to generate the final XML. * * @param array \Mesamatrix\Git\Commit $commits The commits to merge. */ protected function generateMergedXml(array $commits) { \Mesamatrix::$logger->info('Merge all the commits.'); $matrix = new OglMatrix(); foreach ($commits as $commit) { $hash = $commit->getHash(); $xmlPath = \Mesamatrix::path(\Mesamatrix::$config->getValue('info', 'private_dir')) . '/commits/commit_' . $hash . '.xml'; $mesa = simplexml_load_file($xmlPath); $matrix->merge($mesa, $commit); } \Mesamatrix::$logger->info('Generating XML file'); $xml = new \SimpleXMLElement("<mesa></mesa>"); $gitDir = \Mesamatrix::path(\Mesamatrix::$config->getValue('info', 'private_dir')) . '/'; $gitDir .= \Mesamatrix::$config->getValue('git', 'mesa_dir', 'mesa.git'); $updated = filemtime($gitDir . '/FETCH_HEAD'); $xml->addAttribute('updated', $updated); $drivers = $xml->addChild("drivers"); $this->populateDrivers($drivers); $statuses = $xml->addChild("statuses"); $this->populateStatuses($statuses); $xmlCommits = $xml->addChild('commits'); $this->generateCommitsLog($xmlCommits, $commits); $this->generateGlSections($xml, $matrix); $xmlPath = \Mesamatrix::path(\Mesamatrix::$config->getValue("info", "xml_file")); $dom = dom_import_simplexml($xml)->ownerDocument; $dom->formatOutput = true; file_put_contents($xmlPath, $dom->saveXML()); \Mesamatrix::$logger->info('XML saved to ' . $xmlPath); }