| 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 from optparse import OptionParser | |
| 7 import os | 6 import os |
| 8 import re | 7 import re |
| 9 import sys | 8 import sys |
| 10 | 9 |
| 11 """Header Scanner. | 10 """Header Scanner. |
| 12 | 11 |
| 13 This module will scan a set of input sources for include dependencies. Use | 12 This module will scan a set of input sources for include dependencies. Use |
| 14 the command-line switch -Ixxxx to add include paths. All filenames and paths | 13 the command-line switch -Ixxxx to add include paths. All filenames and paths |
| 15 are expected and returned with POSIX separators. | 14 are expected and returned with POSIX separators. |
| 16 """ | 15 """ |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 self.PushIfNew(include_file) | 255 self.PushIfNew(include_file) |
| 257 if added_dir: | 256 if added_dir: |
| 258 self.resolver.RemoveOneDirectory(scan_dir) | 257 self.resolver.RemoveOneDirectory(scan_dir) |
| 259 scan_name = self.PopIfAvail() | 258 scan_name = self.PopIfAvail() |
| 260 return sorted(self.added_set) | 259 return sorted(self.added_set) |
| 261 | 260 |
| 262 | 261 |
| 263 def DoMain(argv): | 262 def DoMain(argv): |
| 264 """Entry point used by gyp's pymod_do_main feature.""" | 263 """Entry point used by gyp's pymod_do_main feature.""" |
| 265 global debug | 264 global debug |
| 266 parser = OptionParser() | |
| 267 parser.add_option('-I', dest='includes', action='append', | |
| 268 help='Set include path.') | |
| 269 parser.add_option('-D', dest='debug', action='store_true', | |
| 270 help='Enable debugging output.', default=False) | |
| 271 (options, files) = parser.parse_args(argv) | |
| 272 | |
| 273 if options.debug: | |
| 274 debug = True | |
| 275 | 265 |
| 276 resolver = Resolver() | 266 resolver = Resolver() |
| 277 if options.includes: | 267 files = [] |
| 278 if not resolver.AddDirectories(options.includes): | 268 |
| 279 return (-1, None) | 269 arg_type = '' |
| 270 for arg in argv: |
| 271 if arg in ['-I', '-S']: |
| 272 arg_type = arg |
| 273 elif arg == '-D': |
| 274 debug = True |
| 275 elif arg_type == '-I': |
| 276 # Skip generated include directories. These files may not exist and |
| 277 # there should be explicit dependency on the target that generates |
| 278 # these files. |
| 279 if arg.startswith('$!PRODUCT_DIR'): |
| 280 continue |
| 281 resolver.AddDirectories([arg]) |
| 282 elif arg_type == '-S': |
| 283 files.append(arg) |
| 280 | 284 |
| 281 workQ = WorkQueue(resolver) | 285 workQ = WorkQueue(resolver) |
| 282 for filename in files: | 286 for filename in files: |
| 283 workQ.PushIfNew(filename) | 287 workQ.PushIfNew(filename) |
| 284 | 288 |
| 285 sorted_list = workQ.Run() | 289 sorted_list = workQ.Run() |
| 286 return '\n'.join(sorted_list) + '\n' | 290 return '\n'.join(sorted_list) + '\n' |
| 287 | 291 |
| 288 | 292 |
| 289 def Main(): | 293 def Main(): |
| 290 result = DoMain(sys.argv[1:]) | 294 result = DoMain(sys.argv[1:]) |
| 291 sys.stdout.write(result) | 295 sys.stdout.write(result) |
| 292 | 296 |
| 293 | 297 |
| 294 if __name__ == '__main__': | 298 if __name__ == '__main__': |
| 295 Main() | 299 Main() |
| OLD | NEW |