elm: fix value of datadir when running in tree
authorMike Blumenkrantz <zmike@samsung.com>
Wed, 29 May 2019 13:18:20 +0000 (09:18 -0400)
committerWonki Kim <wonki_.kim@samsung.com>
Mon, 3 Jun 2019 06:58:35 +0000 (15:58 +0900)
Summary:
this makes it possible to successfully run elm_test out of the tree
without installing

@fix
Depends on D8965

Reviewers: cedric

Reviewed By: cedric

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8966

src/lib/elementary/elm_main.c

index 49ce3b4..818bd33 100644 (file)
@@ -616,7 +616,22 @@ elm_app_data_dir_get(void)
    if (app_data_dir) return app_data_dir;
    _prefix_check();
    if (!app_pfx) return "";
-   app_data_dir = eina_prefix_data_get(app_pfx);
+   /* only used to run inside efl src tree */
+   if (getenv("EFL_RUN_IN_TREE"))
+     {
+        /* "/some/path/to/repo/build/src" */
+        const char *path = elm_app_prefix_dir_get();
+        /* "/some/path/to/repo/build/" */
+        const char *last_sep = strrchr(path, '/');
+        Eina_Strbuf *buf = eina_strbuf_new();
+        eina_strbuf_append_length(buf, path, last_sep - path + 1);
+        eina_strbuf_append(buf, "data/elementary");
+        app_data_dir = eina_strbuf_string_steal(buf);
+        eina_strbuf_free(buf);
+        /* yes this leaks app_data_dir but it's a one time allocation who cares */
+     }
+   else
+     app_data_dir = eina_prefix_data_get(app_pfx);
    return app_data_dir;
 }