Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Unified Diff: tools/copy_tree.py

Issue 2826793002: [Fuchsia] Build only the parts of the SDK that are needed (Closed)
Patch Set: Back out bad fix Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/BUILD.gn ('k') | tools/create_sdk.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/copy_tree.py
diff --git a/tools/copy_tree.py b/tools/copy_tree.py
new file mode 100755
index 0000000000000000000000000000000000000000..da1cb6c8aa98a0384e7acd253efd29ecb9637956
--- /dev/null
+++ b/tools/copy_tree.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+# for details. All rights reserved. Use of this source code is governed by a
+# BSD-style license that can be found in the LICENSE file.
+
+import argparse
+import os
+import re
+import shutil
+import sys
+
+def ParseArgs(args):
+ args = args[1:]
+ parser = argparse.ArgumentParser(
+ description='A script to copy a file tree somewhere')
+
+ parser.add_argument('--exclude_patterns', '-e',
+ type=str,
+ help='Patterns to exclude [passed to shutil.copytree]')
+ parser.add_argument('--from', '-f',
+ dest="copy_from",
+ type=str,
+ required=True,
+ help='Source tree root')
+ parser.add_argument('--to', '-t',
+ type=str,
+ required=True,
+ help='Destination')
+
+ return parser.parse_args(args)
+
+
+def ValidateArgs(args):
+ if not os.path.isdir(args.copy_from):
+ print "--from argument must refer to a directory"
+ return False
+ return True
+
+
+def Main(argv):
+ args = ParseArgs(argv)
+ if not ValidateArgs(args):
+ return -1
+ if os.path.exists(args.to):
+ shutil.rmtree(args.to)
+ if args.exclude_patterns == None:
+ shutil.copytree(args.copy_from, args.to)
+ else:
+ patterns = args.exclude_patterns.split(',')
+ shutil.copytree(args.copy_from, args.to,
+ ignore=shutil.ignore_patterns(tuple(patterns)))
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(Main(sys.argv))
« no previous file with comments | « sdk/BUILD.gn ('k') | tools/create_sdk.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698