mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Plumb through Dart entrypoint arguments on the Linux embedder (#21933)
This commit is contained in:
parent
1358f13c2f
commit
fc72bd2ada
@ -19,6 +19,7 @@ struct _FlDartProject {
|
||||
gchar* aot_library_path;
|
||||
gchar* assets_path;
|
||||
gchar* icu_data_path;
|
||||
gchar** dart_entrypoint_args;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(FlDartProject, fl_dart_project, G_TYPE_OBJECT)
|
||||
@ -42,6 +43,7 @@ static void fl_dart_project_dispose(GObject* object) {
|
||||
g_clear_pointer(&self->aot_library_path, g_free);
|
||||
g_clear_pointer(&self->assets_path, g_free);
|
||||
g_clear_pointer(&self->icu_data_path, g_free);
|
||||
g_clear_pointer(&self->dart_entrypoint_args, g_strfreev);
|
||||
|
||||
G_OBJECT_CLASS(fl_dart_project_parent_class)->dispose(object);
|
||||
}
|
||||
@ -98,6 +100,20 @@ G_MODULE_EXPORT const gchar* fl_dart_project_get_icu_data_path(
|
||||
return self->icu_data_path;
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT gchar** fl_dart_project_get_dart_entrypoint_arguments(
|
||||
FlDartProject* self) {
|
||||
g_return_val_if_fail(FL_IS_DART_PROJECT(self), nullptr);
|
||||
return self->dart_entrypoint_args;
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void fl_dart_project_set_dart_entrypoint_arguments(
|
||||
FlDartProject* self,
|
||||
char** argv) {
|
||||
g_return_if_fail(FL_IS_DART_PROJECT(self));
|
||||
g_clear_pointer(&self->dart_entrypoint_args, g_strfreev);
|
||||
self->dart_entrypoint_args = g_strdupv(argv);
|
||||
}
|
||||
|
||||
GPtrArray* fl_dart_project_get_switches(FlDartProject* self) {
|
||||
GPtrArray* switches = g_ptr_array_new_with_free_func(g_free);
|
||||
std::vector<std::string> env_switches = flutter::GetSwitchesFromEnvironment();
|
||||
|
||||
@ -381,6 +381,9 @@ gboolean fl_engine_start(FlEngine* self, GError** error) {
|
||||
// so that all switches are used.
|
||||
g_ptr_array_insert(command_line_args, 0, g_strdup("flutter"));
|
||||
|
||||
gchar** dart_entrypoint_args =
|
||||
fl_dart_project_get_dart_entrypoint_arguments(self->project);
|
||||
|
||||
FlutterProjectArgs args = {};
|
||||
args.struct_size = sizeof(FlutterProjectArgs);
|
||||
args.assets_path = fl_dart_project_get_assets_path(self->project);
|
||||
@ -391,6 +394,9 @@ gboolean fl_engine_start(FlEngine* self, GError** error) {
|
||||
args.platform_message_callback = fl_engine_platform_message_cb;
|
||||
args.custom_task_runners = &custom_task_runners;
|
||||
args.shutdown_dart_vm_when_done = true;
|
||||
args.dart_entrypoint_argc = g_strv_length(dart_entrypoint_args);
|
||||
args.dart_entrypoint_argv =
|
||||
reinterpret_cast<const char* const*>(dart_entrypoint_args);
|
||||
|
||||
if (FlutterEngineRunsAOTCompiledDartCode()) {
|
||||
FlutterEngineAOTDataSource source = {};
|
||||
|
||||
@ -96,6 +96,30 @@ const gchar* fl_dart_project_get_assets_path(FlDartProject* project);
|
||||
*/
|
||||
const gchar* fl_dart_project_get_icu_data_path(FlDartProject* project);
|
||||
|
||||
/**
|
||||
* fl_dart_project_set_dart_entrypoint_arguments:
|
||||
* @project: an #FlDartProject.
|
||||
* @argv: a pointer to a NULL-terminated array of C strings containing the
|
||||
* command line arguments.
|
||||
*
|
||||
* Sets the command line arguments to be passed through to the Dart
|
||||
* entrypoint function.
|
||||
*/
|
||||
void fl_dart_project_set_dart_entrypoint_arguments(FlDartProject* project,
|
||||
char** argv);
|
||||
|
||||
/**
|
||||
* fl_dart_project_get_dart_entrypoint_arguments:
|
||||
* @project: an #FlDartProject.
|
||||
*
|
||||
* Gets the command line arguments to be passed through to the Dart entrypoint
|
||||
* function.
|
||||
*
|
||||
* Returns: a NULL-terminated array of strings containing the command line
|
||||
* arguments to be passed to the Dart entrypoint.
|
||||
*/
|
||||
gchar** fl_dart_project_get_dart_entrypoint_arguments(FlDartProject* project);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_DART_PROJECT_H_
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user