build: build with ecore_exe and notify errors.
This commit is contained in:
parent
8e4f9b0e5c
commit
ac1430ded0
|
@ -122,6 +122,15 @@ base_gui_term(void)
|
||||||
free(bd);
|
free(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
err_noti_cb(void *data, const char *msg)
|
||||||
|
{
|
||||||
|
base_data *bd = data;
|
||||||
|
|
||||||
|
printf("%s\n", msg);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
Eina_Bool
|
Eina_Bool
|
||||||
base_gui_init(void)
|
base_gui_init(void)
|
||||||
{
|
{
|
||||||
|
@ -161,6 +170,8 @@ base_gui_init(void)
|
||||||
Evas_Object *panes = panes_init(layout);
|
Evas_Object *panes = panes_init(layout);
|
||||||
elm_object_part_content_set(layout, "elm.swallow.panes", panes);
|
elm_object_part_content_set(layout, "elm.swallow.panes", panes);
|
||||||
|
|
||||||
|
build_err_noti_cb_set(err_noti_cb, bd);
|
||||||
|
|
||||||
bd->win = win;
|
bd->win = win;
|
||||||
bd->layout = layout;
|
bd->layout = layout;
|
||||||
|
|
||||||
|
|
114
src/bin/build.c
114
src/bin/build.c
|
@ -1,17 +1,55 @@
|
||||||
#include <Elementary.h>
|
#include <Elementary.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
static char *EDJE_CC_CMD = NULL;
|
typedef struct builder_s
|
||||||
|
{
|
||||||
|
Eina_Strbuf *strbuf;
|
||||||
|
char *build_cmd;
|
||||||
|
void (*noti_cb)(void *data, const char *msg);
|
||||||
|
void *noti_data;
|
||||||
|
Ecore_Event_Handler *event_data_handler;
|
||||||
|
Ecore_Event_Handler *event_err_handler;
|
||||||
|
|
||||||
|
} build_data;
|
||||||
|
|
||||||
|
static build_data *g_bd = NULL;
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
exe_event_error_cb(void *data, int type EINA_UNUSED, void *event_info)
|
||||||
|
{
|
||||||
|
build_data *bd = data;
|
||||||
|
Ecore_Exe_Event_Data *ev = event_info;
|
||||||
|
Ecore_Exe_Event_Data_Line *el;
|
||||||
|
|
||||||
|
eina_strbuf_reset(bd->strbuf);
|
||||||
|
|
||||||
|
for (el = ev->lines; el && el->line; el++)
|
||||||
|
{
|
||||||
|
eina_strbuf_append(bd->strbuf, el->line);
|
||||||
|
eina_strbuf_append_char(bd->strbuf, '\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
bd->noti_cb(bd->noti_data, eina_strbuf_string_get(bd->strbuf));
|
||||||
|
|
||||||
|
return ECORE_CALLBACK_RENEW;
|
||||||
|
}
|
||||||
|
|
||||||
Eina_Bool
|
Eina_Bool
|
||||||
build_cmd_set(void)
|
build_cmd_set(void)
|
||||||
{
|
{
|
||||||
Eina_Strbuf *buf = eina_strbuf_new();
|
build_data *bd = g_bd;
|
||||||
if (!buf) return EINA_FALSE;
|
|
||||||
|
|
||||||
free(EDJE_CC_CMD);
|
free(bd->build_cmd);
|
||||||
|
bd->build_cmd = NULL;
|
||||||
|
|
||||||
eina_strbuf_append_printf(buf,
|
Eina_Strbuf *strbuf = eina_strbuf_new();
|
||||||
|
if (!strbuf)
|
||||||
|
{
|
||||||
|
EINA_LOG_ERR("Failed to new strbuf");
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
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",
|
"edje_cc -fastcomp %s %s -id %s/images -sd %s/sounds -fd %s/fonts -dd %s/data %s %s %s %s",
|
||||||
config_edc_path_get(),
|
config_edc_path_get(),
|
||||||
config_edj_path_get(),
|
config_edj_path_get(),
|
||||||
|
@ -24,37 +62,69 @@ build_cmd_set(void)
|
||||||
config_edc_fnt_path_get(),
|
config_edc_fnt_path_get(),
|
||||||
config_edc_data_path_get());
|
config_edc_data_path_get());
|
||||||
|
|
||||||
EDJE_CC_CMD = eina_strbuf_string_steal(buf);
|
bd->build_cmd = eina_strbuf_string_steal(strbuf);
|
||||||
eina_strbuf_free(buf);
|
eina_strbuf_free(strbuf);
|
||||||
|
|
||||||
return EINA_TRUE;;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
build_edc(void)
|
build_edc(void)
|
||||||
{
|
{
|
||||||
char *bp = NULL;
|
build_data *bd = g_bd;
|
||||||
size_t size;
|
if (!bd->build_cmd)
|
||||||
FILE *stream = open_memstream(&bp, &size);
|
{
|
||||||
(void)stream;
|
EINA_LOG_ERR("Build Command is not set!");
|
||||||
//stderr = &(*stream);
|
return;
|
||||||
|
}
|
||||||
int ret = system(EDJE_CC_CMD);
|
Ecore_Exe_Flags flags =
|
||||||
if (ret == -1)
|
(ECORE_EXE_PIPE_READ_LINE_BUFFERED | ECORE_EXE_PIPE_READ |
|
||||||
EINA_LOG_ERR("error running %s command.", EDJE_CC_CMD);
|
ECORE_EXE_PIPE_ERROR_LINE_BUFFERED | ECORE_EXE_PIPE_ERROR);
|
||||||
|
ecore_exe_pipe_run(bd->build_cmd, flags, NULL);
|
||||||
// if (bp)
|
|
||||||
// printf("@@@@ buf = %s, size = %d\n", bp, size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Eina_Bool
|
Eina_Bool
|
||||||
build_init(void)
|
build_init(void)
|
||||||
{
|
{
|
||||||
return build_cmd_set();
|
build_data *bd = g_bd;
|
||||||
|
if (bd) return EINA_TRUE;
|
||||||
|
|
||||||
|
bd = calloc(1, sizeof(build_data));
|
||||||
|
if (!bd)
|
||||||
|
{
|
||||||
|
EINA_LOG_ERR("Failed to allocate Memory!");
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
g_bd = bd;
|
||||||
|
|
||||||
|
Eina_Bool ret = build_cmd_set();
|
||||||
|
|
||||||
|
bd->event_data_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DATA,
|
||||||
|
exe_event_error_cb, bd);
|
||||||
|
bd->event_err_handler = ecore_event_handler_add(ECORE_EXE_EVENT_ERROR,
|
||||||
|
exe_event_error_cb, bd);
|
||||||
|
|
||||||
|
bd->strbuf = eina_strbuf_new();
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
build_term(void)
|
build_term(void)
|
||||||
{
|
{
|
||||||
free(EDJE_CC_CMD);
|
build_data *bd = g_bd;
|
||||||
|
ecore_event_handler_del(bd->event_data_handler);
|
||||||
|
ecore_event_handler_del(bd->event_err_handler);
|
||||||
|
eina_strbuf_free(bd->strbuf);
|
||||||
|
free(bd->build_cmd);
|
||||||
|
free(bd);
|
||||||
|
g_bd = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
build_err_noti_cb_set(void (*cb)(void *data, const char *msg), void *data)
|
||||||
|
{
|
||||||
|
build_data *bd = g_bd;
|
||||||
|
bd->noti_cb = cb;
|
||||||
|
bd->noti_data = data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,3 +2,4 @@ void build_edc(void);
|
||||||
Eina_Bool build_init(void);
|
Eina_Bool build_init(void);
|
||||||
void build_term(void);
|
void build_term(void);
|
||||||
Eina_Bool build_cmd_set(void);
|
Eina_Bool build_cmd_set(void);
|
||||||
|
void build_err_noti_cb_set(void (*cb)(void *data, const char *msg), void *data);
|
||||||
|
|
Loading…
Reference in New Issue