OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium 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 __future__ import with_statement | 6 from __future__ import with_statement |
7 | 7 |
8 import errno | 8 import errno |
9 import optparse | 9 import optparse |
10 import os | 10 import os |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 parser.add_option('-o', '--output', dest='output', | 370 parser.add_option('-o', '--output', dest='output', |
371 help='Write manifest file to FILE (default is stdout)', | 371 help='Write manifest file to FILE (default is stdout)', |
372 metavar='FILE') | 372 metavar='FILE') |
373 parser.add_option('-D', '--objdump', dest='objdump', default='objdump', | 373 parser.add_option('-D', '--objdump', dest='objdump', default='objdump', |
374 help='Use TOOL as the "objdump" tool to run', | 374 help='Use TOOL as the "objdump" tool to run', |
375 metavar='TOOL') | 375 metavar='TOOL') |
376 parser.add_option('-L', '--library-path', dest='lib_path', | 376 parser.add_option('-L', '--library-path', dest='lib_path', |
377 action='append', default=[], | 377 action='append', default=[], |
378 help='Add DIRECTORY to library search path', | 378 help='Add DIRECTORY to library search path', |
379 metavar='DIRECTORY') | 379 metavar='DIRECTORY') |
| 380 parser.add_option('-P', '--path-prefix', dest='path_prefix', default='', |
| 381 help='A path to prepend to shared libraries in the .nmf', |
| 382 metavar='DIRECTORY') |
380 parser.add_option('-s', '--stage-dependencies', dest='stage_dependencies', | 383 parser.add_option('-s', '--stage-dependencies', dest='stage_dependencies', |
381 help='Destination directory for staging libraries', | 384 help='Destination directory for staging libraries', |
382 metavar='DIRECTORY') | 385 metavar='DIRECTORY') |
383 parser.add_option('-r', '--remove', dest='remove', | 386 parser.add_option('-r', '--remove', dest='remove', |
384 help='Remove the prefix from the files.', | 387 help='Remove the prefix from the files.', |
385 metavar='PATH') | 388 metavar='PATH') |
386 parser.add_option('-t', '--toolchain', dest='toolchain', | 389 parser.add_option('-t', '--toolchain', dest='toolchain', |
387 help='Add DIRECTORY to library search path', | 390 help='Add DIRECTORY to library search path', |
388 default=None, metavar='TOOLCHAIN') | 391 default=None, metavar='TOOLCHAIN') |
389 parser.add_option('-n', '--name', dest='name', | 392 parser.add_option('-n', '--name', dest='name', |
(...skipping 18 matching lines...) Expand all Loading... |
408 if options.toolchain not in ['newlib', 'glibc', 'pnacl']: | 411 if options.toolchain not in ['newlib', 'glibc', 'pnacl']: |
409 raise Error('Unknown toolchain: ' + str(options.toolchain)) | 412 raise Error('Unknown toolchain: ' + str(options.toolchain)) |
410 | 413 |
411 remap = {} | 414 remap = {} |
412 for ren in options.name: | 415 for ren in options.name: |
413 parts = ren.split(',') | 416 parts = ren.split(',') |
414 if len(parts) != 2: | 417 if len(parts) != 2: |
415 raise Error('Expecting --name=<orig_arch.so>,<new_name.so>') | 418 raise Error('Expecting --name=<orig_arch.so>,<new_name.so>') |
416 remap[parts[0]] = parts[1] | 419 remap[parts[0]] = parts[1] |
417 | 420 |
| 421 if options.path_prefix: |
| 422 path_prefix = options.path_prefix.split('/') |
| 423 else: |
| 424 path_prefix = [] |
| 425 |
418 nmf = NmfUtils(objdump=options.objdump, | 426 nmf = NmfUtils(objdump=options.objdump, |
419 main_files=args, | 427 main_files=args, |
420 lib_path=options.lib_path, | 428 lib_path=options.lib_path, |
| 429 lib_prefix=path_prefix, |
421 toolchain=options.toolchain, | 430 toolchain=options.toolchain, |
422 remap=remap) | 431 remap=remap) |
423 | 432 |
424 manifest = nmf.GetManifest() | 433 manifest = nmf.GetManifest() |
425 if options.output is None: | 434 if options.output is None: |
426 sys.stdout.write(nmf.GetJson()) | 435 sys.stdout.write(nmf.GetJson()) |
427 else: | 436 else: |
428 with open(options.output, 'w') as output: | 437 with open(options.output, 'w') as output: |
429 output.write(nmf.GetJson()) | 438 output.write(nmf.GetJson()) |
430 | 439 |
431 if options.stage_dependencies: | 440 if options.stage_dependencies: |
432 Trace("Staging dependencies...") | 441 Trace("Staging dependencies...") |
433 nmf.StageDependencies(options.stage_dependencies) | 442 nmf.StageDependencies(options.stage_dependencies) |
434 | 443 |
435 return 0 | 444 return 0 |
436 | 445 |
437 | 446 |
438 # Invoke this file directly for simple testing. | 447 # Invoke this file directly for simple testing. |
439 if __name__ == '__main__': | 448 if __name__ == '__main__': |
440 try: | 449 try: |
441 rtn = Main(sys.argv[1:]) | 450 rtn = Main(sys.argv[1:]) |
442 except Error, e: | 451 except Error, e: |
443 print "%s: %s" % (os.path.basename(__file__), e) | 452 print "%s: %s" % (os.path.basename(__file__), e) |
444 rtn = 1 | 453 rtn = 1 |
445 sys.exit(rtn) | 454 sys.exit(rtn) |
OLD | NEW |