nikawhite pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=2a4b0d1bd2b055c695cef0bfa00cd8b266cc2029

commit 2a4b0d1bd2b055c695cef0bfa00cd8b266cc2029
Author: Mykyta Biliavskyi <m.biliavs...@samsung.com>
Date:   Tue Aug 9 18:30:49 2016 +0300

    Project manager: add submodule project_manager_export_edj.
    
    This submodule implement export develop and release version
    of edj binary file.
    
    Currently implemented support only develop version.
---
 src/bin/Makefile.am                                |   1 +
 src/bin/project_manager/project_manager.c          |  91 ++--------------
 .../project_manager/project_manager_export_edj.c   | 114 +++++++++++++++++++++
 src/bin/project_manager/project_manager_private.h  |   4 +
 4 files changed, 129 insertions(+), 81 deletions(-)

diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index ae766c2..bd884f6 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -70,6 +70,7 @@ libete_a_SOURCES = \
 ../../src/bin/project_manager/project_manager_import_edc.c \
 ../../src/bin/project_manager/project_manager_export_resources.c \
 ../../src/bin/project_manager/project_manager_export_edc.c \
+../../src/bin/project_manager/project_manager_export_edj.c \
 ../../src/bin/project_manager/resource_manager.c \
 ../../src/bin/logger/logger.c \
 ../../src/bin/config/config.c \
diff --git a/src/bin/project_manager/project_manager.c 
b/src/bin/project_manager/project_manager.c
index 75d9857..fecab36 100644
--- a/src/bin/project_manager/project_manager.c
+++ b/src/bin/project_manager/project_manager.c
@@ -1055,79 +1055,6 @@ pm_project_release_export(Project *project,
      }
 }
 
-static void *
-_develop_export(void *data __UNUSED__,
-                Eina_Thread *thread __UNUSED__)
-{
-   Ecore_Event_Handler *cb_msg_stdout = NULL,
-                       *cb_msg_stderr = NULL;
-   Ecore_Exe_Flags flags  = ECORE_EXE_PIPE_READ |
-                            ECORE_EXE_PIPE_READ_LINE_BUFFERED |
-                            ECORE_EXE_PIPE_ERROR |
-                            ECORE_EXE_PIPE_ERROR_LINE_BUFFERED;
-   Eina_Tmpstr *tmp_filename = NULL;
-   Eina_Stringshare *cmd;
-   Eina_List *l;
-   Group *group;
-   Ecore_Exe *exe_cmd;
-   pid_t exe_pid;
-   int edje_pick_res = 0, waitpid_res = 0;
-
-   PROGRESS_SEND(_("Export project as develop file"));
-   PROGRESS_SEND(_("Export to file '%s'"), worker.edj);
-   CRIT_ON_FAIL(editor_save_all(worker.project->global_object));
-
-   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);
-     }
-
-   if (!ecore_file_exists(worker.edj))
-     cmd = eina_stringshare_printf("edje_pick -o %s", worker.edj);
-   else
-     {
-        eina_file_mkstemp("eflete_export_XXXXXX", &tmp_filename);
-        cmd = eina_stringshare_printf("edje_pick -o %s", tmp_filename);
-        cmd = eina_stringshare_printf("%s -a %s", cmd, worker.edj);
-     }
-   cmd = eina_stringshare_printf("%s -i %s", cmd, worker.project->dev);
-
-   EINA_LIST_FOREACH(worker.project->groups, l, group)
-     {
-        cmd = eina_stringshare_printf("%s -g %s", cmd, group->name);
-     }
-   DBG("Run command for export: %s", cmd);
-   exe_cmd = ecore_exe_pipe_run(cmd, flags, NULL);
-   exe_pid = ecore_exe_pid_get(exe_cmd);
-   THREAD_TESTCANCEL;
-   waitpid_res = waitpid(exe_pid, &edje_pick_res, 0);
-
-   if (worker.func_progress)
-     {
-        ecore_event_handler_del(cb_msg_stdout);
-        ecore_event_handler_del(cb_msg_stderr);
-     }
-
-   if ((waitpid_res == -1) ||
-       (WIFEXITED(edje_pick_res) && (WEXITSTATUS(edje_pick_res) != 0 )))
-     {
-        END_SEND(PM_PROJECT_ERROR);
-        return NULL;
-     }
-
-   if (tmp_filename)
-     {
-        ecore_file_recursive_rm(worker.edj);
-        ecore_file_mv(tmp_filename, worker.edj);
-     }
-
-   PROGRESS_SEND("Export done");
-
-   END_SEND(PM_PROJECT_SUCCESS);
-   return NULL;
-}
-
 void
 pm_project_develop_export(Project *project,
                           const char *path,
@@ -1138,15 +1065,17 @@ pm_project_develop_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;
 
-   if (!eina_thread_create(&worker.thread, EINA_THREAD_URGENT, -1,
-                           (void *)_develop_export, NULL))
-     {
-        ERR("System error: can't create thread");
-        abort();
-     }
+   ptd = mem_calloc(1, sizeof(Project_Thread));
+   ptd->func_progress = func_progress;
+   ptd->func_end = func_end;
+   ptd->data = (void *)data;
+   ptd->project = project;
+   ptd->result = PM_PROJECT_LAST;
+   ptd->path = eina_stringshare_add(path);
+
+   _develop_export(ptd);
 }
 
 #ifdef HAVE_ENVENTOR
