flutter_flutter/tools/frontend_server_packages.py
Vyacheslav Egorov c8050e8e0d
Generate frontend server's .packages from Dart .packages file instead of using pub get. (#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.
2018-05-24 18:33:52 +02:00

27 lines
992 B
Python

#!/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')