Skip to content

Commit

Permalink
Setup GN rules to package embedder dylib as a Mac framework where sup…
Browse files Browse the repository at this point in the history
…ported. (flutter#4270)
  • Loading branch information
chinmaygarde authored Oct 24, 2017
1 parent 16f6d3f commit 052a257
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 12 deletions.
10 changes: 7 additions & 3 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand Down Expand Up @@ -64,7 +66,9 @@ if (is_fuchsia) {

package_name = "flutter"

deps = [ ":flutter" ]
deps = [
":flutter",
]

binaries = [
{
Expand Down
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
129 changes: 121 additions & 8 deletions shell/platform/embedder/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,141 @@ 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") {
deps = [
":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",
]
}
}
28 changes: 28 additions & 0 deletions shell/platform/embedder/EmbedderInfo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>FlutterEmbedder</string>
<key>CFBundleIdentifier</key>
<string>io.flutter.flutter_embedder</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>FlutterEmbedder</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright 2017 The Flutter Authors. All rights reserved.</string>
</dict>
</plist>
6 changes: 6 additions & 0 deletions shell/platform/embedder/embedder.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
framework module FlutterEmbedder {
umbrella header "FlutterEmbedder.h"

export *
module * { export * }
}
2 changes: 2 additions & 0 deletions travis/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 052a257

Please sign in to comment.