diff --git a/src/bin/project_manager/project_manager_export_edj.c 
b/src/bin/project_manager/project_manager_export_edj.c
new file mode 100644
index 0000000..8cdc38d
--- /dev/null
+++ b/src/bin/project_manager/project_manager_export_edj.c
@@ -0,0 +1,114 @@
+/*
+ * Efl Edje Theme Editor
+ * Copyright (C) 2013-2016 Samsung Electronics.
+ *
+ * This file is part of Edje Theme Editor.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; If not, see www.gnu.org/licenses/lgpl.html.
+ */
+#include "project_manager.h"
+#include "project_manager_private.h"
+
+/* Export develop edj file */
+static Eina_Bool
+_develop_edj_export_data_cb(void *data __UNUSED__,
+                     int type __UNUSED__,
+                     void *event_info)
+{
+   Project_Thread *ptd = (Project_Thread *)data;
+   Ecore_Exe_Event_Data *edje_pick_msg = (Ecore_Exe_Event_Data *)event_info;
+   int i = 0;
+
+   for (i = 0; edje_pick_msg->lines[i].line != NULL; i++)
+      ptd->func_progress(NULL, edje_pick_msg->lines[i].line);
+
+   return ECORE_CALLBACK_DONE;
+}
+
+static Eina_Bool
+_develop_edj_export_del_cb(void *data,
+                     int type __UNUSED__,
+                     void *event_info __UNUSED__)
+{
+   Project_Thread *ptd = (Project_Thread *)data;
+   Ecore_Exe_Event_Del *edje_pick_exit = (Ecore_Exe_Event_Del *)event_info;
+   Eina_Stringshare *msg = NULL;
+
+   if (edje_pick_exit->exit_code != 0)
+     {
+        msg = eina_stringshare_printf(_("Export to file '%s' FAILED"), 
ptd->path);
+        ptd->func_progress(NULL, msg);
+        eina_stringshare_del(msg);
+
+        ptd->result = PM_PROJECT_ERROR;
+        _end_send(ptd);
+        return ECORE_CALLBACK_DONE;
+     }
+
+   if (ptd->tmp_dirname)
+     {
+        ecore_file_recursive_rm(ptd->path);
+        ecore_file_mv(ptd->tmp_dirname, ptd->path);
+        eina_stringshare_del(ptd->tmp_dirname);
+        ptd->tmp_dirname = NULL;
+     }
+   msg = eina_stringshare_printf(_("Export to file '%s' successfull"), 
ptd->path);
+   ptd->func_progress(NULL, msg);
+   eina_stringshare_del(msg);
+
+  ptd->result = PM_PROJECT_SUCCESS;
+  _end_send(ptd);
+
+  return ECORE_CALLBACK_DONE;
+}
+
+void
+_develop_export(Project_Thread *ptd)
+{
+   Ecore_Exe_Flags flags  = ECORE_EXE_PIPE_READ |
+                            ECORE_EXE_PIPE_READ_LINE_BUFFERED |
+                            ECORE_EXE_PIPE_ERROR |
+                            ECORE_EXE_PIPE_ERROR_LINE_BUFFERED;
+   Eina_Stringshare *cmd;
+   Eina_List *l;
+   Group *group;
+
+   CRIT_ON_FAIL(editor_save_all(ptd->project->global_object));
+   Eina_Stringshare *msg = eina_stringshare_printf(_("Export to file '%s'"), 
ptd->path);
+   ptd->func_progress(NULL, msg);
+   eina_stringshare_del(msg);
+
+   if (!ecore_file_exists(ptd->path))
+     cmd = eina_stringshare_printf("edje_pick -o %s", ptd->path);
+   else
+     {
+        eina_file_mkstemp("eflete_export_XXXXXX", &ptd->tmp_dirname);
+        cmd = eina_stringshare_printf("edje_pick -o %s", ptd->tmp_dirname);
+        cmd = eina_stringshare_printf("%s -a %s", cmd, ptd->path);
+     }
+   cmd = eina_stringshare_printf("%s -i %s", cmd, ptd->project->dev);
+
+   EINA_LIST_FOREACH(ptd->project->groups, l, group)
+     {
+        cmd = eina_stringshare_printf("%s -g %s", cmd, group->name);
+     }
+   DBG("Run command for export: %s", cmd);
+   ecore_exe_pipe_run(cmd, flags, NULL);
+
+   ptd->data_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DATA, 
_develop_edj_export_data_cb, ptd);
+   ptd->error_handler = ecore_event_handler_add(ECORE_EXE_EVENT_ERROR, 
_develop_edj_export_data_cb, ptd);
+   ptd->del_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, 
_develop_edj_export_del_cb, ptd);
+
+   return;
+}
+
diff --git a/src/bin/project_manager/project_manager_private.h 
b/src/bin/project_manager/project_manager_private.h
index 731fe91..942aadc 100644
--- a/src/bin/project_manager/project_manager_private.h
+++ b/src/bin/project_manager/project_manager_private.h
@@ -215,4 +215,8 @@ void _group_source_code_export_feedback_job(void *data, 
Ecore_Thread *th);
 void _group_source_code_export_feedback_cb(void *data, Ecore_Thread *th, void 
*msg_data);
 void _group_source_code_export_end_cb(void *data, Ecore_Thread *th);
 void _group_source_code_export_cancel_cb(void *data, Ecore_Thread *th);
+
+/*------ Export edj binary--------------*/
+void _develop_export(Project_Thread *ptd);
+
 #endif

-- 


Reply via email to