build: Support relative resource paths in sub edc file.
Relative resource paths in sub edc files are based on the current working directory. To support relative resource paths in sub edc files, set main edc file's directory as the working directory when edje_cc is executed. Test Plan: 1. Create "main.edc" in "./edc/" directory. 2. Create "sub.edc" in "./edc/sub/" directory. 3. Create "icon.png" in "./edc/image/" directory. 4. "main.edc" includes "sub.edc". (i.e. #include "./sub/sub.edc") 5. "sub.edc" uses "icon.png". (i.e. images.image: "./image/icon.png" COMP;) 6. Open "main.edc" in the current working directory. (i.e. enventor -w ./edc ./edc/main.edc -i ./edc/image)
This commit is contained in:
parent
13fa36376c
commit
c17f2f3e37
|
@ -98,8 +98,20 @@ build_cmd_set(build_data *bd)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Move to main edc file's directory to set it as the current working
|
||||||
|
directory to support relative resource paths in sub edc files.
|
||||||
|
(e.g. images.image: "./images/icon.png" COMP; in sub edc files) */
|
||||||
|
char *edc_dir = ecore_file_dir_get(bd->edc_path);
|
||||||
|
if (!edc_dir) goto err;
|
||||||
|
|
||||||
|
/* Move back to current working directory to restore the current working
|
||||||
|
directory after edje_cc compile. */
|
||||||
|
char *cur_dir = ecore_file_realpath("./");
|
||||||
|
if (!cur_dir) goto err;
|
||||||
|
|
||||||
eina_strbuf_append_printf(strbuf,
|
eina_strbuf_append_printf(strbuf,
|
||||||
"edje_cc -fastcomp %s %s -id %s/images -sd %s/sounds -fd %s/fonts -dd %s/data %s %s %s %s -beta",
|
"cd %s && edje_cc -fastcomp %s %s -id %s/images -sd %s/sounds -fd %s/fonts -dd %s/data %s %s %s %s -beta && cd %s",
|
||||||
|
edc_dir,
|
||||||
bd->edc_path,
|
bd->edc_path,
|
||||||
(char *) eina_list_data_get(bd->pathes_list[ENVENTOR_PATH_TYPE_EDJ]),
|
(char *) eina_list_data_get(bd->pathes_list[ENVENTOR_PATH_TYPE_EDJ]),
|
||||||
elm_app_data_dir_get(),
|
elm_app_data_dir_get(),
|
||||||
|
@ -109,11 +121,15 @@ build_cmd_set(build_data *bd)
|
||||||
eina_strbuf_string_get(strbuf_img),
|
eina_strbuf_string_get(strbuf_img),
|
||||||
eina_strbuf_string_get(strbuf_snd),
|
eina_strbuf_string_get(strbuf_snd),
|
||||||
eina_strbuf_string_get(strbuf_fnt),
|
eina_strbuf_string_get(strbuf_fnt),
|
||||||
eina_strbuf_string_get(strbuf_dat));
|
eina_strbuf_string_get(strbuf_dat),
|
||||||
|
cur_dir);
|
||||||
bd->build_cmd = eina_strbuf_string_steal(strbuf);
|
bd->build_cmd = eina_strbuf_string_steal(strbuf);
|
||||||
bd->build_cmd_changed = EINA_FALSE;
|
bd->build_cmd_changed = EINA_FALSE;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
if (edc_dir) free(edc_dir);
|
||||||
|
if (cur_dir) free(cur_dir);
|
||||||
|
|
||||||
eina_strbuf_free(strbuf);
|
eina_strbuf_free(strbuf);
|
||||||
eina_strbuf_free(strbuf_img);
|
eina_strbuf_free(strbuf_img);
|
||||||
eina_strbuf_free(strbuf_snd);
|
eina_strbuf_free(strbuf_snd);
|
||||||
|
|
Loading…
Reference in New Issue