Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: tools/checkdeps/checkdeps.py

Issue 113147: Also scan .m and .mm files in checkdeps.py (Closed)
Patch Set: updat Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/DEPS ('k') | webkit/tools/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/checkdeps/checkdeps.py
diff --git a/tools/checkdeps/checkdeps.py b/tools/checkdeps/checkdeps.py
index 96e9a16327964c3cd9b4e5632e9ba3e20d35e68e..25319cf533be4eb875c269c460827c26060038bc 100755
--- a/tools/checkdeps/checkdeps.py
+++ b/tools/checkdeps/checkdeps.py
@@ -69,9 +69,6 @@ INCLUDE_RULES_VAR_NAME = "include_rules"
# be checked. This allows us to skip third party code, for example.
SKIP_SUBDIRS_VAR_NAME = "skip_child_includes"
-# We'll search for lines beginning with this string for checking.
-INCLUDE_PREFIX = "#include"
-
# The maximum number of lines to check in each source file before giving up.
MAX_LINES = 150
@@ -84,7 +81,7 @@ VERBOSE = False
# This regular expression will be used to extract filenames from include
# statements.
-EXTRACT_INCLUDE_FILENAME = re.compile(INCLUDE_PREFIX + ' *"(.*)"')
+EXTRACT_INCLUDE_PATH = re.compile('[ \t]*#[ \t]*(?:include|import)[ \t]+"(.*)"')
# In lowercase, using forward slashes as directory separators, ending in a
# forward slash. Set by the command line options.
@@ -274,19 +271,21 @@ def ApplyDirectoryRules(existing_rules, dir_name):
def ShouldCheckFile(file_name):
"""Returns True if the given file is a type we want to check."""
- if len(file_name) < 2:
- return False
- return file_name.endswith(".cc") or file_name.endswith(".h")
+ checked_extensions = [
+ '.h',
+ '.cc',
+ '.m',
+ '.mm',
+ ]
+ basename, extension = os.path.splitext(file_name)
+ return extension in checked_extensions
def CheckLine(rules, line):
"""Checks the given file with the given rule set. If the line is an #include
directive and is illegal, a string describing the error will be returned.
Otherwise, None will be returned."""
- if line[0:8] != "#include":
- return None # Not an include line
-
- found_item = EXTRACT_INCLUDE_FILENAME.match(line)
+ found_item = EXTRACT_INCLUDE_PATH.match(line)
if not found_item:
return None # Not a match
« no previous file with comments | « chrome/DEPS ('k') | webkit/tools/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698