nikawhite pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=4c3c82173501d53462cc64536448a48db9223dc4

commit 4c3c82173501d53462cc64536448a48db9223dc4
Author: Mykyta Biliavskyi <m.biliavs...@samsung.com>
Date:   Tue Aug 9 19:27:23 2016 +0300

    Project manager: Fix release export for edj file.
    
    Enabled in menu.
---
 src/bin/project_manager/project_manager.c          | 110 ++-------------------
 .../project_manager/project_manager_export_edj.c   | 100 +++++++++++++++++++
 src/bin/project_manager/project_manager_private.h  |   2 +
 src/bin/ui/menu.c                                  |   5 +-
 src/bin/ui/project_export.c                        |  17 +++-
 5 files changed, 127 insertions(+), 107 deletions(-)

diff --git a/src/bin/project_manager/project_manager.c 
b/src/bin/project_manager/project_manager.c
index fecab36..443b3c8 100644
--- a/src/bin/project_manager/project_manager.c
+++ b/src/bin/project_manager/project_manager.c
@@ -197,17 +197,6 @@ _end_send(void *data)
    func(udata, result);
 }
 
-static void *
-_ecore_exe_edje_exe(void *data)
-{
-   Edje_Exe_Data *edje_exe_data = (Edje_Exe_Data *)data;
-
-   edje_exe_data->exe_cmd = ecore_exe_pipe_run(edje_exe_data->cmd, 
edje_exe_data->flags, NULL);
-   edje_exe_data->exe_pid = ecore_exe_pid_get(edje_exe_data->exe_cmd);
-
-   return NULL;
-}
-
 Eina_Bool
 _build_script_write(const char *path)
 {
@@ -538,25 +527,6 @@ pm_project_import_edj(const char *name,
    _project_import_edj(ptd);
 }
 
-static Eina_Bool
-_exe_data(void *data __UNUSED__,
-          int type __UNUSED__,
-          void *event)
-{
-   int i;
-   Ecore_Exe_Event_Data *ev = event;
-
-   if (ev->lines)
-     {
-        for (i = 0; ev->lines[i].line; i++)
-          {
-             DBG("%s", ev->lines[i].line);
-             PROGRESS_SEND("%s", ev->lines[i].line);
-          }
-     }
-
-   return ECORE_CALLBACK_PASS_ON;
-}
 
 void
 pm_project_import_edc(const char *name,
@@ -944,7 +914,6 @@ pm_group_source_code_export(Project *project,
                              true);
 }
 
-
 void
 pm_project_source_code_export(Project *project,
                               const char *path,
@@ -969,69 +938,6 @@ pm_project_source_code_export(Project *project,
                              _project_source_code_export_end_cb,
                              _project_source_code_export_cancel_cb, ptd,
                              true);
-
-}
-
-static void *
-_release_export(void *data __UNUSED__,
-                Eina_Thread *thread __UNUSED__)
-{
-   Eina_Tmpstr *tmp_dirname;
-   Eina_Strbuf *cmd;
-   Ecore_Event_Handler *cb_msg_stdout = NULL,
-                       *cb_msg_stderr = NULL;
-   int waitpid_res = 0, edje_cc_res = 0;
-
-   PROGRESS_SEND(_("Export project as release file"));
-   PROGRESS_SEND(_("Export to file '%s'"), worker.edj);
-
-   eina_file_mkdtemp("eflete_build_XXXXXX", &tmp_dirname);
-/*   if (!_project_src_export(tmp_dirname))
-     {
-        END_SEND(PM_PROJECT_ERROR)
-        goto exit0;
-     }
-     */
-   if (worker.func_progress)
-     {
-        cb_msg_stdout = ecore_event_handler_add(ECORE_EXE_EVENT_DATA, 
_exe_data, NULL);
-        cb_msg_stderr = ecore_event_handler_add(ECORE_EXE_EVENT_ERROR, 
_exe_data, NULL);
-     }
-   cmd = eina_strbuf_new();
-   Edje_Exe_Data *edje_cc_data = mem_malloc(sizeof(Edje_Exe_Data));
-   eina_strbuf_append_printf(cmd, "edje_cc -v -id %s/images/ -sd %s/sounds/ 
-fd %s/fonts/ %s/generated.edc %s",
-                             tmp_dirname, tmp_dirname, tmp_dirname, 
tmp_dirname, worker.edj);
-   edje_cc_data->cmd = eina_stringshare_add(eina_strbuf_string_get(cmd));
-   edje_cc_data->flags  = ECORE_EXE_PIPE_READ |
-                          ECORE_EXE_PIPE_READ_LINE_BUFFERED |
-                          ECORE_EXE_PIPE_ERROR |
-                          ECORE_EXE_PIPE_ERROR_LINE_BUFFERED;
-   THREAD_TESTCANCEL;
-   ecore_main_loop_thread_safe_call_sync(_ecore_exe_edje_exe, edje_cc_data);
-   THREAD_TESTCANCEL;
-   waitpid_res = waitpid(edje_cc_data->exe_pid, &edje_cc_res, 0);
-   eina_stringshare_del(edje_cc_data->cmd);
-   free(edje_cc_data);
-   if (worker.func_progress)
-     {
-        ecore_event_handler_del(cb_msg_stdout);
-        ecore_event_handler_del(cb_msg_stderr);
-     }
-   if ((waitpid_res == -1) ||
-       (WIFEXITED(edje_cc_res) && (WEXITSTATUS(edje_cc_res) != 0 )))
-     {
-        END_SEND(PM_PROJECT_ERROR);
-        goto exit1;
-     }
-
-   PROGRESS_SEND("Export done");
-   END_SEND(PM_PROJECT_SUCCESS);
-
-exit1:
-   eina_strbuf_free(cmd);
-   ecore_file_recursive_rm(tmp_dirname);
-   eina_tmpstr_del(tmp_dirname);
-   return NULL;
 }
 
 void
@@ -1044,15 +950,15 @@ pm_project_release_export(Project *project,
    assert(project != NULL);
    assert(path != NULL);
 
-   WORKER_CREATE(func_progress, func_end, data, project,
-                 NULL, NULL, path, NULL, data, NULL);
+   Project_Thread *ptd;
+   ptd = mem_calloc(1, sizeof(Project_Thread));
+   ptd->path = eina_stringshare_add(path);
+   ptd->project = project;
+   ptd->func_progress = func_progress;
+   ptd->func_end = func_end;
+   ptd->data = (void *)data;
 
-   if (!eina_thread_create(&worker.thread, EINA_THREAD_URGENT, -1,
-                           (void *)_release_export, NULL))
-     {
-        ERR("System error: can't create thread");
-        abort();
-     }
+   _release_export(ptd);
 }
 
 void
diff --git a/src/bin/project_manager/project_manager_export_edj.c 
b/src/bin/project_manager/project_manager_export_edj.c
index 8cdc38d..bd28116 100644
--- a/src/bin/project_manager/project_manager_export_edj.c
+++ b/src/bin/project_manager/project_manager_export_edj.c
@@ -112,3 +112,103 @@ _develop_export(Project_Thread *ptd)
    return;
 }
 
