Update FlDartProject to new path format (#17302)

Matches the structure used on Windows of assuming a directory format.
diff --git a/shell/platform/linux/BUILD.gn b/shell/platform/linux/BUILD.gn
index d0221b1..1b09d54 100644
--- a/shell/platform/linux/BUILD.gn
+++ b/shell/platform/linux/BUILD.gn
@@ -58,6 +58,8 @@
   }
 
   source_set("flutter_linux") {
+    public = _public_headers
+
     sources = [
       "fl_dart_project.cc",
       "fl_view.cc",
diff --git a/shell/platform/linux/fl_dart_project.cc b/shell/platform/linux/fl_dart_project.cc
index cbabc8c..0a20dd6 100644
--- a/shell/platform/linux/fl_dart_project.cc
+++ b/shell/platform/linux/fl_dart_project.cc
@@ -16,14 +16,29 @@
 struct _FlDartProject {
   GObject parent_instance;
 
-  gchar* assets_path;
-  gchar* icu_data_path;
+  gchar* path;
 };
 
-enum { PROP_ASSETS_PATH = 1, PROP_ICU_DATA_PATH, PROP_LAST };
+enum { PROP_ASSETS_PATH = 1, PROP_ICU_DATA_PATH, PROP_PATH, PROP_LAST };
 
 G_DEFINE_TYPE(FlDartProject, fl_dart_project, G_TYPE_OBJECT)
 
+static void fl_dart_project_set_path(FlDartProject* self, const gchar* path) {
+  g_free(self->path);
+
+  if (g_path_is_absolute(path))
+    self->path = g_strdup(path);
+  else {
+    g_autoptr(GError) error = NULL;
+    g_autofree gchar* exe_path = g_file_read_link("/proc/self/exe", &error);
+    if (exe_path == NULL)
+      g_critical("Failed to determine location of executable: %s",
+                 error->message);
+    g_autofree gchar* dir = g_path_get_dirname(exe_path);
+    self->path = g_build_filename(dir, path, NULL);
+  }
+}
+
 static void fl_dart_project_set_property(GObject* object,
                                          guint prop_id,
                                          const GValue* value,
@@ -31,13 +46,8 @@
   FlDartProject* self = FL_DART_PROJECT(object);
 
   switch (prop_id) {
-    case PROP_ASSETS_PATH:
-      g_free(self->assets_path);
-      self->assets_path = g_strdup(g_value_get_string(value));
-      break;
-    case PROP_ICU_DATA_PATH:
-      g_free(self->icu_data_path);
-      self->icu_data_path = g_strdup(g_value_get_string(value));
+    case PROP_PATH:
+      fl_dart_project_set_path(self, g_value_get_string(value));
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
@@ -53,10 +63,13 @@
 
   switch (prop_id) {
     case PROP_ASSETS_PATH:
-      g_value_set_string(value, self->assets_path);
+      g_value_take_string(value, fl_dart_project_get_assets_path(self));
       break;
     case PROP_ICU_DATA_PATH:
-      g_value_set_string(value, self->icu_data_path);
+      g_value_take_string(value, fl_dart_project_get_icu_data_path(self));
+      break;
+    case PROP_PATH:
+      g_value_set_string(value, self->path);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
@@ -67,8 +80,7 @@
 static void fl_dart_project_dispose(GObject* object) {
   FlDartProject* self = FL_DART_PROJECT(object);
 
-  g_clear_pointer(&self->assets_path, g_free);
-  g_clear_pointer(&self->icu_data_path, g_free);
+  g_clear_pointer(&self->path, g_free);
 
   G_OBJECT_CLASS(fl_dart_project_parent_class)->dispose(object);
 }
@@ -82,12 +94,18 @@
       G_OBJECT_CLASS(klass), PROP_ASSETS_PATH,
       g_param_spec_string(
           "assets-path", "assets-path", "Path to Flutter assets", nullptr,
-          static_cast<GParamFlags>(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
-                                   G_PARAM_STATIC_STRINGS)));
+          static_cast<GParamFlags>(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
+
   g_object_class_install_property(
       G_OBJECT_CLASS(klass), PROP_ICU_DATA_PATH,
       g_param_spec_string(
           "icu-data-path", "icu-data-path", "Path to ICU data", nullptr,
+          static_cast<GParamFlags>(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
+
+  g_object_class_install_property(
+      G_OBJECT_CLASS(klass), PROP_PATH,
+      g_param_spec_string(
+          "path", "path", "Path to Flutter project", nullptr,
           static_cast<GParamFlags>(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
                                    G_PARAM_STATIC_STRINGS)));
 }
@@ -96,18 +114,34 @@
 
 /**
  * fl_dart_project_new:
- * @assets_path: a file path, e.g. "build/assets"
- * @icu_data_path: a file path, e.g. "build/icudtl.dat"
+ * @path: a file path, e.g. "my_dart_project"
  *
- * Create a Flutter project.
+ * Create a Flutter project. The project path should contain the following
+ * top-level items:
+ * - icudtl.dat (provided as a resource by the Flutter tool)
+ * - flutter_assets (as built by the Flutter tool)
+ *
+ * The path can either be absolute, or relative to the directory containing the
+ * running executable.
  *
  * Returns: a new #FlDartProject
  */
-G_MODULE_EXPORT FlDartProject* fl_dart_project_new(const gchar* assets_path,
-                                                   const gchar* icu_data_path) {
+G_MODULE_EXPORT FlDartProject* fl_dart_project_new(const gchar* path) {
   return static_cast<FlDartProject*>(
-      g_object_new(fl_dart_project_get_type(), "assets-path", assets_path,
-                   "icu-data-path", icu_data_path, nullptr));
+      g_object_new(fl_dart_project_get_type(), "path", path, nullptr));
+}
+
+/**
+ * fl_dart_project_get_path:
+ * @view: a #FlDartProject
+ *
+ * Get the path to the directory containing the Flutter application.
+ *
+ * Returns: (type filename): a file path, e.g. "/projects/my_dart_project"
+ */
+G_MODULE_EXPORT const gchar* fl_dart_project_get_path(FlDartProject* self) {
+  g_return_val_if_fail(FL_IS_DART_PROJECT(self), nullptr);
+  return self->path;
 }
 
 /**
@@ -117,12 +151,12 @@
  * Get the path to the directory containing the assets used in the Flutter
  * application.
  *
- * Returns: a file path, e.g. "build/assets"
+ * Returns: (type filename): a file path, e.g.
+ * "/projects/my_dart_project/assets"
  */
-G_MODULE_EXPORT const gchar* fl_dart_project_get_assets_path(
-    FlDartProject* self) {
+G_MODULE_EXPORT gchar* fl_dart_project_get_assets_path(FlDartProject* self) {
   g_return_val_if_fail(FL_IS_DART_PROJECT(self), nullptr);
-  return self->assets_path;
+  return g_build_filename(self->path, "flutter_assets", NULL);
 }
 
 /**
@@ -131,10 +165,10 @@
  *
  * Get the path to the ICU data file in the Flutter application.
  *
- * Returns: a file path, e.g. "build/icudtl.dat"
+ * Returns: (type filename): a file path, e.g.
+ * "/projects/my_dart_project/icudtl.dat"
  */
-G_MODULE_EXPORT const gchar* fl_dart_project_get_icu_data_path(
-    FlDartProject* self) {
+G_MODULE_EXPORT gchar* fl_dart_project_get_icu_data_path(FlDartProject* self) {
   g_return_val_if_fail(FL_IS_DART_PROJECT(self), nullptr);
-  return self->icu_data_path;
+  return g_build_filename(self->path, "icudtl.dat", NULL);
 }
diff --git a/shell/platform/linux/fl_view.cc b/shell/platform/linux/fl_view.cc
index 218f1ae..879a362 100644
--- a/shell/platform/linux/fl_view.cc
+++ b/shell/platform/linux/fl_view.cc
@@ -136,10 +136,15 @@
   config.open_gl.fbo_callback = fl_view_gl_fbo_callback;
   config.open_gl.present = fl_view_gl_present;
 
+  g_autofree gchar* assets_path =
+      fl_dart_project_get_assets_path(self->flutter_project);
+  g_autofree gchar* icu_data_path =
+      fl_dart_project_get_icu_data_path(self->flutter_project);
+
   FlutterProjectArgs args = {};
   args.struct_size = sizeof(FlutterProjectArgs);
-  args.assets_path = fl_dart_project_get_assets_path(self->flutter_project);
-  args.icu_data_path = fl_dart_project_get_icu_data_path(self->flutter_project);
+  args.assets_path = assets_path;
+  args.icu_data_path = icu_data_path;
 
   FlutterEngineResult result = FlutterEngineInitialize(
       FLUTTER_ENGINE_VERSION, &config, &args, self, &self->flutter_engine);
diff --git a/shell/platform/linux/public/flutter_linux/fl_dart_project.h b/shell/platform/linux/public/flutter_linux/fl_dart_project.h
index d2a62b5..8ee4250 100644
--- a/shell/platform/linux/public/flutter_linux/fl_dart_project.h
+++ b/shell/platform/linux/public/flutter_linux/fl_dart_project.h
@@ -15,12 +15,13 @@
 
 G_DECLARE_FINAL_TYPE(FlDartProject, fl_dart_project, FL, DART_PROJECT, GObject)
 
-FlDartProject* fl_dart_project_new(const gchar* assets_path,
-                                   const gchar* icu_data_path);
+FlDartProject* fl_dart_project_new(const gchar* path);
 
-const gchar* fl_dart_project_get_assets_path(FlDartProject* project);
+const gchar* fl_dart_project_get_path(FlDartProject* project);
 
-const gchar* fl_dart_project_get_icu_data_path(FlDartProject* project);
+gchar* fl_dart_project_get_assets_path(FlDartProject* project);
+
+gchar* fl_dart_project_get_icu_data_path(FlDartProject* project);
 
 G_END_DECLS