From b1d7872faacbd37c03eacc1e86214904db8f658f Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 2 Feb 2018 22:17:58 +0000 Subject: Teach the presubmit check to look for checkdeps in other places. When PDFium source is not part of a standalone checkout, uploading CLs fail because the presubmit check cannot find the checkdeps tool. Detect the common case where PDFium is in third_party/pdfium, and look in the embedder source tree for checkdeps. BUG=pdfium:999 Change-Id: I972282aef9e62f99dce282d556ca2e68de3acbb0 Reviewed-on: https://pdfium-review.googlesource.com/24910 Commit-Queue: Lei Zhang Reviewed-by: Nico Weber --- PRESUBMIT.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/PRESUBMIT.py b/PRESUBMIT.py index a7db1230d4..ec0f0e4d9d 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -45,8 +45,21 @@ def _CheckUnwantedDependencies(input_api, output_api): # eval-ed and thus doesn't have __file__. original_sys_path = sys.path try: - sys.path = sys.path + [input_api.os_path.join( - input_api.PresubmitLocalPath(), 'buildtools', 'checkdeps')] + def GenerateCheckdepsPath(base_path): + return input_api.os_path.join(base_path, 'buildtools', 'checkdeps') + + presubmit_path = input_api.PresubmitLocalPath() + presubmit_parent_path = input_api.os_path.dirname(presubmit_path) + not_standalone_pdfium = \ + input_api.os_path.basename(presubmit_parent_path) == "third_party" and \ + input_api.os_path.basename(presubmit_path) == "pdfium" + + sys.path.append(GenerateCheckdepsPath(presubmit_path)) + if not_standalone_pdfium: + presubmit_grandparent_path = input_api.os_path.dirname( + presubmit_parent_path) + sys.path.append(GenerateCheckdepsPath(presubmit_grandparent_path)) + import checkdeps from cpp_checker import CppChecker from rules import Rule -- cgit v1.2.3