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

Unified Diff: mojo/tools/deploy.py

Issue 1145843002: Fix domokit.github.io site deployment script (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 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 | « no previous file | mojo/tools/deploy_domokit_site.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/tools/deploy.py
diff --git a/mojo/tools/deploy.py b/mojo/tools/deploy.py
deleted file mode 100755
index be83c9395fef669d8c2f78594f6b12a6d2d83f45..0000000000000000000000000000000000000000
--- a/mojo/tools/deploy.py
+++ /dev/null
@@ -1,134 +0,0 @@
-#!/usr/bin/env python
-# Copyright 2015 The Chromium Authors. 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 logging
-import os
-import shutil
-import subprocess
-
-from mopy.paths import Paths
-
-
-def git_revision():
- return subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip()
-
-
-def mojo_filter(path):
- if not os.path.isfile(path):
- return False
- _, ext = os.path.splitext(path)
- if ext != '.mojo':
- return False
- return 'apptests' not in os.path.basename(path)
-
-
-def gen_filter(path):
- if os.path.isdir(path):
- return True
- _, ext = os.path.splitext(path)
- # Don't include all .dart, just .mojom.dart.
- return ext == '.sky' or path.endswith('.mojom.dart')
-
-
-def sky_or_dart_filter(path):
- if os.path.isdir(path):
- return True
- _, ext = os.path.splitext(path)
- # .dart includes '.mojom.dart'
- return ext == '.sky' or ext == '.dart'
-
-
-def assets_filter(path):
- if os.path.isdir(path):
- return True
- if os.path.basename(os.path.dirname(path)) != '2x_web':
- return False
- # We only use the 18 and 24s for now.
- return '18dp' in path or '24dp' in path
-
-
-def copy(from_root, to_root, filter_func=None):
- if os.path.exists(to_root):
- shutil.rmtree(to_root)
- os.makedirs(to_root)
-
- for root, dirs, files in os.walk(from_root):
- # filter_func expects paths not names, so wrap it to make them absolute.
- wrapped_filter = None
- if filter_func:
- wrapped_filter = lambda name: filter_func(os.path.join(root, name))
-
- for name in filter(wrapped_filter, files):
- from_path = os.path.join(root, name)
- root_rel_path = os.path.relpath(from_path, from_root)
- to_path = os.path.join(to_root, root_rel_path)
- to_dir = os.path.dirname(to_path)
- if not os.path.exists(to_dir):
- os.makedirs(to_dir)
- shutil.copyfile(from_path, to_path)
-
- dirs[:] = filter(wrapped_filter, dirs)
-
-def main():
- logging.basicConfig(level=logging.WARN)
- parser = argparse.ArgumentParser(description='Deploy a new build of mojo.')
- parser.add_argument('deploy_root', type=str)
- args = parser.parse_args()
-
- # Always use android release?
- rel_build_dir = os.path.join('out', 'android_Release')
- build_dir = os.path.join(Paths().src_root, rel_build_dir)
- paths = Paths(build_dir=build_dir)
-
- def deploy_path(rel_path):
- return os.path.join(args.deploy_root, rel_path)
-
- def src_path(rel_path):
- return os.path.join(paths.src_root, rel_path)
-
- copy(paths.build_dir, deploy_path('mojo'), mojo_filter)
- copy(src_path('mojo/public'), deploy_path('mojo/public'),
- sky_or_dart_filter)
-
- # TODO(eseidel): All of these should be removed and package: sky includes
- # used instead.
- copy(src_path('sky/examples'), deploy_path('sky/examples'),
- sky_or_dart_filter)
- copy(src_path('sky/framework'), deploy_path('sky/framework'),
- sky_or_dart_filter)
- copy(os.path.join(paths.build_dir, 'gen'), deploy_path('gen'), gen_filter)
- copy(src_path('sky/assets'), deploy_path('sky/assets'), assets_filter)
-
- shutil.copy(os.path.join(paths.build_dir, 'apks', 'MojoShell.apk'),
- args.deploy_root)
- shutil.copy(os.path.join(paths.build_dir, 'apks', 'MojoShortcuts.apk'),
- args.deploy_root)
-
- packages_root = deploy_path('packages')
- if os.path.exists(packages_root):
- shutil.rmtree(packages_root)
- subprocess.check_call([
- src_path('sky/tools/deploy_sdk.py'),
- '--non-interactive',
- deploy_path('sky_sdk'),
- '--fake-pub-get-into',
- packages_root
- ])
-
- with open(deploy_path('LICENSES.sky'), 'w') as license_file:
- subprocess.check_call([src_path('tools/licenses.py'), 'credits'],
- stdout=license_file)
-
-
- subprocess.check_call(['git', 'add', '.'], cwd=args.deploy_root)
- subprocess.check_call([
- 'git', 'commit',
- '-m', '%s from %s' % (rel_build_dir, git_revision())
- ], cwd=args.deploy_root)
-
-
-if __name__ == '__main__':
- main()
« no previous file with comments | « no previous file | mojo/tools/deploy_domokit_site.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698