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

Unified Diff: mojo/public/tools/dart_pkg.py

Issue 1233493008: Generate Sky's _sdkext file using the build system (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 | « mojo/public/dart/rules.gni ('k') | sky/sdk/.gitignore » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/dart_pkg.py
diff --git a/mojo/public/tools/dart_pkg.py b/mojo/public/tools/dart_pkg.py
index 6e472f315ccbc9bfd7b476b72b3f15fdee70c888..dfd83921184cda68ffabf0d07c1f1becac24593d 100755
--- a/mojo/public/tools/dart_pkg.py
+++ b/mojo/public/tools/dart_pkg.py
@@ -8,6 +8,7 @@
import argparse
import errno
+import json
import os
import shutil
import sys
@@ -105,6 +106,13 @@ def copy_or_link(from_root, to_root, filter_func=None):
copy(from_root, to_root, filter_func)
+def remove_if_exists(path):
+ try:
+ os.remove(path)
+ except OSError as e:
+ if e.errno != errno.ENOENT:
+ raise
+
def list_files(from_root, filter_func=None):
file_list = []
for root, dirs, files in os.walk(from_root):
@@ -192,13 +200,33 @@ def main():
help='List of .dart files that are part of of sdk_ext.',
nargs='*',
default=[])
+ parser.add_argument('--sdk-ext-mappings',
+ metavar='sdk_ext_mappings',
+ help='Mappings for SDK extension libraries.',
+ nargs='*',
+ default=[])
args = parser.parse_args()
# We must have a pubspec.yaml.
assert has_pubspec_yaml(args.package_sources)
- # Copy or symlink package sources into pkg directory.
target_dir = os.path.join(args.pkg_directory, args.package_name)
+ lib_path = os.path.join(target_dir, "lib")
+
+ mappings = {}
+ for mapping in args.sdk_ext_mappings:
+ library, path = mapping.split(',', 1)
+ mappings[library] = '../sdk_ext/%s' % path
+
+ sdkext_path = os.path.join(lib_path, '_sdkext')
+ if mappings:
+ with open(sdkext_path, 'w') as stream:
+ json.dump(mappings, stream, sort_keys=True,
+ indent=2, separators=(',', ': '))
+ else:
+ remove_if_exists(sdkext_path)
+
+ # Copy or symlink package sources into pkg directory.
common_source_prefix = os.path.commonprefix(args.package_sources)
for source in args.package_sources:
relative_source = os.path.relpath(source, common_source_prefix)
@@ -220,7 +248,6 @@ def main():
target = os.path.join(sdk_ext_dir, relative_source)
copy_or_link(source, target)
- lib_path = os.path.join(target_dir, "lib")
lib_mojom_path = os.path.join(lib_path, "mojom")
# Copy generated mojom.dart files.
« no previous file with comments | « mojo/public/dart/rules.gni ('k') | sky/sdk/.gitignore » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698