| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Copies files to a directory.""" | 7 """Copies files to a directory.""" |
| 8 | 8 |
| 9 import itertools | 9 import itertools |
| 10 import optparse | 10 import optparse |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 """Copy file or directory and update deps.""" | 28 """Copy file or directory and update deps.""" |
| 29 if os.path.isdir(f): | 29 if os.path.isdir(f): |
| 30 shutil.copytree(f, os.path.join(dest, os.path.basename(f))) | 30 shutil.copytree(f, os.path.join(dest, os.path.basename(f))) |
| 31 deps.extend(_get_all_files(f)) | 31 deps.extend(_get_all_files(f)) |
| 32 else: | 32 else: |
| 33 shutil.copy(f, dest) | 33 shutil.copy(f, dest) |
| 34 deps.append(f) | 34 deps.append(f) |
| 35 | 35 |
| 36 def DoCopy(options, deps): | 36 def DoCopy(options, deps): |
| 37 """Copy files or directories given in options.files and update deps.""" | 37 """Copy files or directories given in options.files and update deps.""" |
| 38 files = list(itertools.chain.from_iterable(build_utils.ParseGypList(f) | 38 files = list(itertools.chain.from_iterable(build_utils.ParseGnList(f) |
| 39 for f in options.files)) | 39 for f in options.files)) |
| 40 | 40 |
| 41 for f in files: | 41 for f in files: |
| 42 if os.path.isdir(f) and not options.clear: | 42 if os.path.isdir(f) and not options.clear: |
| 43 print ('To avoid stale files you must use --clear when copying ' | 43 print ('To avoid stale files you must use --clear when copying ' |
| 44 'directories') | 44 'directories') |
| 45 sys.exit(-1) | 45 sys.exit(-1) |
| 46 CopyFile(f, options.dest, deps) | 46 CopyFile(f, options.dest, deps) |
| 47 | 47 |
| 48 def DoRenaming(options, deps): | 48 def DoRenaming(options, deps): |
| 49 """Copy and rename files given in options.renaming_sources and update deps.""" | 49 """Copy and rename files given in options.renaming_sources and update deps.""" |
| 50 src_files = list(itertools.chain.from_iterable( | 50 src_files = list(itertools.chain.from_iterable( |
| 51 build_utils.ParseGypList(f) | 51 build_utils.ParseGnList(f) |
| 52 for f in options.renaming_sources)) | 52 for f in options.renaming_sources)) |
| 53 | 53 |
| 54 dest_files = list(itertools.chain.from_iterable( | 54 dest_files = list(itertools.chain.from_iterable( |
| 55 build_utils.ParseGypList(f) | 55 build_utils.ParseGnList(f) |
| 56 for f in options.renaming_destinations)) | 56 for f in options.renaming_destinations)) |
| 57 | 57 |
| 58 if (len(src_files) != len(dest_files)): | 58 if (len(src_files) != len(dest_files)): |
| 59 print('Renaming source and destination files not match.') | 59 print('Renaming source and destination files not match.') |
| 60 sys.exit(-1) | 60 sys.exit(-1) |
| 61 | 61 |
| 62 for src, dest in itertools.izip(src_files, dest_files): | 62 for src, dest in itertools.izip(src_files, dest_files): |
| 63 if os.path.isdir(src): | 63 if os.path.isdir(src): |
| 64 print ('renaming diretory is not supported.') | 64 print ('renaming diretory is not supported.') |
| 65 sys.exit(-1) | 65 sys.exit(-1) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 options.depfile, | 108 options.depfile, |
| 109 deps + build_utils.GetPythonDependencies()) | 109 deps + build_utils.GetPythonDependencies()) |
| 110 | 110 |
| 111 if options.stamp: | 111 if options.stamp: |
| 112 build_utils.Touch(options.stamp) | 112 build_utils.Touch(options.stamp) |
| 113 | 113 |
| 114 | 114 |
| 115 if __name__ == '__main__': | 115 if __name__ == '__main__': |
| 116 sys.exit(main(sys.argv[1:])) | 116 sys.exit(main(sys.argv[1:])) |
| 117 | 117 |
| OLD | NEW |