+/* Export release edj file */
+static Eina_Bool
+_data_from_edje_cc(void *data __UNUSED__,
+                   int type __UNUSED__,
+                   void *event_info)
+{
+   int i = 0;
+   Ecore_Exe_Event_Data *edje_cc_msg = (Ecore_Exe_Event_Data *)event_info;
+   Edje_Exe_Data *edje_cc_data = (Edje_Exe_Data*)data;
+   Project_Thread *ptd = (Project_Thread *)edje_cc_data->data;
+   if (!edje_cc_msg) return ECORE_CALLBACK_DONE;
+
+   for (i = 0; edje_cc_msg->lines[i].line != NULL; i++)
+         ptd->func_progress(NULL, edje_cc_msg->lines[i].line);
+
+   return ECORE_CALLBACK_DONE;
+}
+
+static unsigned char
+_finish_from_release_edje_cc(void *data,
+                             int type __UNUSED__,
+                             void *event_info __UNUSED__)
+{
+   Edje_Exe_Data *edje_cc_data = (Edje_Exe_Data *)data;
+   Project_Thread *ptd = (Project_Thread *)edje_cc_data->data;
+   Ecore_Exe_Event_Del *edje_cc_exit = (Ecore_Exe_Event_Del *)event_info;
+
+   eina_stringshare_del(edje_cc_data->cmd);
+   free(edje_cc_data);
+   if (edje_cc_exit->exit_code != 0)
+     {
+        ptd->result = PM_PROJECT_ERROR;
+        _end_send(ptd);
+        return ECORE_CALLBACK_DONE;
+     }
+
+   Eina_Stringshare *msg = eina_stringshare_printf(_("Data for importing 
prepared"));
+   ptd->func_progress(NULL, msg);
+   eina_stringshare_del(msg);
+
+   Eina_Stringshare *edj = eina_stringshare_printf("%s/out.edj", 
ptd->tmp_dirname);
+   ecore_file_cp(edj, ptd->tmp_path);
+   ptd->result = PM_PROJECT_SUCCESS;
+   _end_send(ptd);
+
+   return ECORE_CALLBACK_DONE;
+}
+
+static void
+_project_source_code_release_export_end_cb(void *data,
+                                           Ecore_Thread *th __UNUSED__)
+{
+   Project_Thread *ptd = (Project_Thread *)data;
+
+   Eina_Stringshare *msg = eina_stringshare_printf(_("Start import '%s' file 
as new project"), ptd->edc);
+   ptd->func_progress(NULL, msg);
+   eina_stringshare_del(msg);
+
+   ptd->edc = eina_stringshare_printf("%s/%s/generated.edc", ptd->tmp_dirname, 
ptd->project->name);
+   ptd->build_options = eina_stringshare_printf("-id \"%s/%s/images\" "
+                                                "-sd \"%s/%s/sounds\" "
+                                                "-fd \"%s/%s/fonts\" "
+                                                "-v",
+                                                ptd->tmp_dirname, 
ptd->project->name,
+                                                ptd->tmp_dirname, 
ptd->project->name,
+                                                ptd->tmp_dirname, 
ptd->project->name);
+
+   ptd->edj = eina_stringshare_printf("%s/out.edj", ptd->tmp_dirname);
+   Edje_Exe_Data *edje_cc_data = mem_malloc(sizeof(Edje_Exe_Data));
+   edje_cc_data->cmd = eina_stringshare_printf("edje_cc -v %s %s %s",
+                                               ptd->edc,
+                                               ptd->edj,
+                                               ptd->build_options);
+   edje_cc_data->flags  = ECORE_EXE_PIPE_READ |
+      ECORE_EXE_PIPE_READ_LINE_BUFFERED |
+      ECORE_EXE_PIPE_ERROR |
+      ECORE_EXE_PIPE_ERROR_LINE_BUFFERED;
+   edje_cc_data->data = (void *)ptd;
+
+   edje_cc_data->exe_cmd = ecore_exe_pipe_run(edje_cc_data->cmd, 
edje_cc_data->flags, NULL);
+
+   ptd->data_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DATA, 
_data_from_edje_cc, edje_cc_data);
+   ptd->error_handler = ecore_event_handler_add(ECORE_EXE_EVENT_ERROR, 
_data_from_edje_cc, edje_cc_data);
+   ptd->del_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, 
_finish_from_release_edje_cc, edje_cc_data);
+}
+
+void
+_release_export(Project_Thread *ptd)
+{
+   Eina_Stringshare *msg = eina_stringshare_printf(_("Export to file '%s'"), 
ptd->edj);
+   ptd->func_progress(NULL, msg);
+   eina_stringshare_del(msg);
+
+   eina_file_mkdtemp("eflete_build_XXXXXX", &ptd->tmp_dirname);
+   ptd->tmp_path = eina_stringshare_add(ptd->path);
+   ptd->path = eina_stringshare_add(ptd->tmp_dirname);
+   ecore_thread_feedback_run(_project_source_code_export_feedback_job, 
_project_source_code_export_feedback_cb,
+                             _project_source_code_release_export_end_cb, 
_project_source_code_export_cancel_cb, ptd,
+                             true);
+}
diff --git a/src/bin/project_manager/project_manager_private.h 
b/src/bin/project_manager/project_manager_private.h
index 942aadc..23bfad6 100644
--- a/src/bin/project_manager/project_manager_private.h
+++ b/src/bin/project_manager/project_manager_private.h
@@ -219,4 +219,6 @@ void _group_source_code_export_cancel_cb(void *data, 
Ecore_Thread *th);
 /*------ Export edj binary--------------*/
 void _develop_export(Project_Thread *ptd);
 
+void _release_export(Project_Thread *ptd);
+
 #endif
diff --git a/src/bin/ui/menu.c b/src/bin/ui/menu.c
index 9bc340b..367f0cc 100644
--- a/src/bin/ui/menu.c
+++ b/src/bin/ui/menu.c
@@ -31,7 +31,7 @@ int MENU_ITEMS_LIST_BASE[] = {
    MENU_FILE_EXPORT_EDC_PROJECT,
    MENU_FILE_EXPORT,
    MENU_FILE_EXPORT_DEVELOP,
-/* MENU_FILE_EXPORT_RELEASE,*/
+   MENU_FILE_EXPORT_RELEASE,
    MENU_FILE_CLOSE_PROJECT,
    MENU_WINDOW_MANAGER_IMAGE,
    MENU_WINDOW_MANAGER_SOUND,
@@ -339,9 +339,6 @@ ui_menu_add(void)
 
    elm_menu_item_separator_add(window_menu, menu->items[MENU_FILE_IMPORT_EDC]);
 
-   /* uncomment it, when release export will be implemented */
-   ui_menu_disable_set(menu, MENU_FILE_EXPORT_RELEASE, true);
-
    ui_menu_items_list_disable_set(menu, MENU_ITEMS_LIST_BASE, true);
    ui_menu_items_list_disable_set(menu, MENU_ITEMS_LIST_STYLE_ONLY, true);
 
diff --git a/src/bin/ui/project_export.c b/src/bin/ui/project_export.c
index 6451193..5d61623 100644
--- a/src/bin/ui/project_export.c
+++ b/src/bin/ui/project_export.c
@@ -156,7 +156,22 @@ _export_release(void *data __UNUSED__,
 void
 project_export_release(void)
 {
-   popup_fileselector_edj_helper("Export to release edj-file", NULL, NULL, 
_export_release, NULL, false, true);
+   Eina_Strbuf *buf;
+
+   if (!ap.path.export_edj)
+     popup_fileselector_edj_helper("Export to release edj-file", NULL, NULL, 
_export_release, NULL, false, true);
+   else
+     {
+        Eina_List *l = NULL;
+        l = eina_list_append(l, ap.path.export_edj);
+        _export_dev(NULL, NULL, l);
+        eina_list_free(l);
+     }
+
+   buf = eina_strbuf_new();
+   eina_strbuf_append_printf(buf, "%s-release.edj", ap.project->name);
+   popup_fileselector_file_set(eina_strbuf_string_get(buf));
+   eina_strbuf_free(buf);
 }
 
 static Eina_Bool

-- 


Reply via email to