Skip to content

Commit 881c130

Browse files
cbrackenloic-sharma
authored andcommitted
[linux] Allow overriding asset, ICU data path (flutter#38296)
Support setting a custom asset directory and ICU data path. Fixes: flutter/flutter#117103 Issue: flutter/flutter#117102
1 parent 14dd501 commit 881c130

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

shell/platform/linux/fl_dart_project.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,26 @@ G_MODULE_EXPORT const gchar* fl_dart_project_get_aot_library_path(
8888
return self->aot_library_path;
8989
}
9090

91+
G_MODULE_EXPORT void fl_dart_project_set_assets_path(FlDartProject* self,
92+
gchar* path) {
93+
g_return_if_fail(FL_IS_DART_PROJECT(self));
94+
g_clear_pointer(&self->assets_path, g_free);
95+
self->assets_path = g_strdup(path);
96+
}
97+
9198
G_MODULE_EXPORT const gchar* fl_dart_project_get_assets_path(
9299
FlDartProject* self) {
93100
g_return_val_if_fail(FL_IS_DART_PROJECT(self), nullptr);
94101
return self->assets_path;
95102
}
96103

104+
G_MODULE_EXPORT void fl_dart_project_set_icu_data_path(FlDartProject* self,
105+
gchar* path) {
106+
g_return_if_fail(FL_IS_DART_PROJECT(self));
107+
g_clear_pointer(&self->icu_data_path, g_free);
108+
self->icu_data_path = g_strdup(path);
109+
}
110+
97111
G_MODULE_EXPORT const gchar* fl_dart_project_get_icu_data_path(
98112
FlDartProject* self) {
99113
g_return_val_if_fail(FL_IS_DART_PROJECT(self), nullptr);

shell/platform/linux/fl_dart_project_test.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ TEST(FlDartProjectTest, EnableMirrors) {
3838
G_GNUC_END_IGNORE_DEPRECATIONS
3939
}
4040

41+
TEST(FlDartProjectTest, OverrideAssetsPath) {
42+
g_autoptr(FlDartProject) project = fl_dart_project_new();
43+
44+
char assets_path[] = "/normal/tuesday/night/for/shia/labeouf";
45+
fl_dart_project_set_assets_path(project, assets_path);
46+
EXPECT_STREQ(fl_dart_project_get_assets_path(project), assets_path);
47+
}
48+
49+
TEST(FlDartProjectTest, OverrideIcuDataPath) {
50+
g_autoptr(FlDartProject) project = fl_dart_project_new();
51+
52+
char icu_data_path[] = "/living/in/the/woods/icudtl.dat";
53+
fl_dart_project_set_icu_data_path(project, icu_data_path);
54+
EXPECT_STREQ(fl_dart_project_get_icu_data_path(project), icu_data_path);
55+
}
56+
4157
TEST(FlDartProjectTest, DartEntrypointArgs) {
4258
g_autoptr(FlDartProject) project = fl_dart_project_new();
4359

shell/platform/linux/public/flutter_linux/fl_dart_project.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ gboolean fl_dart_project_get_enable_mirrors(FlDartProject* project)
7373
*/
7474
const gchar* fl_dart_project_get_aot_library_path(FlDartProject* project);
7575

76+
/**
77+
* fl_dart_project_set_assets_path:
78+
* @project: an #FlDartProject.
79+
* @path: the absolute path to the assets directory.
80+
*
81+
* Sets the path to the directory containing the assets used in the Flutter
82+
* application. By default, this is the data/flutter_assets subdirectory
83+
* relative to the executable directory.
84+
*/
85+
void fl_dart_project_set_assets_path(FlDartProject* project, gchar* path);
86+
7687
/**
7788
* fl_dart_project_get_assets_path:
7889
* @project: an #FlDartProject.
@@ -85,6 +96,16 @@ const gchar* fl_dart_project_get_aot_library_path(FlDartProject* project);
8596
*/
8697
const gchar* fl_dart_project_get_assets_path(FlDartProject* project);
8798

99+
/**
100+
* fl_dart_project_set_icu_data_path:
101+
* @project: an #FlDartProject.
102+
* @path: the absolute path to the ICU data file.
103+
*
104+
* Sets the path to the ICU data file used in the Flutter application. By
105+
* default, this is data/icudtl.dat relative to the executable directory.
106+
*/
107+
void fl_dart_project_set_icu_data_path(FlDartProject* project, gchar* path);
108+
88109
/**
89110
* fl_dart_project_get_icu_data_path:
90111
* @project: an #FlDartProject.

0 commit comments

Comments
 (0)