16 parser = argparse.ArgumentParser(
17 description=
'A script to copy a file tree somewhere')
19 parser.add_argument(
'--depfile',
22 help=
'Path to a depfile to write when copying.')
27 help=
'Patterns to exclude [passed to shutil.copytree]')
29 '--from',
'-f', dest=
"copy_from", type=str, help=
'Source directory')
34 help=
'The path to a stamp file to output when finished.')
35 parser.add_argument(
'--to',
'-t', type=str, help=
'Destination directory')
37 return parser.parse_args(args)
41 if not args.copy_from
or not os.path.isdir(args.copy_from):
42 print(
"--from argument must refer to a directory")
45 print(
"--to is required")
56 names = os.listdir(src)
57 if ignore
is not None:
58 ignored_names = ignore(src, names)
62 if not os.path.exists(dst):
65 if name
in ignored_names:
67 srcname = os.path.join(src, name)
68 dstname = os.path.join(dst, name)
70 if os.path.isdir(srcname):
71 copy_tree(srcname, dstname, ignore, errors)
73 copied_files.append(srcname)
74 shutil.copy(srcname, dstname)
75 except (IOError, os.error)
as why:
76 errors.append((srcname, dstname, str(why)))
78 shutil.copystat(src, dst)
82 except OSError
as why:
83 errors.append((src, dst, str(why)))
86 def format_error(error):
88 return "Error: {msg}".
format(msg=str(error[0]))
89 return "From: {src}\nTo: {dst}\n{msg}" \
90 .
format(src=error[0], dst=error[1], msg=error[2])
95 failures =
"\n\n".
join(format_error(error)
for error
in errors)
96 parts = (
"Some file copies failed:",
"=" * 78, failures)
97 msg =
'\n'.
join(parts)
98 raise RuntimeError(msg)
104 os.makedirs(os.path.dirname(depfile), exist_ok=
True)
108 relstamp = os.path.relpath(stamp, cwd)
109 reldep_list = [os.path.relpath(d, cwd)
for d
in dep_list]
111 reldep_list = [path.replace(
" ",
r"\ ")
for path
in reldep_list]
112 with open(depfile,
'w')
as f:
121 if args.exclude_patterns ==
None:
122 copied_files =
CopyTree(args.copy_from, args.to)
124 patterns = args.exclude_patterns.split(
',')
125 copied_files =
CopyTree(args.copy_from,
127 ignore=shutil.ignore_patterns(*patterns))
129 if args.depfile
and args.stamp:
133 open(args.stamp,
'w').close()
138if __name__ ==
'__main__':
139 sys.exit(
Main(sys.argv))
uint32_t uint32_t * format
def CopyTree(src, dst, ignore=None)
def WriteDepfile(depfile, stamp, dep_list)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
def print(*args, **kwargs)
static SkString join(const CommandLineFlags::StringArray &)