Dart: Adds mojom pub package.

Creates generate.dart script that installs generated .mojom.dart files into
the mojom pub package.

Updates Sky's deploy_sdk.py script to put mojom.dart files in locations where
they can be consumed by the generate.dart script once the SDK is published and
obtained via "pub get".

This CL is adapted from a patch by zra@google.com; most of the work here is his.

R=iposva@google.com

Review URL: https://codereview.chromium.org/1106383006
This commit is contained in:
Colin Blundell 2015-05-07 15:23:03 +02:00
parent 17c616b420
commit cff10ebf23

View File

@ -174,10 +174,27 @@ def main():
# Mojo package, lots of overlap with gen, must be copied: # Mojo package, lots of overlap with gen, must be copied:
copy(src_path('mojo/public'), sdk_path('packages/mojo/lib/public'), copy(src_path('mojo/public'), sdk_path('packages/mojo/lib/public'),
dart_filter) dart_filter)
mojom_dirs = [ os.path.join(build_dir, 'gen/dart-gen/mojom') ]
mojom_dirs += args.extra_mojom_dirs # By convention the generated .mojom.dart files in a pub package
for mojom_dir in mojom_dirs: # go under $PACKAGE/lib/mojom.
copy(mojom_dir, sdk_path('packages/mojom/lib/'), gen_filter) # The mojo package owns all the .mojom.dart files that are not in the 'sky'
# mojom module.
def non_sky_gen_filter(path):
if os.path.isdir(path) and path.endswith('sky'):
return False
return gen_filter(path)
mojo_package_mojom_dir = sdk_path('packages/mojo/lib/mojom')
copy(os.path.join(build_dir, 'gen/dart-gen/mojom'), mojo_package_mojom_dir,
non_sky_gen_filter)
# The Sky package owns the .mojom.dart files in the 'sky' mojom module.
def sky_gen_filter(path):
if os.path.isfile(path) and not os.path.dirname(path).endswith('sky'):
return False
return gen_filter(path)
sky_package_mojom_dir = sdk_path('packages/sky/lib/mojom')
copy(os.path.join(build_dir, 'gen/dart-gen/mojom'), sky_package_mojom_dir,
sky_gen_filter)
# Mojo SDK additions: # Mojo SDK additions:
copy_or_link(src_path('mojo/public/dart/bindings.dart'), copy_or_link(src_path('mojo/public/dart/bindings.dart'),
@ -205,11 +222,14 @@ def main():
ensure_dir_exists(packages_dir) ensure_dir_exists(packages_dir)
make_relative_symlink(sdk_path('packages/mojo/lib'), make_relative_symlink(sdk_path('packages/mojo/lib'),
os.path.join(packages_dir, 'mojo')) os.path.join(packages_dir, 'mojo'))
make_relative_symlink(sdk_path('packages/mojom/lib'),
os.path.join(packages_dir, 'mojom'))
make_relative_symlink(sdk_path('packages/sky/lib'), make_relative_symlink(sdk_path('packages/sky/lib'),
os.path.join(packages_dir, 'sky')) os.path.join(packages_dir, 'sky'))
mojom_dirs = [ mojo_package_mojom_dir, sky_package_mojom_dir ]
mojom_dirs += args.extra_mojom_dirs
for mojom_dir in mojom_dirs:
copy(mojom_dir, os.path.join(packages_dir, 'mojom'), gen_filter)
if should_commit: if should_commit:
# Kinda a hack to make a prettier build dir for the commit: # Kinda a hack to make a prettier build dir for the commit:
script_path = os.path.relpath(os.path.abspath(__file__), SRC_ROOT) script_path = os.path.relpath(os.path.abspath(__file__), SRC_ROOT)