Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # | |
| 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 | |
| 5 # found in the LICENSE file. | |
| 6 | |
| 7 """Copies files to a directory.""" | |
| 8 | |
| 9 import optparse | |
| 10 import shutil | |
| 11 import sys | |
| 12 | |
| 13 from util import build_utils | |
| 14 | |
| 15 def main(args): | |
| 16 args = build_utils.ExpandFileArgs(args) | |
| 17 | |
| 18 parser = optparse.OptionParser() | |
| 19 build_utils.AddDepfileOption(parser) | |
| 20 | |
| 21 parser.add_option('--todir', help='Directory to copy files to.') | |
|
newt (away)
2014/08/11 23:55:23
"dest"?
cjhopman
2014/08/18 01:21:11
Done.
| |
| 22 parser.add_option('--files', action='append', | |
| 23 help='List of files to copy.') | |
| 24 parser.add_option('--clear', action='store_true', | |
| 25 help='If set, todir will be deleted before copying files ' | |
| 26 'to it. This is highly recommended to ensure that no stale ' | |
| 27 'files are left in the directory.') | |
| 28 parser.add_option('--stamp', help='Path to touch on success.') | |
| 29 | |
| 30 options, _ = parser.parse_args(args) | |
| 31 | |
| 32 | |
|
newt (away)
2014/08/11 23:55:23
move extra newline to above "main"
cjhopman
2014/08/18 01:21:11
Done.
| |
| 33 if options.clear: | |
| 34 build_utils.DeleteDirectory(options.todir) | |
| 35 build_utils.MakeDirectory(options.todir) | |
| 36 | |
| 37 files = [] | |
| 38 for file_opt in options.files: | |
|
newt (away)
2014/08/11 23:55:23
what's "_opt"?
cjhopman
2014/08/18 01:21:11
I don't know if this is any better.
| |
| 39 files += build_utils.ParseGypList(file_opt) | |
| 40 | |
| 41 for f in files: | |
| 42 shutil.copy(f, options.todir) | |
| 43 | |
| 44 if options.depfile: | |
| 45 build_utils.WriteDepfile( | |
| 46 options.depfile, | |
| 47 options.files + build_utils.GetPythonDependencies()) | |
| 48 | |
| 49 if options.stamp: | |
| 50 build_utils.Touch(options.stamp) | |
| 51 | |
| 52 | |
| 53 if __name__ == '__main__': | |
| 54 sys.exit(main(sys.argv[1:])) | |
| 55 | |
| OLD | NEW |