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

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

Issue 1310103002: Update mojo sdk to rev c02a28868825edfa57ab77947b8cb15e741c5598 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 | « third_party/mojo/src/mojo/public/tools/bindings/generators/python_templates/module_macros.tmpl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/mojo/src/mojo/public/tools/dart_pkg.py
diff --git a/third_party/mojo/src/mojo/public/tools/dart_pkg.py b/third_party/mojo/src/mojo/public/tools/dart_pkg.py
index d0f0d6ebb18b767bd5eadfbfdbdab602a40691c7..86ae5d5b83c36ad3eeed10bdbbf916daa853cd27 100755
--- a/third_party/mojo/src/mojo/public/tools/dart_pkg.py
+++ b/third_party/mojo/src/mojo/public/tools/dart_pkg.py
@@ -8,6 +8,7 @@
import argparse
import errno
+import json
import os
import shutil
import sys
@@ -47,8 +48,9 @@ def mojom_filter(path):
def ensure_dir_exists(path):
- if not os.path.exists(path):
- os.makedirs(path)
+ abspath = os.path.abspath(path)
+ if not os.path.exists(abspath):
+ os.makedirs(abspath)
def has_pubspec_yaml(paths):
@@ -105,6 +107,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):
@@ -187,13 +196,39 @@ def main():
help='Directory containing .dart sources',
nargs='*',
default=[])
+ parser.add_argument('--sdk-ext-files',
+ metavar='sdk_ext_files',
+ 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:
+ ensure_dir_exists(lib_path)
+ 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)
@@ -209,8 +244,12 @@ def main():
relative_source = os.path.relpath(source, common_prefix)
target = os.path.join(sdk_ext_dir, relative_source)
copy_or_link(source, target)
+ for source in args.sdk_ext_files:
+ common_prefix = os.path.commonprefix(args.sdk_ext_files)
+ relative_source = os.path.relpath(source, common_prefix)
+ 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 | « third_party/mojo/src/mojo/public/tools/bindings/generators/python_templates/module_macros.tmpl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698