execWithResult("{$bison} --version", false); if (preg_match('/bison \(GNU Bison\) (\d+)\.(\d+)(?:\.(\d+))?/', $version[1][0], $matches)) { $major = (int) $matches[1]; // major should be 3 or later if ($major < 3) { // find homebrew keg-only bison if ($command_path !== []) { return CheckResult::fail("Current {$bison} version is too old: " . $matches[0]); } return $this->checkBisonVersion(['/opt/homebrew/opt/bison/bin', '/usr/local/opt/bison/bin']); } return CheckResult::ok($matches[0]); } return CheckResult::fail('bison version cannot be determined'); } #[FixItem('brew')] public function fixBrew(): bool { shell(true)->exec('/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'); return true; } #[FixItem('build-tools')] public function fixBuildTools(array $missing): bool { $replacement = [ 'glibtoolize' => 'libtool', ]; foreach ($missing as $cmd) { if (isset($replacement[$cmd])) { $cmd = $replacement[$cmd]; } shell()->exec('brew install --formula ' . escapeshellarg($cmd)); } return true; } }