Set the install name at link time for darwin dylibs (flutter/engine#13428)

This commit is contained in:
Dan Field
2019-10-29 20:30:13 -07:00
committed by GitHub
parent 07f337c540
commit 46bf911c59
4 changed files with 19 additions and 92 deletions

View File

@@ -42,6 +42,8 @@ shared_library("create_flutter_framework_dylib") {
output_name = "Flutter"
ldflags = [ "-Wl,-install_name,@rpath/Flutter.framework/Flutter" ]
sources = [
"framework/Source/FlutterAppDelegate.mm",
"framework/Source/FlutterAppDelegate_Internal.h",
@@ -137,13 +139,9 @@ shared_library("create_flutter_framework_dylib") {
]
}
action("copy_dylib_and_update_framework_install_name") {
copy("copy_dylib") {
visibility = [ ":*" ]
script = "$flutter_root/sky/tools/change_install_name.py"
inputs = [
script,
]
sources = [
"$root_out_dir/libFlutter.dylib",
]
@@ -151,15 +149,6 @@ action("copy_dylib_and_update_framework_install_name") {
"$_flutter_framework_dir/Flutter",
]
args = [
"--dylib",
rebase_path(sources[0]),
"--install_name",
"@rpath/Flutter.framework/Flutter",
"--output",
rebase_path(outputs[0]),
]
deps = [
":create_flutter_framework_dylib",
]
@@ -275,7 +264,7 @@ ios_app("FlutterTests") {
group("flutter_framework") {
deps = [
":copy_and_verify_framework_headers",
":copy_dylib_and_update_framework_install_name",
":copy_dylib",
":copy_framework_icu",
":copy_framework_info_plist",
":copy_framework_module_map",

View File

@@ -26,6 +26,7 @@ group("macos") {
_flutter_framework_name = "FlutterMacOS"
_flutter_framework_filename = "$_flutter_framework_name.framework"
_flutter_framework_dir = "$root_out_dir/$_flutter_framework_filename"
_framework_binary_subpath = "Versions/A/$_flutter_framework_name"
# The headers that will be copied to the framework and be accessed from outside
# the Flutter engine source root.
@@ -84,9 +85,10 @@ source_set("flutter_framework_source") {
shared_library("flutter_framework_dylib") {
visibility = [ ":*" ]
output_name = "$_flutter_framework_name"
ldflags = [ "-Wl,-install_name,@rpath/$_flutter_framework_filename/$_framework_binary_subpath" ]
deps = [
":flutter_framework_source",
]
@@ -119,28 +121,14 @@ executable("flutter_desktop_darwin_unittests") {
]
}
action("copy_dylib_and_update_framework_install_name") {
copy("copy_dylib") {
visibility = [ ":*" ]
script = "$flutter_root/sky/tools/change_install_name.py"
framework_binary_subpath = "Versions/A/$_flutter_framework_name"
inputs = [
script,
]
sources = [
"$root_out_dir/lib$_flutter_framework_name.dylib",
]
outputs = [
"$_flutter_framework_dir/$framework_binary_subpath",
]
args = [
"--dylib",
rebase_path(sources[0]),
"--install_name",
"@rpath/$_flutter_framework_filename/$framework_binary_subpath",
"--output",
rebase_path(outputs[0]),
"$_flutter_framework_dir/$_framework_binary_subpath",
]
deps = [
@@ -225,7 +213,7 @@ action("_generate_symlinks") {
"$_flutter_framework_name.stamp",
]
deps = [
":copy_dylib_and_update_framework_install_name",
":copy_dylib",
":copy_framework_headers",
":copy_framework_icu",
":copy_framework_info_plist",

View File

@@ -14,6 +14,8 @@ shell_gpu_configuration("embedder_gpu_configuration") {
enable_metal = false
}
_framework_binary_subpath = "Versions/A/FlutterEmbedder"
# Template for the embedder build. Used to allow building it multiple times with
# different flags.
template("embedder_source_set") {
@@ -138,6 +140,10 @@ shared_library("flutter_engine_library") {
output_name = "flutter_engine"
if (is_mac && !embedder_for_target) {
ldflags = [ "-Wl,-install_name,@rpath/FlutterEmbedder.framework/$_framework_binary_subpath" ]
}
deps = [
":embedder",
]
@@ -204,28 +210,14 @@ if (is_mac && !embedder_for_target) {
]
}
action("install_dylib") {
copy("copy_dylib") {
visibility = [ ":*" ]
script = "$flutter_root/sky/tools/change_install_name.py"
framework_binary_subpath = "Versions/A/FlutterEmbedder"
inputs = [
script,
]
sources = [
"$root_out_dir/libflutter_engine.dylib",
]
outputs = [
"$_flutter_embedder_framework_dir/$framework_binary_subpath",
]
args = [
"--dylib",
rebase_path(sources[0]),
"--install_name",
"@rpath/FlutterEmbedder.framework/$framework_binary_subpath",
"--output",
rebase_path(outputs[0]),
"$_flutter_embedder_framework_dir/$_framework_binary_subpath",
]
deps = [
@@ -253,11 +245,11 @@ if (is_mac && !embedder_for_target) {
"FlutterEmbedder.stamp",
]
deps = [
":copy_dylib",
":copy_framework_headers",
":copy_icu",
":copy_info_plist",
":copy_module_map",
":install_dylib",
]
}

View File

@@ -1,42 +0,0 @@
#!/usr/bin/env python
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import argparse
import subprocess
import sys
import os
def main():
parser = argparse.ArgumentParser(
description='Changes the install name of a dylib')
parser.add_argument('--dylib', type=str)
parser.add_argument('--install_name', type=str)
# install_name_tool operates in place, which can't be expressed in GN, so
# this tool copies to a new location first, then operates on the copy.
parser.add_argument('--output', type=str)
args = parser.parse_args()
subprocess.check_call([
'/usr/bin/env',
'cp',
'-fp',
args.dylib,
args.output,
])
subprocess.check_call([
'/usr/bin/env',
'xcrun',
'install_name_tool',
'-id',
args.install_name,
args.output,
])
if __name__ == '__main__':
sys.exit(main())