Getting application data using wrt common library. 37/168837/3
authorjinwoo jeong <jw00.jeong@samsung.com>
Wed, 31 Jan 2018 08:59:22 +0000 (17:59 +0900)
committermin7.choi <min7.choi@samsung.com>
Mon, 26 Feb 2018 07:57:04 +0000 (16:57 +0900)
To use wrt common library, it should be complied to shared library.
Because it has many dependency with system libraries.

In wrt common, there are CommandLine and ApplicationData modules.
Using those modules, the arguements can be parsed.
And electron can get more information from app db or app control.

Change-Id: Idb7f906b240de01f04ad4ed145266e23615ef4d3
Signed-off-by: jinwoo jeong <jw00.jeong@samsung.com>
atom/app/atom_main.cc
electron.gyp
packaging/electron-efl.spec
tizen/common/common.gyp
tizen/loader/loader.gyp
tizen/loader/wrt_loader.cc

index 0d6ea8b..49625a6 100644 (file)
@@ -37,6 +37,9 @@
 #include "base/i18n/icu_util.h"
 
 #if defined(OS_TIZEN)
+#include "base/logging.h"
+#include "tizen/common/application_data.h"
+#include "tizen/common/command_line.h"
 #include "tizen/loader/prelauncher.h"
 #include "base/logging.h"
 #endif
@@ -144,9 +147,18 @@ int main(int argc, char* argv[]) {
   }
 
 #if defined(USE_EFL)
-  if (argv[0] == "/usr/bin/electron")  // not browser process
-    base::CommandLine::Init(argc, argv);
-  else if (efl::Initialize(argc, const_cast<const char**>(argv)))
+  common::CommandLine::Init(argc, argv);
+  common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess();
+  std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/electron");
+
+  // load manifest
+  auto appdata_manager = common::ApplicationDataManager::GetInstance();
+  common::ApplicationData* appdata = appdata_manager->GetApplicationData(appid);
+  if (!appdata->LoadManifestData()) {
+    return false;
+  }
+
+  if (efl::Initialize(argc, const_cast<const char**>(argv)))
     return 1;
 
   // Add params for EFL port
index dda2dff..d876687 100644 (file)
           ],
         }],  # OS=="linux"
         ['is_tizen==1', {
+          'includes': [
+            'tizen/build/common.gypi',
+          ],
           'dependencies': [
-            'tizen/common/common.gyp:*',
-            'tizen/loader/loader.gyp:*',
+            'tizen/common/common.gyp:wrt_common',
+            'tizen/loader/loader.gyp:wrt-loader',
             '<(DEPTH)/efl/build/system.gyp:ecore',
             '<(DEPTH)/efl/build/system.gyp:launchpad',
           ],
+          'sources': [
+            'tizen/loader/prelauncher.h',
+            'tizen/loader/prelauncher.cc',
+          ],
           'ldflags': [
             '-pie',
             '-export-dynamic',
           ],
-          'cflags': [ '-fPIC' ],
-          'cflags_cc': [ '-fPIC' ],
         }],  # is_tizen==1
       ],
     },  # target <(project_name)
index f909978..42f9c65 100755 (executable)
@@ -105,6 +105,10 @@ install -m 0644 %{_out}/packaging/%{_pkgid}.xml %{buildroot}%{_xmldir}
 mkdir -p %{buildroot}%{_datadir}/aul/
 cp %{SOURCE1002} %{buildroot}%{_datadir}/aul/
 
+# wrt_common
+mkdir -p %{buildroot}%{_libdir}
+install -p -m 644 %{_out}/lib/libwrt_common.so %{buildroot}%{_libdir}
+
 mkdir -p %{buildroot}/usr/apps/org.tizen.electron-efl/bin/
 install -d %{buildroot}/%{_icondir}
 install -d %{buildroot}/%{_libdir}
@@ -162,3 +166,4 @@ rm -fr %{buildroot}
 %attr(755,root,root) %{_bindir}/wrt-loader
 %attr(755,root,root) %{_bindir}/xwalk_runtime
 %attr(644,root,root) %{_datadir}/aul/wrt.loader
+%attr(644,root,root) %{_libdir}/libwrt_common.so
index 25d27a8..7d56a2e 100644 (file)
@@ -5,7 +5,7 @@
   'targets': [
     {
       'target_name': 'wrt_common',
-      'type': 'static_library',
+      'type': 'shared_library',
       'sources': [
         'command_line.h',
         'command_line.cc',
index 14d1fdc..d71af00 100755 (executable)
@@ -1,4 +1,7 @@
 {
+  'includes': [
+    '../build/common.gypi',
+  ],
   'targets': [
     {
       'target_name': 'wrt-loader',
       'libraries' : [
         '-ldl',
       ],
-      'include_dirs': [
-        '<(libchromiumcontent_src_dir)',
-      ],
       'ldflags': [
-        '-Wl,--whole-archive',
-        '<@(libchromiumcontent_libraries)',
-        '-Wl,--no-whole-archive',
+        '-pie',
       ],
-      'link_settings': {
-        'libraries': [
-          '<@(libchromiumcontent_libraries)',
-        ]
+      'variables': {
+        'packages': [
+          'dlog',
+        ],
       },
     },  # end of target 'wrt-loader'
-    {
-      'target_name': 'prelauncher',
-      'type': 'static_library',
-      'dependencies': [
-        '<(DEPTH)/efl/build/system.gyp:ecore',
-        '<(DEPTH)/efl/build/system.gyp:launchpad',
-      ],
-      'include_dirs': [
-        '<(libchromiumcontent_src_dir)',
-      ],
-      'cflags': [ '-fPIC' ],
-      'cflags_cc': [ '-fPIC' ],
-      'sources': [
-        'prelauncher.cc',
-        'prelauncher.h',
-      ],
-    },  # end of target 'preloader'
   ],
 }
index 57b9d3b..bb91449 100644 (file)
  *    limitations under the License.
  */
 #include <dlfcn.h>
-#include "base/logging.h"
+#include <dlog.h>
 
 // loader file must have "User" execute label, because launchpad daemon runs
 // with "System::Privileged" label.
 int main(int argc, char* argv[]) {
-  LOG(INFO) << "Begin wrt-loader";
+  dlog_print(DLOG_INFO, "CHROMIUM", "Begin wrt-loader");
   void* handle = dlopen("/usr/bin/electron", RTLD_NOW);
   if (!handle) {
-    LOG(ERROR) << "Failed to load electorn";
+    dlog_print(DLOG_ERROR, "CHROMIUM", "Failed to load electorn");
     return false;
   }
 
@@ -30,7 +30,7 @@ int main(int argc, char* argv[]) {
 
   MAIN_FUNC real_main = reinterpret_cast<MAIN_FUNC>(dlsym(handle, "main"));
   if (!real_main) {
-    LOG(ERROR) << "Failed to load real_main";
+    dlog_print(DLOG_ERROR, "CHROMIUM", "Failed to load real_main");
     return false;
   }