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."""
13 from util
import build_utils
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
)
34 build_utils
.DeleteDirectory(options
.dest
)
35 build_utils
.MakeDirectory(options
.dest
)
38 for file_arg
in options
.files
:
39 files
+= build_utils
.ParseGypList(file_arg
)
42 shutil
.copy(f
, options
.dest
)
45 build_utils
.WriteDepfile(
47 options
.files
+ build_utils
.GetPythonDependencies())
50 build_utils
.Touch(options
.stamp
)
53 if __name__
== '__main__':
54 sys
.exit(main(sys
.argv
[1:]))