forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_package_files.py
36 lines (29 loc) · 1.19 KB
/
generate_package_files.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
# Copyright 2013 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
ALL_PACKAGES = {
'frontend_server': [],
}
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)