From 3e860e9ba7f3d135aed408bae5ea6c8bd977ed79 Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Sun, 9 Nov 2014 14:08:52 +0000 Subject: [PATCH] Adding simple build check and clean support to the CLI and main toolbar --- src/bin/edi_build_main.c | 21 ++++++++++++++++--- src/bin/edi_main.c | 44 +++++++++++++++++++++++++++++++++------- src/lib/edi_builder.c | 17 ++++++++++++++++ src/lib/edi_builder.h | 20 ++++++++++++++++++ 4 files changed, 92 insertions(+), 10 deletions(-) diff --git a/src/bin/edi_build_main.c b/src/bin/edi_build_main.c index 50a887a..893275c 100644 --- a/src/bin/edi_build_main.c +++ b/src/bin/edi_build_main.c @@ -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: diff --git a/src/bin/edi_main.c b/src/bin/edi_main.c index 1912797..6385c3d 100644 --- a/src/bin/edi_main.c +++ b/src/bin/edi_main.c @@ -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; diff --git a/src/lib/edi_builder.c b/src/lib/edi_builder.c index 31a82bf..017e63f 100644 --- a/src/lib/edi_builder.c +++ b/src/lib/edi_builder.c @@ -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); +} + + diff --git a/src/lib/edi_builder.h b/src/lib/edi_builder.h index dcb8462..c8b0730 100644 --- a/src/lib/edi_builder.h +++ b/src/lib/edi_builder.h @@ -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); + /** * @} */