From 052a257974edf10e5e117646fe4221cf39988aee Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Tue, 24 Oct 2017 12:50:13 -0700 Subject: [PATCH] Setup GN rules to package embedder dylib as a Mac framework where supported. (#4270) --- BUILD.gn | 10 +- DEPS | 2 +- shell/platform/embedder/BUILD.gn | 129 +++++++++++++++++++-- shell/platform/embedder/EmbedderInfo.plist | 28 +++++ shell/platform/embedder/embedder.modulemap | 6 + travis/licenses_golden/licenses_flutter | 2 + 6 files changed, 165 insertions(+), 12 deletions(-) create mode 100644 shell/platform/embedder/EmbedderInfo.plist create mode 100644 shell/platform/embedder/embedder.modulemap diff --git a/BUILD.gn b/BUILD.gn index 05e3bff18c31c..a60a66092a54f 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -33,8 +33,10 @@ group("flutter") { # If on the host, compile all unittests targets. if (current_toolchain == host_toolchain) { if (is_mac) { - public_deps += - [ "$flutter_root/shell/platform/darwin:flutter_channels_unittests" ] + public_deps += [ + "$flutter_root/shell/platform/darwin:flutter_channels_unittests", + "$flutter_root/shell/platform/embedder:flutter_embedder_framework", + ] } if (!is_win) { public_deps += [ "$flutter_root/shell/platform/embedder:flutter_engine" ] @@ -64,7 +66,9 @@ if (is_fuchsia) { package_name = "flutter" - deps = [ ":flutter" ] + deps = [ + ":flutter", + ] binaries = [ { diff --git a/DEPS b/DEPS index 231e05c5a7cd9..20ede147177b5 100644 --- a/DEPS +++ b/DEPS @@ -114,7 +114,7 @@ allowed_hosts = [ ] deps = { - 'src': 'https://github.com/flutter/buildroot.git' + '@' + 'fcb277b9b2f78b5b59cda0a0b15edfc5f5578807', + 'src': 'https://github.com/flutter/buildroot.git' + '@' + '77c6728e5ac9fc7d08b163ed5bf8bc64fc463f21', # Fuchsia compatibility # diff --git a/shell/platform/embedder/BUILD.gn b/shell/platform/embedder/BUILD.gn index bfe5c7a9ad6ff..39d7014904e01 100644 --- a/shell/platform/embedder/BUILD.gn +++ b/shell/platform/embedder/BUILD.gn @@ -12,20 +12,18 @@ source_set("embedder") { ] deps = [ - "//third_party/dart/runtime:libdart_jit", - "//third_party/dart/runtime/bin:embedded_dart_io", "$flutter_root/common", "$flutter_root/fml", "$flutter_root/shell/common", "$flutter_root/shell/gpu", "//garnet/public/lib/fxl", + "//third_party/dart/runtime:libdart_jit", + "//third_party/dart/runtime/bin:embedded_dart_io", "//third_party/skia", "//topaz/lib/tonic", ] - public_configs = [ - "$flutter_root:config", - ] + public_configs = [ "$flutter_root:config" ] } shared_library("flutter_engine") { @@ -33,7 +31,122 @@ shared_library("flutter_engine") { ":embedder", ] - public_configs = [ - "$flutter_root:config", - ] + public_configs = [ "$flutter_root:config" ] +} + +if (is_mac) { + _flutter_embedder_framework_dir = "$root_out_dir/FlutterEmbedder.framework" + + copy("copy_dylib") { + visibility = [ ":*" ] + sources = [ + "$root_out_dir/libflutter_engine.dylib", + ] + outputs = [ + "$_flutter_embedder_framework_dir/Versions/A/FlutterEmbedder", + ] + deps = [ + ":flutter_engine", + ] + } + + copy("copy_headers") { + visibility = [ ":*" ] + sources = [ + "embedder.h", + ] + outputs = [ + "$_flutter_embedder_framework_dir/Versions/A/Headers/FlutterEmbedder.h", + ] + } + + copy("copy_icu") { + visibility = [ ":*" ] + sources = [ + "//third_party/icu/common/icudtl.dat", + ] + outputs = [ + "$_flutter_embedder_framework_dir/Versions/A/Resources/icudtl.dat", + ] + } + + copy("copy_info_plist") { + visibility = [ ":*" ] + sources = [ + "EmbedderInfo.plist", + ] + outputs = [ + "$_flutter_embedder_framework_dir/Versions/A/Resources/Info.plist", + ] + } + + copy("copy_module_map") { + visibility = [ ":*" ] + sources = [ + "embedder.modulemap", + ] + outputs = [ + "$_flutter_embedder_framework_dir/Versions/A/Modules/module.modulemap", + ] + } + + action("install_dylib") { + visibility = [ ":*" ] + stamp_file = "$root_build_dir/flutter_embedder_install_name_stamp" + script = "$flutter_root/sky/tools/change_install_name.py" + + inputs = [ + "$_flutter_embedder_framework_dir/Versions/A/FlutterEmbedder", + ] + + outputs = [ + stamp_file, + ] + + args = [ + "--dylib", + "FlutterEmbedder.framework/Versions/A/FlutterEmbedder", + "--install_name", + "@rpath/FlutterEmbedder.framework/Versions/A/FlutterEmbedder", + "--stamp", + rebase_path(stamp_file), + ] + + deps = [ + ":copy_dylib", + ] + } + + action("generate_symlinks") { + script = "//build/config/mac/package_framework.py" + outputs = [ + "$root_build_dir/FlutterEmbedder.stamp", + ] + args = [ + "--framework", + "FlutterEmbedder.framework", + "--version", + "A", + "--contents", + "FlutterEmbedder", + "Resources", + "Headers", + "Modules", + "--stamp", + "FlutterEmbedder.stamp", + ] + deps = [ + ":copy_headers", + ":copy_icu", + ":copy_info_plist", + ":copy_module_map", + ":install_dylib", + ] + } + + group("flutter_embedder_framework") { + deps = [ + ":generate_symlinks", + ] + } } diff --git a/shell/platform/embedder/EmbedderInfo.plist b/shell/platform/embedder/EmbedderInfo.plist new file mode 100644 index 0000000000000..38352b319ff5b --- /dev/null +++ b/shell/platform/embedder/EmbedderInfo.plist @@ -0,0 +1,28 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + FlutterEmbedder + CFBundleIdentifier + io.flutter.flutter_embedder + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + FlutterEmbedder + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSupportedPlatforms + + MacOSX + + CFBundleVersion + 1 + NSHumanReadableCopyright + Copyright 2017 The Flutter Authors. All rights reserved. + + diff --git a/shell/platform/embedder/embedder.modulemap b/shell/platform/embedder/embedder.modulemap new file mode 100644 index 0000000000000..60328fe17e31b --- /dev/null +++ b/shell/platform/embedder/embedder.modulemap @@ -0,0 +1,6 @@ +framework module FlutterEmbedder { + umbrella header "FlutterEmbedder.h" + + export * + module * { export * } +} diff --git a/travis/licenses_golden/licenses_flutter b/travis/licenses_golden/licenses_flutter index d7a85169d91bc..9a9555293026e 100644 --- a/travis/licenses_golden/licenses_flutter +++ b/travis/licenses_golden/licenses_flutter @@ -1254,6 +1254,8 @@ FILE: ../../../flutter/shell/platform/darwin/desktop/flutter_mac.xib FILE: ../../../flutter/shell/platform/darwin/ios/framework/Flutter.podspec FILE: ../../../flutter/shell/platform/darwin/ios/framework/Info.plist FILE: ../../../flutter/shell/platform/darwin/ios/framework/module.modulemap +FILE: ../../../flutter/shell/platform/embedder/EmbedderInfo.plist +FILE: ../../../flutter/shell/platform/embedder/embedder.modulemap FILE: ../../../flutter/sky/engine/core/editing/CompositionUnderlineRangeFilter.cpp FILE: ../../../flutter/sky/engine/core/editing/CompositionUnderlineRangeFilter.h FILE: ../../../flutter/sky/engine/core/editing/PositionWithAffinity.cpp