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

Side by Side Diff: mojo/public/dart/third_party/update_packages.py

Issue 1346773002: Stop running pub get at gclient sync time and fix build bugs (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright 2015 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 """Utility for updating third_party packages used in the Mojo Dart SDK"""
8
9 import argparse
10 import errno
11 import json
12 import os
13 import shutil
14 import subprocess
15 import sys
16
17 SCRIPT_DIR = os.path.dirname(sys.argv[0])
18
19 def check_for_pubspec_yaml():
20 return os.path.exists(os.path.join(SCRIPT_DIR, 'pubspec.yaml'))
21
22 def change_directory(directory):
23 return os.chdir(directory)
24
25 def remove_existing_packages(base_path):
26 print('Removing all package directories under %s' % base_path)
27 for child in os.listdir(base_path):
28 path = os.path.join(base_path, child)
29 if os.path.isdir(path):
30 print('Removing %s ' % path)
31 shutil.rmtree(path)
32
33 def pub_get(pub_exe):
34 return subprocess.check_output([pub_exe, 'get'])
35
36 def copy_packages(base_path):
37 packages_path = os.path.join(base_path, 'packages')
38 for package in os.listdir(packages_path):
39 lib_path = os.path.realpath(os.path.join(packages_path, package))
40 package_path = os.path.normpath(os.path.join(lib_path, '..'))
41 destinaton_path = os.path.join(base_path, package)
42 print('Copying %s to %s' % (package_path, destinaton_path))
43 shutil.copytree(package_path, destinaton_path)
44
45 def cleanup(base_path):
46 shutil.rmtree(os.path.join(base_path, 'packages'), True)
47 shutil.rmtree(os.path.join(base_path, '.pub'), True)
48 os.remove(os.path.join(base_path, '.packages'))
49
50 def main():
51 parser = argparse.ArgumentParser(description='Update third_party packages')
52 parser.add_argument('--pub-exe',
53 action='store',
54 metavar='pub_exe',
55 help='Path to the pub executable',
56 default='../../../../third_party/dart-sdk/dart-sdk/bin/pub ')
57
58 args = parser.parse_args()
59 if not check_for_pubspec_yaml():
60 print('Error could not find pubspec.yaml')
61 return 1
62
63 remove_existing_packages(SCRIPT_DIR)
64 change_directory(SCRIPT_DIR)
65 print('Running pub get')
66 pub_get(args.pub_exe)
67 copy_packages(SCRIPT_DIR)
68 print('Cleaning up')
69 cleanup(SCRIPT_DIR)
70
71 if __name__ == '__main__':
72 sys.exit(main())
OLDNEW
« no previous file with comments | « mojo/public/dart/third_party/unittest/test/with_test_environment_test.dart ('k') | mojo/public/dart/third_party/utf/LICENSE » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698