Adding simple build check and clean support to the CLI and main toolbar

This commit is contained in:
Andy Williams 2014-11-09 14:08:52 +00:00
parent 863a4a47a2
commit 3e860e9ba7
4 changed files with 92 additions and 10 deletions

View File

@ -40,7 +40,7 @@ _exe_del(void *d EINA_UNUSED, int t EINA_UNUSED, void *event_info EINA_UNUSED)
static const Ecore_Getopt optdesc = {
"edi_build",
"%prog [options]",
"%prog [options] [build-type]",
PACKAGE_VERSION,
COPYRIGHT,
"BSD with advertisement clause",
@ -59,7 +59,7 @@ EAPI_MAIN int
main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
int args;
char path[PATH_MAX];
char path[PATH_MAX], *build_type = NULL;
Eina_Bool quit_option = EINA_FALSE;
Ecore_Getopt_Value values[] = {
@ -102,11 +102,26 @@ main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
goto exit;
}
if (args < argc)
build_type = argv[args];
if (!build_type)
build_type = "build";
ecore_event_handler_add(ECORE_EXE_EVENT_DATA, _exe_data, NULL);
ecore_event_handler_add(ECORE_EXE_EVENT_ERROR, _exe_data, NULL);
ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _exe_del, NULL);
edi_builder_build();
if (!strncmp("clean", build_type, 5))
edi_builder_clean();
else if (!strncmp("test", build_type, 4))
edi_builder_test();
else if (!strncmp("build", build_type, 5))
edi_builder_build();
else
{
fprintf(stderr, "Unrecognised build type - try build, test or clean.\n");
goto end;
}
ecore_main_loop_begin();
end:

View File

@ -303,10 +303,10 @@ _tb_goto_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUS
evas_object_show(popup);
}
static void
_tb_build_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
static Eina_Bool
_edi_build_prep(Evas_Object *button)
{
elm_toolbar_item_selected_set(elm_toolbar_selected_item_get(obj), EINA_FALSE);
elm_toolbar_item_selected_set(elm_toolbar_selected_item_get(button), EINA_FALSE);
edi_consolepanel_clear();
edi_consolepanel_show();
@ -314,11 +314,38 @@ _tb_build_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNU
if (!edi_builder_can_build())
{
edi_consolepanel_append_error_line("Cowardly refusing to build unknown project type.");
return EINA_FALSE;
}
else
{
edi_builder_build();
}
return EINA_TRUE;
}
static void
_tb_build_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
if (_edi_build_prep(obj))
edi_builder_build();
}
static void
_tb_test_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
if (_edi_build_prep(obj))
edi_builder_test();
}
/*
static void
_tb_run_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
if (_edi_build_prep(obj))
edi_builder_run();
}
*/
static void
_tb_clean_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
if (_edi_build_prep(obj))
edi_builder_clean();
}
static Evas_Object *
@ -357,6 +384,9 @@ edi_toolbar_setup(Evas_Object *win)
elm_toolbar_item_separator_set(tb_it, EINA_TRUE);
tb_it = elm_toolbar_item_append(tb, "system-run", "Build", _tb_build_cb, NULL);
tb_it = elm_toolbar_item_append(tb, "emblem-default", "Test", _tb_test_cb, NULL);
// tb_it = elm_toolbar_item_append(tb, "player-play", "Run", _tb_run_cb, NULL);
tb_it = elm_toolbar_item_append(tb, "edit-clear", "Clean", _tb_clean_cb, NULL);
evas_object_show(tb);
return tb;

View File

@ -50,3 +50,20 @@ edi_builder_build(void)
_edi_builder_build_autogen();
}
EAPI void
edi_builder_test(void)
{
chdir(edi_project_get());
ecore_exe_pipe_run("make check", ECORE_EXE_PIPE_READ_LINE_BUFFERED | ECORE_EXE_PIPE_READ |
ECORE_EXE_PIPE_ERROR_LINE_BUFFERED | ECORE_EXE_PIPE_ERROR, NULL);
}
EAPI void
edi_builder_clean(void)
{
chdir(edi_project_get());
ecore_exe_pipe_run("make clean", ECORE_EXE_PIPE_READ_LINE_BUFFERED | ECORE_EXE_PIPE_READ |
ECORE_EXE_PIPE_ERROR_LINE_BUFFERED | ECORE_EXE_PIPE_ERROR, NULL);
}

View File

@ -44,6 +44,26 @@ edi_builder_can_build(void);
EAPI void
edi_builder_build(void);
/**
* Run a test build for the current project.
*
* @see edi_builder_can_build().
*
* @ingroup Builder
*/
EAPI void
edi_builder_test(void);
/**
* Run a clean for the current project.
*
* @see edi_builder_can_build().
*
* @ingroup Builder
*/
EAPI void
edi_builder_clean(void);
/**
* @}
*/