Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: sky/tools/setup-dart-analyzer

Issue 1227913007: Add a script to setup source tree for Dart analyzer (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/sdk/pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/tools/setup-dart-analyzer
diff --git a/sky/tools/setup-dart-analyzer b/sky/tools/setup-dart-analyzer
new file mode 100755
index 0000000000000000000000000000000000000000..434774e5a5015526a820b976eddee224c2f12d8c
--- /dev/null
+++ b/sky/tools/setup-dart-analyzer
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import argparse
+import subprocess
+import sys
+import os
+import yaml
+
+
+SKY_TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
+SRC_ROOT = os.path.dirname(os.path.dirname(SKY_TOOLS_DIR))
+SKY_SDK_DIR = os.path.join(SRC_ROOT, 'sky', 'sdk')
+SKY_PUBSPEC = os.path.join(SKY_SDK_DIR, 'pubspec.yaml')
+SKY_PUBSPEC_LOCK = os.path.join(SKY_SDK_DIR, 'pubspec.lock')
+SDK_EXT = os.path.join(SKY_SDK_DIR, 'lib', '_sdkext')
+
+SDK_EXT_TEMPLATE = '''{
+ "dart:sky": "%(build_dir)s/gen/dart-pkg/sky/sdk_ext/dart_sky.dart",
+ "dart:sky.internals": "%(build_dir)s/gen/dart-pkg/sky/sky_internals.dart",
+ "dart:sky_builtin_natvies": "%(build_dir)s../sdk_ext/builtin_natives.dart"
+}'''
+
+def version_for_pubspec(pubspec_path):
+ with open(pubspec_path, 'r') as stream:
+ dependency_spec = yaml.load(stream)
+ return dependency_spec['version']
+
+
+def entry_for_dependency(dart_pkg_dir, dependency):
+ dependency_path = os.path.join(dart_pkg_dir, dependency)
+ version = version_for_pubspec(os.path.join(dependency_path, 'pubspec.yaml'))
+ return {
+ 'description': {
+ 'path': os.path.relpath(dependency_path, SKY_SDK_DIR),
+ 'relative': True,
+ },
+ 'source': 'path',
+ 'version': version,
+ }
+
+
+def main():
+ parser = argparse.ArgumentParser(description='Adds files to the source tree to make the dart analyzer happy')
+ parser.add_argument('build_dir', type=str, help='Path the build directory to use for build artifacts')
+ args = parser.parse_args()
+
+ dart_pkg_dir = os.path.join(args.build_dir, 'gen', 'dart-pkg')
+ packages = {}
+
+ with open(SKY_PUBSPEC, 'r') as stream:
+ spec = yaml.load(stream)
+ for dependency in spec['dependencies'].keys():
+ packages[dependency] = entry_for_dependency(dart_pkg_dir, dependency)
+
+ lock = { 'packages': packages }
+ with open(SKY_PUBSPEC_LOCK, 'w') as stream:
+ yaml.dump(lock, stream=stream, default_flow_style=False)
+
+ with open(SDK_EXT, 'w') as stream:
+ rebased_build_dir = os.path.relpath(args.build_dir, os.path.dirname(SDK_EXT))
+ stream.write(SDK_EXT_TEMPLATE % { 'build_dir': rebased_build_dir })
+
+
+if __name__ == '__main__':
+ sys.exit(main())
« no previous file with comments | « sky/sdk/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698