| 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 """Utility for checking and processing licensing information in third_party | 6 """Utility for checking and processing licensing information in third_party |
| 7 directories. | 7 directories. |
| 8 | 8 |
| 9 Usage: licenses.py <command> | 9 Usage: licenses.py <command> |
| 10 | 10 |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 | 578 |
| 579 entries.sort(key=lambda entry: (entry['name'], entry['content'])) | 579 entries.sort(key=lambda entry: (entry['name'], entry['content'])) |
| 580 entries_contents = '\n'.join([entry['content'] for entry in entries]) | 580 entries_contents = '\n'.join([entry['content'] for entry in entries]) |
| 581 file_template = open(file_template_file).read() | 581 file_template = open(file_template_file).read() |
| 582 template_contents = "<!-- Generated by licenses.py; do not edit. -->" | 582 template_contents = "<!-- Generated by licenses.py; do not edit. -->" |
| 583 template_contents += EvaluateTemplate(file_template, | 583 template_contents += EvaluateTemplate(file_template, |
| 584 {'entries': entries_contents}, | 584 {'entries': entries_contents}, |
| 585 escape=False) | 585 escape=False) |
| 586 | 586 |
| 587 if output_file: | 587 if output_file: |
| 588 with open(output_file, 'w') as output: | 588 changed = True |
| 589 output.write(template_contents) | 589 try: |
| 590 old_output = open(output_file, 'r').read() |
| 591 if old_output == template_contents: |
| 592 changed = False |
| 593 except: |
| 594 pass |
| 595 if changed: |
| 596 with open(output_file, 'w') as output: |
| 597 output.write(template_contents) |
| 590 else: | 598 else: |
| 591 print template_contents | 599 print template_contents |
| 592 | 600 |
| 593 if depfile: | 601 if depfile: |
| 594 assert output_file | 602 assert output_file |
| 595 # Add in build.ninja so that the target will be considered dirty whenever | 603 # Add in build.ninja so that the target will be considered dirty whenever |
| 596 # gn gen is run. Otherwise, it will fail to notice new files being added. | 604 # gn gen is run. Otherwise, it will fail to notice new files being added. |
| 597 # This is still no perfect, as it will fail if no build files are changed, | 605 # This is still no perfect, as it will fail if no build files are changed, |
| 598 # but a new README.chromium / LICENSE is added. This shouldn't happen in | 606 # but a new README.chromium / LICENSE is added. This shouldn't happen in |
| 599 # practice however. | 607 # practice however. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 args.output_file, args.target_os, | 639 args.output_file, args.target_os, |
| 632 args.gn_out_dir, args.gn_target, args.depfile): | 640 args.gn_out_dir, args.gn_target, args.depfile): |
| 633 return 1 | 641 return 1 |
| 634 else: | 642 else: |
| 635 print __doc__ | 643 print __doc__ |
| 636 return 1 | 644 return 1 |
| 637 | 645 |
| 638 | 646 |
| 639 if __name__ == '__main__': | 647 if __name__ == '__main__': |
| 640 sys.exit(main()) | 648 sys.exit(main()) |
| OLD | NEW |