OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Deploy domokit.github.io""" | 6 """Deploy domokit.github.io""" |
7 | 7 |
8 # NOTE: Requires that download_material_design_icons to have been run from | 8 # NOTE: Requires that download_material_design_icons to have been run from |
9 # $build_dir/gen/dart-dpkg/sky. | 9 # $build_dir/gen/dart-dpkg/sky. |
10 | 10 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 | 63 |
64 def packages_filter(path): | 64 def packages_filter(path): |
65 if 'packages/sky/assets/material-design-icons/' in path: | 65 if 'packages/sky/assets/material-design-icons/' in path: |
66 return assets_filter(path) | 66 return assets_filter(path) |
67 if '.gitignore' in path: | 67 if '.gitignore' in path: |
68 return False | 68 return False |
69 return True | 69 return True |
70 | 70 |
71 | 71 |
| 72 def ensure_dir_exists(path): |
| 73 if not os.path.exists(path): |
| 74 os.makedirs(path) |
| 75 |
| 76 |
72 def copy(from_root, to_root, filter_func=None, followlinks=False): | 77 def copy(from_root, to_root, filter_func=None, followlinks=False): |
| 78 assert os.path.exists(from_root), "%s does not exist!" % from_root |
| 79 if os.path.isfile(from_root): |
| 80 ensure_dir_exists(os.path.dirname(to_root)) |
| 81 shutil.copy(from_root, to_root) |
| 82 return |
| 83 |
73 if os.path.exists(to_root): | 84 if os.path.exists(to_root): |
74 shutil.rmtree(to_root) | 85 shutil.rmtree(to_root) |
75 os.makedirs(to_root) | 86 os.makedirs(to_root) |
76 | 87 |
77 for root, dirs, files in os.walk(from_root, followlinks=followlinks): | 88 for root, dirs, files in os.walk(from_root, followlinks=followlinks): |
78 # filter_func expects paths not names, so wrap it to make them absolute. | 89 # filter_func expects paths not names, so wrap it to make them absolute. |
79 wrapped_filter = None | 90 wrapped_filter = None |
80 if filter_func: | 91 if filter_func: |
81 wrapped_filter = lambda name: filter_func(os.path.join(root, name)) | 92 wrapped_filter = lambda name: filter_func(os.path.join(root, name)) |
82 | 93 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 'sky/assets/material-design-icons') | 129 'sky/assets/material-design-icons') |
119 if not os.path.isdir(icons_dir): | 130 if not os.path.isdir(icons_dir): |
120 print('NOTE: Running `download_material_design_icons` for you.'); | 131 print('NOTE: Running `download_material_design_icons` for you.'); |
121 subprocess.check_call([ | 132 subprocess.check_call([ |
122 os.path.join(sky_pkg_lib_dir, 'download_material_design_icons') | 133 os.path.join(sky_pkg_lib_dir, 'download_material_design_icons') |
123 ]) | 134 ]) |
124 | 135 |
125 # Copy sky/examples into examples/ | 136 # Copy sky/examples into examples/ |
126 copy(src_path('sky/examples'), deploy_path('examples'), examples_filter) | 137 copy(src_path('sky/examples'), deploy_path('examples'), examples_filter) |
127 | 138 |
| 139 copy(src_path('sky/sky_home'), args.deploy_root) |
| 140 copy(src_path('sky/sky_home.dart'), args.deploy_root) |
| 141 |
128 # Deep copy packages/. This follows symlinks and flattens them. | 142 # Deep copy packages/. This follows symlinks and flattens them. |
129 packages_root = deploy_path('packages') | 143 packages_root = deploy_path('packages') |
130 copy(dart_pkg_packages_dir, packages_root, packages_filter, True) | 144 copy(dart_pkg_packages_dir, packages_root, packages_filter, True) |
131 | 145 |
132 # Write out license. | 146 # Write out license. |
133 with open(deploy_path('LICENSES.sky'), 'w') as license_file: | 147 with open(deploy_path('LICENSES.sky'), 'w') as license_file: |
134 subprocess.check_call([src_path('tools/licenses.py'), 'credits'], | 148 subprocess.check_call([src_path('tools/licenses.py'), 'credits'], |
135 stdout=license_file) | 149 stdout=license_file) |
136 | 150 |
137 # Run git commands. | 151 # Run git commands. |
138 subprocess.check_call(['git', 'add', '.'], cwd=args.deploy_root) | 152 subprocess.check_call(['git', 'add', '.'], cwd=args.deploy_root) |
139 subprocess.check_call([ | 153 subprocess.check_call([ |
140 'git', 'commit', | 154 'git', 'commit', |
141 '-m', '%s from %s' % (rel_build_dir, git_revision()) | 155 '-m', '%s from %s' % (rel_build_dir, git_revision()) |
142 ], cwd=args.deploy_root) | 156 ], cwd=args.deploy_root) |
143 | 157 |
144 | 158 |
145 if __name__ == '__main__': | 159 if __name__ == '__main__': |
146 main() | 160 main() |
OLD | NEW |