From a9721eb9d8be568e38c49e7a20473e75af987033 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Fri, 27 Oct 2017 17:31:13 -0700 Subject: [PATCH] Allow embedders to specify custom ICU data paths and command line args. (flutter/engine#4290) --- .../shell/platform/embedder/embedder.cc | 19 ++++++++++++++++--- .../shell/platform/embedder/embedder.h | 13 +++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/engine/src/flutter/shell/platform/embedder/embedder.cc b/engine/src/flutter/shell/platform/embedder/embedder.cc index f971c1be2a..e97ddc1cc5 100644 --- a/engine/src/flutter/shell/platform/embedder/embedder.cc +++ b/engine/src/flutter/shell/platform/embedder/embedder.cc @@ -100,13 +100,26 @@ FlutterResult FlutterEngineRun(size_t version, return ptr(user_data); }; + std::string icu_data_path; + if (SAFE_ACCESS(args, icu_data_path, nullptr) != nullptr) { + icu_data_path = SAFE_ACCESS(args, icu_data_path, nullptr); + } + + fxl::CommandLine command_line; + if (SAFE_ACCESS(args, command_line_argc, 0) != 0 && + SAFE_ACCESS(args, command_line_argv, nullptr) != nullptr) { + command_line = fxl::CommandLineFromArgcArgv( + SAFE_ACCESS(args, command_line_argc, 0), + SAFE_ACCESS(args, command_line_argv, nullptr)); + } + static std::once_flag once_shell_initialization; std::call_once(once_shell_initialization, [&]() { fxl::CommandLine null_command_line; shell::Shell::InitStandalone( - fxl::CommandLine{}, - "", // icu data path default lookup. - "" // application library not supported in JIT mode. + std::move(command_line), + icu_data_path, // icu data path default lookup. + "" // application library not supported in JIT mode. ); }); diff --git a/engine/src/flutter/shell/platform/embedder/embedder.h b/engine/src/flutter/shell/platform/embedder/embedder.h index 4dcb2cb09a..1d7e193a56 100644 --- a/engine/src/flutter/shell/platform/embedder/embedder.h +++ b/engine/src/flutter/shell/platform/embedder/embedder.h @@ -65,6 +65,19 @@ typedef struct { // after the call to |FlutterEngineRun| returns. The string must be NULL // terminated. const char* packages_path; + // The path to the icudtl.dat file for the project. The string can be + // collected after the call to |FlutterEngineRun| returns. The string must + // be NULL terminated. + const char* icu_data_path; + // The command line argument count used to initialize the project. The string + // can be collected after the call to |FlutterEngineRun| returns. The string + // must be NULL terminated. + int command_line_argc; + // The command line arguments used to initialize the project. The strings can + // be collected after the call to |FlutterEngineRun| returns. The strings must + // be NULL terminated. + const char* const* command_line_argv; + } FlutterProjectArgs; typedef struct {