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

Unified Diff: checkdeps/cpp_checker.py

Issue 1154753008: Optionally support relative include paths in cpp_checker.py (Closed) Base URL: https://chromium.googlesource.com/chromium/buildtools.git@master
Patch Set: Resolve dot dot. Created 5 years, 6 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 | « checkdeps/checkdeps.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: checkdeps/cpp_checker.py
diff --git a/checkdeps/cpp_checker.py b/checkdeps/cpp_checker.py
index 94fd37a92145a7e3b0c829c303680dfff500363c..16139915d7f0714dea60b7fe643c69d5ca36a514 100644
--- a/checkdeps/cpp_checker.py
+++ b/checkdeps/cpp_checker.py
@@ -34,8 +34,10 @@ class CppChecker(object):
_EXTRACT_INCLUDE_PATH = re.compile(
'[ \t]*#[ \t]*(?:include|import)[ \t]+"(.*)"')
- def __init__(self, verbose):
+ def __init__(self, verbose, resolve_dotdot=False, root_dir=''):
self._verbose = verbose
+ self._resolve_dotdot = resolve_dotdot
+ self._root_dir = root_dir
def CheckLine(self, rules, line, dependee_path, fail_on_temp_allow=False):
"""Checks the given line with the given rule set.
@@ -65,6 +67,11 @@ class CppChecker(object):
print ' WARNING: include specified with no directory: ' + include_path
return True, None
+ if self._resolve_dotdot and '../' in include_path:
+ dependee_dir = os.path.dirname(dependee_path)
+ include_path = os.path.normpath(os.path.join(dependee_dir, include_path))
+ include_path = os.path.relpath(include_path, self._root_dir)
+
rule = rules.RuleApplyingTo(include_path, dependee_path)
if (rule.allow == Rule.DISALLOW or
(fail_on_temp_allow and rule.allow == Rule.TEMP_ALLOW)):
« no previous file with comments | « checkdeps/checkdeps.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698