Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / build / android / gyp / copy_ex.py
blob088880ce4866acaf4b029e67285a53ed768d10c5
1 #!/usr/bin/env python
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.
7 """Copies files to a directory."""
9 import optparse
10 import shutil
11 import sys
13 from util import build_utils
16 def main(args):
17 args = build_utils.ExpandFileArgs(args)
19 parser = optparse.OptionParser()
20 build_utils.AddDepfileOption(parser)
22 parser.add_option('--dest', help='Directory to copy files to.')
23 parser.add_option('--files', action='append',
24 help='List of files to copy.')
25 parser.add_option('--clear', action='store_true',
26 help='If set, the destination directory will be deleted '
27 'before copying files to it. This is highly recommended to '
28 'ensure that no stale files are left in the directory.')
29 parser.add_option('--stamp', help='Path to touch on success.')
31 options, _ = parser.parse_args(args)
33 if options.clear:
34 build_utils.DeleteDirectory(options.dest)
35 build_utils.MakeDirectory(options.dest)
37 files = []
38 for file_arg in options.files:
39 files += build_utils.ParseGypList(file_arg)
41 for f in files:
42 shutil.copy(f, options.dest)
44 if options.depfile:
45 build_utils.WriteDepfile(
46 options.depfile,
47 options.files + build_utils.GetPythonDependencies())
49 if options.stamp:
50 build_utils.Touch(options.stamp)
53 if __name__ == '__main__':
54 sys.exit(main(sys.argv[1:]))