From 544bbc6d81ee9d94a09809830b3f622f2dbad28a Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 14 Mar 2016 15:07:39 -0400 Subject: Add missing DEPS files; enable checkdeps. This CL adds the needed DEPS files to make checkdeps pass correctly. The checkdeps PRESUBMIT method has been copied from Chromium and is enabled on CL upload. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1801923002 . --- PRESUBMIT.py | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ core/fxge/freetype/DEPS | 3 +++ fpdfsdk/javascript/DEPS | 3 +++ testing/DEPS | 2 ++ xfa/fgas/font/DEPS | 3 +++ xfa/fxjse/DEPS | 5 +++++ 6 files changed, 73 insertions(+) create mode 100644 core/fxge/freetype/DEPS create mode 100644 fpdfsdk/javascript/DEPS create mode 100644 xfa/fgas/font/DEPS create mode 100644 xfa/fxjse/DEPS diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 71d6b6f7b3..819c4e64fd 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -33,9 +33,66 @@ LINT_FILTERS = [ '-whitespace/indent', ] + +def _CheckUnwantedDependencies(input_api, output_api): + """Runs checkdeps on #include statements added in this + change. Breaking - rules is an error, breaking ! rules is a + warning. + """ + import sys + # We need to wait until we have an input_api object and use this + # roundabout construct to import checkdeps because this file is + # 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')] + import checkdeps + from cpp_checker import CppChecker + from rules import Rule + finally: + # Restore sys.path to what it was before. + sys.path = original_sys_path + + added_includes = [] + for f in input_api.AffectedFiles(): + if not CppChecker.IsCppFile(f.LocalPath()): + continue + + changed_lines = [line for line_num, line in f.ChangedContents()] + added_includes.append([f.LocalPath(), changed_lines]) + + deps_checker = checkdeps.DepsChecker(input_api.PresubmitLocalPath()) + + error_descriptions = [] + warning_descriptions = [] + for path, rule_type, rule_description in deps_checker.CheckAddedCppIncludes( + added_includes): + description_with_path = '%s\n %s' % (path, rule_description) + if rule_type == Rule.DISALLOW: + error_descriptions.append(description_with_path) + else: + warning_descriptions.append(description_with_path) + + results = [] + if error_descriptions: + results.append(output_api.PresubmitError( + 'You added one or more #includes that violate checkdeps rules.', + error_descriptions)) + if warning_descriptions: + results.append(output_api.PresubmitPromptOrNotify( + 'You added one or more #includes of files that are temporarily\n' + 'allowed but being removed. Can you avoid introducing the\n' + '#include? See relevant DEPS file(s) for details and contacts.', + warning_descriptions)) + return results + + def CheckChangeOnUpload(input_api, output_api): results = [] + results += _CheckUnwantedDependencies(input_api, output_api) results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api) results += input_api.canned_checks.CheckChangeLintsClean( input_api, output_api, None, LINT_FILTERS) + return results diff --git a/core/fxge/freetype/DEPS b/core/fxge/freetype/DEPS new file mode 100644 index 0000000000..26546f7920 --- /dev/null +++ b/core/fxge/freetype/DEPS @@ -0,0 +1,3 @@ +include_rules = [ + '+third_party/freetype/src' +] diff --git a/fpdfsdk/javascript/DEPS b/fpdfsdk/javascript/DEPS new file mode 100644 index 0000000000..4b3f3dd3d0 --- /dev/null +++ b/fpdfsdk/javascript/DEPS @@ -0,0 +1,3 @@ +include_rules = [ + '+xfa/fxjse' +] diff --git a/testing/DEPS b/testing/DEPS index 949e92821f..86d3090407 100644 --- a/testing/DEPS +++ b/testing/DEPS @@ -3,4 +3,6 @@ include_rules = [ '+fpdfsdk/include', '+public', '+v8', + '+xfa/fxfa/parser', + '+xfa/fxfa/fm2js', ] diff --git a/xfa/fgas/font/DEPS b/xfa/fgas/font/DEPS new file mode 100644 index 0000000000..2930dd036a --- /dev/null +++ b/xfa/fgas/font/DEPS @@ -0,0 +1,3 @@ +include_rules = [ + '+third_party/freetype/include', +] diff --git a/xfa/fxjse/DEPS b/xfa/fxjse/DEPS new file mode 100644 index 0000000000..5cec1f887f --- /dev/null +++ b/xfa/fxjse/DEPS @@ -0,0 +1,5 @@ +include_rules = [ + # TODO(dsinclair): Layering violation. XFA can't include FPDFSDK. + '+fpdfsdk/include/jsapi', + '+v8/include', +] -- cgit v1.2.3