提交 dd17a112 编写于 作者: T Todd Volkert 提交者: GitHub

Make dylib filename configurable in Info.plist for iOS (#3277)

上级 bc4dac32
......@@ -26,6 +26,7 @@ struct Settings {
std::string aot_vm_isolate_snapshot_file_name;
std::string aot_instructions_blob_file_name;
std::string aot_rodata_blob_file_name;
std::string application_library_path;
std::string temp_directory_path;
std::vector<std::string> dart_flags;
......
......@@ -399,12 +399,20 @@ void* _DartSymbolLookup(const char* symbol_name) {
return nullptr;
}
const char* application_library_path = kDartApplicationLibraryPath;
const Settings& settings = Settings::Get();
const std::string& application_library_path_setting =
settings.application_library_path;
if (!application_library_path_setting.empty()) {
application_library_path = application_library_path_setting.c_str();
}
// First the application library is checked for the valid symbols. This
// library may not necessarily exist. If it does exist, it is loaded and the
// symbols resolved. Once the application library is loaded, there is
// currently no provision to unload the same.
void* symbol =
DartLookupSymbolInLibrary(symbol_name, kDartApplicationLibraryPath);
DartLookupSymbolInLibrary(symbol_name, application_library_path);
if (symbol != nullptr) {
return symbol;
}
......
......@@ -107,7 +107,8 @@ Shell::Shell() {
Shell::~Shell() {}
void Shell::InitStandalone(std::string icu_data_path) {
void Shell::InitStandalone(std::string icu_data_path,
std::string application_library_path) {
TRACE_EVENT0("flutter", "Shell::InitStandalone");
ftl::UniqueFD icu_fd(
......@@ -126,6 +127,7 @@ void Shell::InitStandalone(std::string icu_data_path) {
base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
blink::Settings settings;
settings.application_library_path = application_library_path;
// Enable Observatory
settings.enable_observatory =
......
......@@ -22,7 +22,8 @@ class Shell {
public:
~Shell();
static void InitStandalone(std::string icu_data_path = "");
static void InitStandalone(std::string icu_data_path = "",
std::string application_library_path = "");
static void Init();
static Shell& Shared();
......
......@@ -9,7 +9,10 @@
namespace shell {
void PlatformMacMain(int argc, const char* argv[], std::string icu_data_path);
void PlatformMacMain(int argc,
const char* argv[],
std::string icu_data_path,
std::string application_library_path);
bool AttemptLaunchFromCommandLineSwitches(Engine* engine);
......
......@@ -52,7 +52,10 @@ static void RedirectIOConnectionsToSyslog() {
class EmbedderState {
public:
EmbedderState(int argc, const char* argv[], std::string icu_data_path) {
EmbedderState(int argc,
const char* argv[],
std::string icu_data_path,
std::string application_library_path) {
#if TARGET_OS_IPHONE
// This calls crashes on MacOS because we haven't run Dart_Initialize yet.
// See https://github.com/flutter/flutter/issues/4006
......@@ -90,7 +93,7 @@ class EmbedderState {
embedder_message_loop_->Attach();
#endif
shell::Shell::InitStandalone(icu_data_path);
shell::Shell::InitStandalone(icu_data_path, application_library_path);
}
~EmbedderState() {
......@@ -106,12 +109,16 @@ class EmbedderState {
FTL_DISALLOW_COPY_AND_ASSIGN(EmbedderState);
};
void PlatformMacMain(int argc, const char* argv[], std::string icu_data_path) {
void PlatformMacMain(int argc,
const char* argv[],
std::string icu_data_path,
std::string application_library_path) {
static std::unique_ptr<EmbedderState> g_embedder;
static std::once_flag once_main;
std::call_once(once_main, [&]() {
g_embedder = WTF::MakeUnique<EmbedderState>(argc, argv, icu_data_path);
g_embedder = WTF::MakeUnique<EmbedderState>(argc, argv, icu_data_path,
application_library_path);
});
}
......
......@@ -32,7 +32,7 @@ void AttachMessageLoopToMainRunLoop(void) {
int main(int argc, const char* argv[]) {
[SkyApplication sharedApplication];
shell::PlatformMacMain(argc, argv, "");
shell::PlatformMacMain(argc, argv, "", "");
base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(shell::FlagForSwitch(shell::Switch::Help))) {
......
......@@ -58,7 +58,10 @@ class PlatformMessageResponseDarwin : public blink::PlatformMessageResponse {
void FlutterInit(int argc, const char* argv[]) {
NSBundle* bundle = [NSBundle bundleForClass:[FlutterViewController class]];
NSString* icuDataPath = [bundle pathForResource:@"icudtl" ofType:@"dat"];
shell::PlatformMacMain(argc, argv, icuDataPath.UTF8String);
NSString* libraryName =
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"FLTLibraryPath"];
shell::PlatformMacMain(argc, argv, icuDataPath.UTF8String,
libraryName != nil ? libraryName.UTF8String : "");
}
@implementation FlutterViewController {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册