| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import os | 6 import os |
| 7 import re | 7 import re |
| 8 import sys | 8 import sys |
| 9 | 9 |
| 10 """Header Scanner. | 10 """Header Scanner. |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 includes = self.scanner.ScanFile(scan_name) | 251 includes = self.scanner.ScanFile(scan_name) |
| 252 # Add the directory of the current scanned file for resolving includes | 252 # Add the directory of the current scanned file for resolving includes |
| 253 # while processing includes for this file. | 253 # while processing includes for this file. |
| 254 scan_dir = PathConverter().dirname(scan_name) | 254 scan_dir = PathConverter().dirname(scan_name) |
| 255 added_dir = not self.resolver.AddOneDirectory(scan_dir) | 255 added_dir = not self.resolver.AddOneDirectory(scan_dir) |
| 256 for include_file in includes: | 256 for include_file in includes: |
| 257 self.PushIfNew(include_file) | 257 self.PushIfNew(include_file) |
| 258 if added_dir: | 258 if added_dir: |
| 259 self.resolver.RemoveOneDirectory(scan_dir) | 259 self.resolver.RemoveOneDirectory(scan_dir) |
| 260 scan_name = self.PopIfAvail() | 260 scan_name = self.PopIfAvail() |
| 261 return sorted(self.added_set) | 261 return self.added_set |
| 262 | 262 |
| 263 | 263 |
| 264 def DoMain(argv): | 264 def DoMain(argv): |
| 265 """Entry point used by gyp's pymod_do_main feature.""" | 265 """Entry point used by gyp's pymod_do_main feature.""" |
| 266 global debug | 266 global debug |
| 267 | 267 |
| 268 resolver = Resolver() | 268 resolver = Resolver() |
| 269 files = [] | 269 files = [] |
| 270 | 270 |
| 271 arg_type = '' | 271 arg_type = '' |
| 272 for arg in argv: | 272 for arg in argv: |
| 273 if arg in ['-I', '-S']: | 273 if arg in ['-I', '-S']: |
| 274 arg_type = arg | 274 arg_type = arg |
| 275 elif arg == '-D': | 275 elif arg == '-D': |
| 276 debug = True | 276 debug = True |
| 277 elif arg_type == '-I': | 277 elif arg_type == '-I': |
| 278 # Skip generated include directories. These files may not exist and | 278 # Skip generated include directories. These files may not exist and |
| 279 # there should be explicit dependency on the target that generates | 279 # there should be explicit dependency on the target that generates |
| 280 # these files. | 280 # these files. |
| 281 if arg.startswith('$!PRODUCT_DIR'): | 281 if arg.startswith('$!PRODUCT_DIR'): |
| 282 continue | 282 continue |
| 283 resolver.AddDirectories([arg]) | 283 resolver.AddDirectories([arg]) |
| 284 elif arg_type == '-S': | 284 elif arg_type == '-S': |
| 285 files.append(arg) | 285 files.append(arg) |
| 286 | 286 |
| 287 workQ = WorkQueue(resolver) | 287 workQ = WorkQueue(resolver) |
| 288 for filename in files: | 288 for filename in files: |
| 289 workQ.PushIfNew(filename) | 289 workQ.PushIfNew(filename) |
| 290 | 290 |
| 291 sorted_list = workQ.Run() | 291 sources_set = workQ.Run() |
| 292 |
| 293 # If any of the original files requested aren't found, add them anyway. |
| 294 # This is so that source files that will be generated are still returned in |
| 295 # the program output. |
| 296 sources_set = sources_set.union(set(files)) |
| 297 |
| 298 sorted_list = sorted(sources_set) |
| 292 return '\n'.join(sorted_list) + '\n' | 299 return '\n'.join(sorted_list) + '\n' |
| 293 | 300 |
| 294 | 301 |
| 295 def Main(): | 302 def Main(): |
| 296 result = DoMain(sys.argv[1:]) | 303 result = DoMain(sys.argv[1:]) |
| 297 sys.stdout.write(result) | 304 sys.stdout.write(result) |
| 298 | 305 |
| 299 | 306 |
| 300 if __name__ == '__main__': | 307 if __name__ == '__main__': |
| 301 Main() | 308 Main() |
| OLD | NEW |