generate_package_files.py 1.2 KB
Newer Older
1
#!/usr/bin/env python
M
Michael Goderbauer 已提交
2
# Copyright 2013 The Flutter Authors. All rights reserved.
3 4 5
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

6 7
# This script generates .packages file for frontend_server from Dart SDKs
# .packages file located in  third_party/dart/.packages
8 9 10 11 12

import os
import shutil

ALL_PACKAGES = {
13
  'flutter_frontend_server': [],
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
}

SRC_DIR = os.getcwd()

DOT_PACKAGES = '.packages'
DART_PACKAGES_FILE = os.path.join(SRC_DIR, 'third_party', 'dart', DOT_PACKAGES)

# Generate .packages file in the given package.
def GeneratePackages(package, local_deps):
  with open(os.path.join('flutter', package, 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:
          [name, path] = line.split(':', 1)
          packages.write('%s:../../third_party/dart/%s' % (name, path))
    packages.write('%s:./lib\n' % (package))
    for other_package in local_deps:
      packages.write('%s:../%s/lib\n' % (other_package, other_package))

for package, local_deps in ALL_PACKAGES.iteritems():
  GeneratePackages(package, local_deps)