From a03085b5569520becb74a2f06156b78060533686 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Tue, 11 Aug 2015 11:36:12 -0700 Subject: [PATCH] Fix linters on non-fb machines Summary: Our linters assume that clang-format is installed at /mnt/vol/engshare/admin/scripts/clang-format and flint is installed at /home/engshare/tools/flint. This makes them fail on non-fb machines. This change will: * if clang-format is not on a specified path, it will try running generic clang-format. Linters will still fail if clang-format is not installed, but this shouldn't be a big issue, since it's pretty easy to install it. * flint will not be run if /home/engshare/tools/flint is not present Test Plan: Made a change on a mac machine. Ran `arc lint`. No failures observed. Reviewers: aekmekji, yhchiang Reviewed By: yhchiang Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D44031 --- arcanist_util/cpp_linter/FbcodeClangFormatLinter.php | 8 +++++++- arcanist_util/cpp_linter/FbcodeCppLinter.php | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arcanist_util/cpp_linter/FbcodeClangFormatLinter.php b/arcanist_util/cpp_linter/FbcodeClangFormatLinter.php index 8b5d86475..a94a0bed1 100644 --- a/arcanist_util/cpp_linter/FbcodeClangFormatLinter.php +++ b/arcanist_util/cpp_linter/FbcodeClangFormatLinter.php @@ -35,9 +35,15 @@ final class FbcodeClangFormatLinter extends BaseDirectoryScopedFormatLinter { $args .= " --lines=$key:$key"; } + $binary = self::CLANG_FORMAT_BINARY; + if (!file_exists($binary)) { + // trust the $PATH + $binary = "clang-format"; + } + return new ExecFuture( "%s %s $args", - self::CLANG_FORMAT_BINARY, + $binary, $this->getEngine()->getFilePathOnDisk($path)); } diff --git a/arcanist_util/cpp_linter/FbcodeCppLinter.php b/arcanist_util/cpp_linter/FbcodeCppLinter.php index 4cb8b7c73..66eefa004 100644 --- a/arcanist_util/cpp_linter/FbcodeCppLinter.php +++ b/arcanist_util/cpp_linter/FbcodeCppLinter.php @@ -11,6 +11,9 @@ class FbcodeCppLinter extends ArcanistLinter { private $rawLintOutput = array(); public function willLintPaths(array $paths) { + if (!file_exists(self::FLINT)) { + return; + } $futures = array(); foreach ($paths as $p) { $lpath = $this->getEngine()->getFilePathOnDisk($p);