diff --git a/DEPS b/DEPS index 5126ae5494..7f6c90fc7f 100644 --- a/DEPS +++ b/DEPS @@ -237,10 +237,10 @@ hooks = [ 'name': 'run_dart_pub_get', 'pattern': '', 'action': [ 'python', - 'src/mojo/public/tools/git/dart_pub_get.py', - '--repository-root', '../../../..', + 'src/sky/tools/dart_pub_get.py', + '--repository-root', '../..', '--dart-sdk-directory', - '../../../../third_party/dart-sdk/dart-sdk', + '../../third_party/dart-sdk/dart-sdk', '--dirs-to-ignore', 'sky/packages/sky', ], }, diff --git a/engine/src/flutter/.gitignore b/engine/src/flutter/.gitignore index 6ed41e13e4..3e5103433e 100644 --- a/engine/src/flutter/.gitignore +++ b/engine/src/flutter/.gitignore @@ -24,7 +24,6 @@ Thumbs.db /build/linux/bin/eu-strip /buildtools/ /dart/ -/dart-pub-cache/ /mojo/devtools/ /mojo/public/ /native_client/ diff --git a/engine/src/flutter/sky/tools/dart_pub_get.py b/engine/src/flutter/sky/tools/dart_pub_get.py new file mode 100755 index 0000000000..6ca03f30eb --- /dev/null +++ b/engine/src/flutter/sky/tools/dart_pub_get.py @@ -0,0 +1,90 @@ +#!/usr/bin/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. + +"""This script runs "pub get" on all directories within the tree that have +pubspec.yaml files. + +See https://www.dartlang.org/tools/pub/get-started.html for information about +the pub tool.""" + +import argparse +import os +import subprocess +import sys + +def pub_get(dart_sdk_path, target_directory, upgrade): + cmd = [ + os.path.join(dart_sdk_path, "bin/pub") + ] + if upgrade: + cmd.extend(["upgrade"]) + else: + cmd.extend(["get"]) + + try: + subprocess.check_output(cmd, shell=False, + stderr=subprocess.STDOUT, + cwd=target_directory) + except subprocess.CalledProcessError as e: + print('Error running pub get in %s' % target_directory) + print(e.output) + raise e + + + +def main(repository_root, dart_sdk_path, dirs_to_ignore, upgrade): + os.chdir(repository_root) + + # Relativize dart_sdk_path to repository_root. + dart_sdk_path_from_root = os.path.join(repository_root, + os.path.relpath(dart_sdk_path, repository_root)) + + cmd = ["git", "ls-files", "*/pubspec.yaml"] + pubspec_yaml_files = subprocess.check_output(cmd, + shell=False, + stderr=subprocess.STDOUT) + + for f in pubspec_yaml_files.split(): + ignore = reduce(lambda x, y: x or f.startswith(y), dirs_to_ignore, False) + if ignore: + continue + pub_get(dart_sdk_path_from_root, os.path.dirname(f), upgrade) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="Run 'pub get' on all directories with checked-in " + "pubspec.yaml files") + parser.add_argument("--repository-root", + metavar="", + type=str, + required=True, + help="Path to the root of the Git repository, " + "specified as a relative path from this directory.") + parser.add_argument("--dart-sdk-directory", + metavar="", + type=str, + required=True, + help="Path to the directory containing the Dart SDK, " + "specified as a relative path from this directory.") + parser.add_argument("--dirs-to-ignore", + metavar="", + nargs="+", + default=[], + type=str, + help="Optional list of directories to ignore, specified " + "relative to the root of the repo. 'pub get' will " + "not be run for any subdirectories of these " + "directories.") + parser.add_argument("--upgrade", + action="store_true", + default=False, + help="Upgrade pub package dependencies") + args = parser.parse_args() + _current_path = os.path.dirname(os.path.realpath(__file__)) + _repository_root = os.path.join(_current_path, args.repository_root) + _dart_sdk_path = os.path.join(_current_path, args.dart_sdk_directory) + sys.exit( + main(_repository_root, _dart_sdk_path, args.dirs_to_ignore, args.upgrade)) diff --git a/engine/src/flutter/sky/tools/run_tests b/engine/src/flutter/sky/tools/run_tests index 709278ed2d..f32735d095 100755 --- a/engine/src/flutter/sky/tools/run_tests +++ b/engine/src/flutter/sky/tools/run_tests @@ -14,7 +14,6 @@ SRC_ROOT = os.path.dirname(SKY_ROOT) DART_SDK = os.path.join(SRC_ROOT, 'third_party', 'dart-sdk', 'dart-sdk', 'bin') PUB = os.path.join(DART_SDK, 'pub') -PUB_CACHE = os.path.join(SRC_ROOT, 'dart-pub-cache') UNIT_DIR = os.path.join(SRC_ROOT, 'sky', 'unit') PACKAGES_DIR = os.path.join(UNIT_DIR, 'packages') @@ -35,7 +34,6 @@ def main(): sky_shell = os.path.join(build_dir, 'SkyShell.app', 'Contents', 'MacOS', 'SkyShell') env = os.environ.copy() - env['PUB_CACHE'] = PUB_CACHE env['SKY_SHELL'] = sky_shell return subprocess.call([ PUB, 'run', 'sky_tools:sky_test', diff --git a/engine/src/flutter/sky/tools/skydoc.py b/engine/src/flutter/sky/tools/skydoc.py index e812860c2f..19f291365e 100755 --- a/engine/src/flutter/sky/tools/skydoc.py +++ b/engine/src/flutter/sky/tools/skydoc.py @@ -17,7 +17,6 @@ SKY_PACKAGE = os.path.join(SRC_ROOT, 'sky', 'packages', 'sky') DART_SDK = os.path.join(SRC_ROOT, 'third_party', 'dart-sdk', 'dart-sdk', 'bin') DARTDOC = os.path.join(DART_SDK, 'dartdoc') -PUB_CACHE = os.path.join(SRC_ROOT, 'dart-pub-cache') def main(): parser = argparse.ArgumentParser(description='Sky Documentation Generator') diff --git a/engine/src/flutter/sky/tools/skypy/skyserver.py b/engine/src/flutter/sky/tools/skypy/skyserver.py index fb32328c94..de00dd69b1 100644 --- a/engine/src/flutter/sky/tools/skypy/skyserver.py +++ b/engine/src/flutter/sky/tools/skypy/skyserver.py @@ -13,7 +13,6 @@ SRC_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(SKYPY_PATH))) WORKBENCH_ROOT = os.path.join(SRC_ROOT, 'sky', 'packages', 'workbench') DART_SDK = os.path.join(SRC_ROOT, 'third_party', 'dart-sdk', 'dart-sdk', 'bin') PUB = os.path.join(DART_SDK, 'pub') -PUB_CACHE = os.path.join(SRC_ROOT, "dart-pub-cache") EXAMPLES_ROOT = os.path.join(SRC_ROOT, 'examples') SKY_ROOT = os.path.join(SRC_ROOT, 'sky') @@ -36,15 +35,13 @@ class SkyServer(object): self.port) return - env = os.environ.copy() - env["PUB_CACHE"] = PUB_CACHE args = [PUB, 'run', 'sky_tools:sky_server', '--route=/sky,%s' % SKY_ROOT, '--route=/examples,%s' % EXAMPLES_ROOT, str(self.port)] - self.server = subprocess.Popen(args, cwd=WORKBENCH_ROOT, env=env) + self.server = subprocess.Popen(args, cwd=WORKBENCH_ROOT) return self.server.pid def stop(self):