elm: fix value of datadir when running in tree

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
This commit is contained in:
Mike Blumenkrantz 2019-05-29 09:18:20 -04:00
parent b792bd83b6
commit 67e9e1cad4
1 changed files with 16 additions and 1 deletions

View File

@ -587,7 +587,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;
}