OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 import argparse |
| 7 import subprocess |
| 8 import sys |
| 9 import os |
| 10 import yaml |
| 11 |
| 12 |
| 13 SKY_TOOLS_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 14 SRC_ROOT = os.path.dirname(os.path.dirname(SKY_TOOLS_DIR)) |
| 15 SKY_SDK_DIR = os.path.join(SRC_ROOT, 'sky', 'sdk') |
| 16 SKY_PUBSPEC = os.path.join(SKY_SDK_DIR, 'pubspec.yaml') |
| 17 SKY_PUBSPEC_LOCK = os.path.join(SKY_SDK_DIR, 'pubspec.lock') |
| 18 SDK_EXT = os.path.join(SKY_SDK_DIR, 'lib', '_sdkext') |
| 19 |
| 20 SDK_EXT_TEMPLATE = '''{ |
| 21 "dart:sky": "%(build_dir)s/gen/dart-pkg/sky/sdk_ext/dart_sky.dart", |
| 22 "dart:sky.internals": "%(build_dir)s/gen/dart-pkg/sky/sky_internals.dart", |
| 23 "dart:sky_builtin_natvies": "%(build_dir)s../sdk_ext/builtin_natives.dart" |
| 24 }''' |
| 25 |
| 26 def version_for_pubspec(pubspec_path): |
| 27 with open(pubspec_path, 'r') as stream: |
| 28 dependency_spec = yaml.load(stream) |
| 29 return dependency_spec['version'] |
| 30 |
| 31 |
| 32 def entry_for_dependency(dart_pkg_dir, dependency): |
| 33 dependency_path = os.path.join(dart_pkg_dir, dependency) |
| 34 version = version_for_pubspec(os.path.join(dependency_path, 'pubspec.yaml')) |
| 35 return { |
| 36 'description': { |
| 37 'path': os.path.relpath(dependency_path, SKY_SDK_DIR), |
| 38 'relative': True, |
| 39 }, |
| 40 'source': 'path', |
| 41 'version': version, |
| 42 } |
| 43 |
| 44 |
| 45 def main(): |
| 46 parser = argparse.ArgumentParser(description='Adds files to the source tree
to make the dart analyzer happy') |
| 47 parser.add_argument('build_dir', type=str, help='Path the build directory to
use for build artifacts') |
| 48 args = parser.parse_args() |
| 49 |
| 50 dart_pkg_dir = os.path.join(args.build_dir, 'gen', 'dart-pkg') |
| 51 packages = {} |
| 52 |
| 53 with open(SKY_PUBSPEC, 'r') as stream: |
| 54 spec = yaml.load(stream) |
| 55 for dependency in spec['dependencies'].keys(): |
| 56 packages[dependency] = entry_for_dependency(dart_pkg_dir, dependency
) |
| 57 |
| 58 lock = { 'packages': packages } |
| 59 with open(SKY_PUBSPEC_LOCK, 'w') as stream: |
| 60 yaml.dump(lock, stream=stream, default_flow_style=False) |
| 61 |
| 62 with open(SDK_EXT, 'w') as stream: |
| 63 rebased_build_dir = os.path.relpath(args.build_dir, os.path.dirname(SDK_
EXT)) |
| 64 stream.write(SDK_EXT_TEMPLATE % { 'build_dir': rebased_build_dir }) |
| 65 |
| 66 |
| 67 if __name__ == '__main__': |
| 68 sys.exit(main()) |
OLD | NEW |