From c8c5afc95a3d658c9d7c42c3c23fe6c9a839779d Mon Sep 17 00:00:00 2001 From: Vyacheslav Egorov Date: Thu, 24 May 2018 18:33:52 +0200 Subject: [PATCH] Generate frontend server's .packages from Dart .packages file instead of using pub get. (flutter/engine#5360) Dart SDK itself does not use pub which forced us to manually maintain dependecy overrides in the frontend server's pubspec.yaml. This is rather fragile and easily breaks when dependencies in one of the "internal" packages change, but the package is not published yet. This change switches us to the same model of dependcies management that Dart SDK itself is using. Down side of this is that we can no longer do pub run test in the frontend_server and have to run tests manually. --- DEPS | 27 +---- .../src/flutter/frontend_server/pubspec.yaml | 101 ------------------ .../flutter/tools/frontend_server_packages.py | 26 +++++ 3 files changed, 31 insertions(+), 123 deletions(-) create mode 100644 engine/src/flutter/tools/frontend_server_packages.py diff --git a/DEPS b/DEPS index 46c229ddc0..70ee6343b6 100644 --- a/DEPS +++ b/DEPS @@ -88,6 +88,7 @@ vars = { 'dart_stack_trace_tag': '1.9.2', 'dart_stream_channel_tag': '1.6.4', 'dart_string_scanner_tag': '1.0.2', + 'dart_term_glyph_tag': '1.0.0', 'dart_test_tag': '0.12.38', 'dart_tuple_tag': 'v1.0.1', 'dart_typed_data_tag': '1.1.3', @@ -321,6 +322,9 @@ deps = { 'src/third_party/dart/third_party/pkg/typed_data': Var('dart_git') + '/typed_data.git' + '@' + Var('dart_typed_data_tag'), + 'src/third_party/dart/third_party/pkg/term_glyph': + Var('dart_git') + '/term_glyph.git' + '@' + Var('dart_term_glyph_tag'), + 'src/third_party/dart/third_party/pkg/test': Var('dart_git') + '/test.git' + '@' + Var('dart_test_tag'), @@ -418,29 +422,8 @@ hooks = [ { 'name': 'frontend_server_packages', 'pattern': '.', - 'condition': 'host_os == "linux"', 'cwd': 'src/flutter/frontend_server/', - 'action': [ - '../../../src/third_party/dart/tools/sdks/linux/dart-sdk/bin/pub', 'get', - ], - }, - { - 'name': 'frontend_server_packages', - 'pattern': '.', - 'condition': 'host_os == "mac"', - 'cwd': 'src/flutter/frontend_server/', - 'action': [ - '../../../src/third_party/dart/tools/sdks/mac/dart-sdk/bin/pub', 'get', - ], - }, - { - 'name': 'frontend_server_packages', - 'pattern': '.', - 'condition': 'host_os == "win"', - 'cwd': 'src/flutter/frontend_server/', - 'action': [ - '..\\..\\..\\src\\third_party\\dart\\tools\\sdks\\win\\dart-sdk\\bin\\pub.bat', 'get', - ], + 'action': ['python', '../tools/frontend_server_packages.py'], }, { # Ensure that we don't accidentally reference any .pyc files whose diff --git a/engine/src/flutter/frontend_server/pubspec.yaml b/engine/src/flutter/frontend_server/pubspec.yaml index ecf382f755..de6263ccd8 100644 --- a/engine/src/flutter/frontend_server/pubspec.yaml +++ b/engine/src/flutter/frontend_server/pubspec.yaml @@ -56,104 +56,3 @@ dev_dependencies: web_socket_channel: any when: any yaml: any - -dependency_overrides: - args: - path: ../../third_party/dart/third_party/pkg/args - async: - path: ../../third_party/dart/third_party/pkg/async - charcode: - path: ../../third_party/dart/third_party/pkg/charcode - collection: - path: ../../third_party/dart/third_party/pkg/collection - convert: - path: ../../third_party/dart/third_party/pkg/convert - crypto: - path: ../../third_party/dart/third_party/pkg/crypto - flutter_kernel_transformers: - path: ../flutter_kernel_transformers - front_end: - path: ../../third_party/dart/pkg/front_end/ - kernel: - path: ../../third_party/dart/pkg/kernel/ - logging: - path: ../../third_party/dart/third_party/pkg/logging - meta: - path: ../../third_party/dart/pkg/meta - quiver: - path: ../../third_party/dart/third_party/pkg/quiver - package_config: - path: ../../third_party/dart/third_party/pkg_tested/package_config - path: - path: ../../third_party/dart/third_party/pkg/path - source_span: - path: ../../third_party/dart/third_party/pkg/source_span - typed_data: - path: ../../third_party/dart/third_party/pkg/typed_data - usage: - path: ../../third_party/dart/third_party/pkg/usage - vm: - path: ../../third_party/dart/pkg/vm/ - - analyzer: - path: ../../third_party/dart/pkg/analyzer - boolean_selector: - path: ../../third_party/dart/third_party/pkg/boolean_selector - cli_util: - path: ../../third_party/dart/third_party/pkg/cli_util - csslib: - path: ../../third_party/dart/third_party/pkg/csslib - glob: - path: ../../third_party/dart/third_party/pkg/glob - html: - path: ../../third_party/dart/third_party/pkg/html - http: - path: ../../third_party/dart/third_party/pkg/http - http_multi_server: - path: ../../third_party/dart/third_party/pkg/http_multi_server - http_parser: - path: ../../third_party/dart/third_party/pkg/http_parser - matcher: - path: ../../third_party/dart/third_party/pkg/matcher - mime: - path: ../../third_party/dart/third_party/pkg/mime - mockito: - path: ../../third_party/dart/third_party/pkg/mockito - package_resolver: - path: ../../third_party/dart/third_party/pkg_tested/package_resolver - plugin: - path: ../../third_party/dart/third_party/pkg/plugin - pool: - path: ../../third_party/dart/third_party/pkg/pool - pub_semver: - path: ../../third_party/dart/third_party/pkg/pub_semver - shelf: - path: ../../third_party/dart/third_party/pkg/shelf - shelf_packages_handler: - path: ../../third_party/dart/third_party/pkg/shelf_packages_handler - shelf_static: - path: ../../third_party/dart/third_party/pkg/shelf_static - shelf_web_socket: - path: ../../third_party/dart/third_party/pkg/shelf_web_socket - source_map_stack_trace: - path: ../../third_party/dart/third_party/pkg/source_map_stack_trace - source_maps: - path: ../../third_party/dart/third_party/pkg/source_maps - stack_trace: - path: ../../third_party/dart/third_party/pkg/stack_trace - stream_channel: - path: ../../third_party/dart/third_party/pkg/stream_channel - string_scanner: - path: ../../third_party/dart/third_party/pkg/string_scanner - test: - path: ../../third_party/dart/third_party/pkg/test - utf: - path: ../../third_party/dart/third_party/pkg/utf - watcher: - path: ../../third_party/dart/third_party/pkg/watcher - web_socket_channel: - path: ../../third_party/dart/third_party/pkg/web_socket_channel - when: - path: ../../third_party/pkg/when - yaml: - path: ../../third_party/dart/third_party/pkg/yaml diff --git a/engine/src/flutter/tools/frontend_server_packages.py b/engine/src/flutter/tools/frontend_server_packages.py new file mode 100644 index 0000000000..1c2bbe28c5 --- /dev/null +++ b/engine/src/flutter/tools/frontend_server_packages.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# Copyright 2018 The Flutter 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 generates .packages file for frontend server from +# Dart SDKs .packages file located in third_party/dart/.packages + +import os +import shutil + +DOT_PACKAGES = '.packages' +FRONTEND_SERVER_DIR = os.getcwd() +SRC_DIR = os.path.dirname(os.path.dirname(FRONTEND_SERVER_DIR)) +DART_PACKAGES_FILE = os.path.join(SRC_DIR, 'third_party', 'dart', DOT_PACKAGES) + +with open(DOT_PACKAGES, 'w') as packages: + with open(DART_PACKAGES_FILE, 'r') as dart_packages: + for line in dart_packages: + if line.startswith('#'): + packages.write(line) + else: + [package, path] = line.split(':', 1) + packages.write('%s:../../third_party/dart/%s' % (package, path)) + packages.write('frontend_server:./lib\n') + packages.write('flutter_kernel_transformers:../flutter_kernel_transformers/lib\n')