未验证 提交 f267ef58 编写于 作者: R Robert Ancell 提交者: GitHub

Add a flag to enable dart:mirrors (#19112)

Fixes https://github.com/flutter/flutter/issues/59233
上级 760366b4
......@@ -9,6 +9,7 @@
struct _FlDartProject {
GObject parent_instance;
gboolean enable_mirrors;
gchar* aot_library_path;
gchar* assets_path;
gchar* icu_data_path;
......@@ -60,6 +61,19 @@ G_MODULE_EXPORT FlDartProject* fl_dart_project_new() {
return self;
}
G_MODULE_EXPORT void fl_dart_project_set_enable_mirrors(
FlDartProject* self,
gboolean enable_mirrors) {
g_return_if_fail(FL_IS_DART_PROJECT(self));
self->enable_mirrors = enable_mirrors;
}
G_MODULE_EXPORT gboolean
fl_dart_project_get_enable_mirrors(FlDartProject* self) {
g_return_val_if_fail(FL_IS_DART_PROJECT(self), FALSE);
return self->enable_mirrors;
}
G_MODULE_EXPORT const gchar* fl_dart_project_get_aot_library_path(
FlDartProject* self) {
g_return_val_if_fail(FL_IS_DART_PROJECT(self), nullptr);
......
......@@ -24,3 +24,12 @@ TEST(FlDartProjectTest, GetPaths) {
EXPECT_STREQ(fl_dart_project_get_icu_data_path(project),
expected_icu_data_path);
}
TEST(FlDartProjectTest, EnableMirrors) {
g_autoptr(FlDartProject) project = fl_dart_project_new();
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
EXPECT_FALSE(fl_dart_project_get_enable_mirrors(project));
fl_dart_project_set_enable_mirrors(project, TRUE);
EXPECT_TRUE(fl_dart_project_get_enable_mirrors(project));
G_GNUC_END_IGNORE_DEPRECATIONS
}
......@@ -274,10 +274,24 @@ gboolean fl_engine_start(FlEngine* self, GError** error) {
custom_task_runners.struct_size = sizeof(FlutterCustomTaskRunners);
custom_task_runners.platform_task_runner = &platform_task_runner;
g_autoptr(GPtrArray) command_line_args =
g_ptr_array_new_with_free_func(g_free);
g_ptr_array_add(command_line_args, g_strdup("flutter"));
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gboolean enable_mirrors = fl_dart_project_get_enable_mirrors(self->project);
G_GNUC_END_IGNORE_DEPRECATIONS
if (enable_mirrors) {
g_ptr_array_add(command_line_args,
g_strdup("--dart-flags=--enable_mirrors=true"));
}
FlutterProjectArgs args = {};
args.struct_size = sizeof(FlutterProjectArgs);
args.assets_path = fl_dart_project_get_assets_path(self->project);
args.icu_data_path = fl_dart_project_get_icu_data_path(self->project);
args.command_line_argc = command_line_args->len;
args.command_line_argv =
reinterpret_cast<const char* const*>(command_line_args->pdata);
args.platform_message_callback = fl_engine_platform_message_cb;
args.custom_task_runners = &custom_task_runners;
args.shutdown_dart_vm_when_done = true;
......
......@@ -35,6 +35,33 @@ G_DECLARE_FINAL_TYPE(FlDartProject, fl_dart_project, FL, DART_PROJECT, GObject)
*/
FlDartProject* fl_dart_project_new();
/**
* fl_dart_project_set_enable_mirrors:
* @project: an #FlDartProject.
* @enable_mirrors: %TRUE if the dart:mirrors library should be used.
*
* Sets if this Flutter project can use the dart:mirrors library.
*
* Deprecated: This function is temporary and will be removed in a future
* release.
*/
void fl_dart_project_set_enable_mirrors(FlDartProject* project,
gboolean enable_mirrors) G_DEPRECATED;
/**
* fl_dart_project_get_enable_mirrors:
* @project: an #FlDartProject.
*
* Gets if this Flutter project can use the dart:mirrors library.
*
* Returns: %TRUE if the dart:mirrors library can be used.
*
* Deprecated: This function is temporary and will be removed in a future
* release.
*/
gboolean fl_dart_project_get_enable_mirrors(FlDartProject* project)
G_DEPRECATED;
/**
* fl_dart_project_get_aot_library_path:
* @project: an #FlDartProject.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册