From cff10ebf23f980062c306cebd7f617635dfff94c Mon Sep 17 00:00:00 2001 From: Colin Blundell Date: Thu, 7 May 2015 15:23:03 +0200 Subject: [PATCH] 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 --- engine/src/flutter/tools/deploy_sdk.py | 32 +++++++++++++++++++++----- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/engine/src/flutter/tools/deploy_sdk.py b/engine/src/flutter/tools/deploy_sdk.py index c510afedec..838afe8712 100755 --- a/engine/src/flutter/tools/deploy_sdk.py +++ b/engine/src/flutter/tools/deploy_sdk.py @@ -174,10 +174,27 @@ def main(): # Mojo package, lots of overlap with gen, must be copied: copy(src_path('mojo/public'), sdk_path('packages/mojo/lib/public'), dart_filter) - mojom_dirs = [ os.path.join(build_dir, 'gen/dart-gen/mojom') ] - mojom_dirs += args.extra_mojom_dirs - for mojom_dir in mojom_dirs: - copy(mojom_dir, sdk_path('packages/mojom/lib/'), gen_filter) + + # By convention the generated .mojom.dart files in a pub package + # go under $PACKAGE/lib/mojom. + # 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: copy_or_link(src_path('mojo/public/dart/bindings.dart'), @@ -205,11 +222,14 @@ def main(): ensure_dir_exists(packages_dir) make_relative_symlink(sdk_path('packages/mojo/lib'), 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'), 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: # Kinda a hack to make a prettier build dir for the commit: script_path = os.path.relpath(os.path.abspath(__file__), SRC_ROOT)