Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[linux] Allow overriding asset, ICU data path #38296

Merged
merged 1 commit into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions shell/platform/linux/fl_dart_project.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,26 @@ G_MODULE_EXPORT const gchar* fl_dart_project_get_aot_library_path(
return self->aot_library_path;
}

G_MODULE_EXPORT void fl_dart_project_set_assets_path(FlDartProject* self,
gchar* path) {
g_return_if_fail(FL_IS_DART_PROJECT(self));
g_clear_pointer(&self->assets_path, g_free);
self->assets_path = g_strdup(path);
}

G_MODULE_EXPORT const gchar* fl_dart_project_get_assets_path(
FlDartProject* self) {
g_return_val_if_fail(FL_IS_DART_PROJECT(self), nullptr);
return self->assets_path;
}

G_MODULE_EXPORT void fl_dart_project_set_icu_data_path(FlDartProject* self,
gchar* path) {
g_return_if_fail(FL_IS_DART_PROJECT(self));
g_clear_pointer(&self->icu_data_path, g_free);
self->icu_data_path = g_strdup(path);
}

G_MODULE_EXPORT const gchar* fl_dart_project_get_icu_data_path(
FlDartProject* self) {
g_return_val_if_fail(FL_IS_DART_PROJECT(self), nullptr);
Expand Down
16 changes: 16 additions & 0 deletions shell/platform/linux/fl_dart_project_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ TEST(FlDartProjectTest, EnableMirrors) {
G_GNUC_END_IGNORE_DEPRECATIONS
}

TEST(FlDartProjectTest, OverrideAssetsPath) {
g_autoptr(FlDartProject) project = fl_dart_project_new();

char assets_path[] = "/normal/tuesday/night/for/shia/labeouf";
fl_dart_project_set_assets_path(project, assets_path);
EXPECT_STREQ(fl_dart_project_get_assets_path(project), assets_path);
}

TEST(FlDartProjectTest, OverrideIcuDataPath) {
g_autoptr(FlDartProject) project = fl_dart_project_new();

char icu_data_path[] = "/living/in/the/woods/icudtl.dat";
fl_dart_project_set_icu_data_path(project, icu_data_path);
EXPECT_STREQ(fl_dart_project_get_icu_data_path(project), icu_data_path);
}

TEST(FlDartProjectTest, DartEntrypointArgs) {
g_autoptr(FlDartProject) project = fl_dart_project_new();

Expand Down
21 changes: 21 additions & 0 deletions shell/platform/linux/public/flutter_linux/fl_dart_project.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ gboolean fl_dart_project_get_enable_mirrors(FlDartProject* project)
*/
const gchar* fl_dart_project_get_aot_library_path(FlDartProject* project);

/**
* fl_dart_project_set_assets_path:
* @project: an #FlDartProject.
* @path: the absolute path to the assets directory.
*
* Sets the path to the directory containing the assets used in the Flutter
* application. By default, this is the data/flutter_assets subdirectory
* relative to the executable directory.
*/
void fl_dart_project_set_assets_path(FlDartProject* project, gchar* path);

/**
* fl_dart_project_get_assets_path:
* @project: an #FlDartProject.
Expand All @@ -85,6 +96,16 @@ const gchar* fl_dart_project_get_aot_library_path(FlDartProject* project);
*/
const gchar* fl_dart_project_get_assets_path(FlDartProject* project);

/**
* fl_dart_project_set_icu_data_path:
* @project: an #FlDartProject.
* @path: the absolute path to the ICU data file.
*
* Sets the path to the ICU data file used in the Flutter application. By
* default, this is data/icudtl.dat relative to the executable directory.
*/
void fl_dart_project_set_icu_data_path(FlDartProject* project, gchar* path);

/**
* fl_dart_project_get_icu_data_path:
* @project: an #FlDartProject.
Expand Down