Index: build/scan_sources.py |
diff --git a/build/scan_sources.py b/build/scan_sources.py |
index 44cb0043e2bff65aca58df6d0d52cbcd48cf3492..bd6253189f18d86e389ddb3795b38a1909b64202 100755 |
--- a/build/scan_sources.py |
+++ b/build/scan_sources.py |
@@ -59,6 +59,11 @@ class PathConverter(object): |
ospath = os.path.realpath(ospath) |
return self.ToPosixPath(ospath) |
+ def dirname(self, pathname): |
+ ospath = self.ToNativePath(pathname) |
+ ospath = os.path.dirname(ospath) |
+ return self.ToPosixPath(ospath) |
+ |
class Resolver(object): |
"""Resolver finds and generates relative paths for include files. |
@@ -85,6 +90,14 @@ class Resolver(object): |
return False |
return True |
+ def RemoveOneDirectory(self, pathname): |
+ """Remove an include search path.""" |
+ pathname = self.pathobj.realpath(pathname) |
+ DebugPrint('Removing DIR: %s' % pathname) |
+ if pathname in self.search_dirs: |
+ self.search_dirs.remove(pathname) |
+ return True |
+ |
def AddDirectories(self, pathlist): |
"""Add list of space separated directories.""" |
failed = False |
@@ -198,8 +211,13 @@ class WorkQueue(object): |
scan_name = self.PopIfAvail() |
while scan_name: |
includes = self.scanner.ScanFile(scan_name) |
+ # Add the directory of the current scanned file for resolving includes |
+ # while processing includes for this file. |
+ scan_dir = PathConverter().dirname(scan_name) |
+ self.resolver.AddOneDirectory(scan_dir) |
for include_file in includes: |
self.PushIfNew(include_file) |
+ self.resolver.RemoveOneDirectory(scan_dir) |
scan_name = self.PopIfAvail() |
return sorted(self.added_set) |