Add widget object to electron interface 00/181000/2
authorPrathmesh <prathmesh.m@samsung.com>
Thu, 7 Jun 2018 07:13:41 +0000 (12:43 +0530)
committerPrathmesh <prathmesh.m@samsung.com>
Thu, 7 Jun 2018 07:25:41 +0000 (12:55 +0530)
- Generate the idls
- Build extension independently and add to extension
  libs

Change-Id: Ida4361a75267341ffca46c4d96369a973311e839
Signed-off-by: Prathmesh <prathmesh.m@samsung.com>
packaging/electron-efl.spec
tizen/build/common.gypi
tizen/extensions/extensions.gyp
tizen/tools/generate_api.py [new file with mode: 0644]
tizen/tools/mergejs.py [new file with mode: 0644]
wrt.gyp

index 7e464c1..93ce41f 100755 (executable)
@@ -70,13 +70,14 @@ cp %{SOURCE1001} .
 %define _pkgid org.tizen.%{name}
 %define _xmldir %TZ_SYS_RO_PACKAGES
 %define _out out.tizen/out/D
+%define extension_path %{_libdir}/tizen-extensions-crosswalk
 
 DEFINE_ARGS="
     libchromiumcontent_component=1
     use_efl=1
     is_tizen=1
     injected_bundle_path=%{_libdir}/libxwalk_injected_bundle.so
-    extension_path=%{_libdir}/tizen-extensions-crosswalk
+    extension_path=%{extension_path}
 "
 %if "%{?TIZEN_PRODUCT_TV}" == "1"
 DEFINE_ARGS+="
@@ -140,6 +141,10 @@ mkdir -p %{buildroot}%{extension_path}
 install -p -m 644 %{_out}/lib/libxwalk_extension_shared.so %{buildroot}%{_libdir}
 # xwalk_injected_bundle
 install -p -m 755 %{_out}/lib/libxwalk_injected_bundle.so %{buildroot}%{_libdir}
+# widget plugin
+install -p -m 644 %{_out}/lib/libwidget_plugin.so %{buildroot}%{extension_path}
+install -p -m 644 %{_out}/gen/widget.json %{buildroot}%{extension_path}
+
 %post
 # Owner account can't write /opt/usr/home/owner/data/org.tizen.electron-efl
 # which is created in 'install'. So we should copy resources in 'post'.
@@ -172,3 +177,5 @@ rm -fr %{buildroot}
 %attr(644,root,root) %{_libdir}/libwrt_common.so
 %attr(644,root,root) %{_libdir}/libxwalk_extension_shared.so
 %attr(644,root,root) %{_libdir}/libxwalk_injected_bundle.so
+%attr(644,root,root) %{extension_path}/libwidget_plugin.so
+%attr(644,root,root) %{extension_path}/widget.json
index 8b70ac2..6b4560f 100644 (file)
@@ -30,7 +30,7 @@
     'includes': [
       'cynara-client.gypi',
       'pkg-config.gypi',
-#      'xwalk_js2c.gypi',
+      'xwalk_js2c.gypi',
     ],
     'include_dirs': [
       '../',
index 652dfd1..db9f91c 100644 (file)
         },
       },
     }, # end of target 'xwalk_extension_static'
+    {
+      'target_name': 'widget_plugin',
+      'type': 'shared_library',
+      'sources': [
+        'internal/widget/widget_api.js',
+        'internal/widget/widget_extension.cc',
+      ],
+      'variables': {
+        'packages': [
+          'dlog',
+        ],
+      },
+      'copies': [
+        {
+          'destination': '<(SHARED_INTERMEDIATE_DIR)',
+          'files': [
+            'internal/widget/widget.json'
+          ],
+        },
+      ],
+    }, # end of target 'widget_plugin'
   ], # end of targets
 }
diff --git a/tizen/tools/generate_api.py b/tizen/tools/generate_api.py
new file mode 100644 (file)
index 0000000..b50adea
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2013 Intel Corporation. All rights reserved.
+# Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import sys
+import subprocess
+
+TEMPLATE = """\
+extern const char %s[];
+const char %s[] = { %s, 0 };
+"""
+
+js_code = sys.argv[1]
+cmd = "python " + os.path.dirname(__file__) + "/mergejs.py -f" + js_code
+lines = subprocess.check_output(cmd, shell=True)
+c_code = ', '.join(str(ord(c)) for c in lines)
+
+symbol_name = sys.argv[2]
+output = open(sys.argv[3], "w")
+output.write(TEMPLATE % (symbol_name, symbol_name, c_code))
+output.close()
diff --git a/tizen/tools/mergejs.py b/tizen/tools/mergejs.py
new file mode 100644 (file)
index 0000000..fc3dc96
--- /dev/null
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+
+import fileinput
+import sys
+import getopt
+import glob
+import os
+
+class Utils:
+    reqfiles = []
+    searchfile = '*_api.js'
+    startwith = "//= require('"
+    endwith = "')"
+    code = ""
+
+    @classmethod
+    def get_require(self, s):
+        try:
+            start = s.index(self.startwith) + len(self.startwith)
+            end = s.index(self.endwith, start)
+            filename = s[start:end]
+            self.reqfiles.append(filename)
+        except ValueError:
+           return ""
+
+    @classmethod
+    def find_require(self):
+        p = os.path.join('./', self.searchfile)
+        filenames = glob.glob(self.searchfile)
+        for fname in filenames:
+            with open(fname, 'r') as myfile:
+                for line in myfile:
+                    self.get_require(line)
+
+    @classmethod
+    def print_lines(self, filename):
+        with open(filename, 'r') as file:
+            for line in file:
+                self.code += line
+
+    @classmethod
+    def merge_js_files(self, path):
+        self.find_require()
+        if len(self.reqfiles) == 0:
+            s = os.path.join('./', self.searchfile)
+            sfiles = glob.glob(s)
+            for fname in sfiles:
+                self.print_lines(fname)
+        else:
+            js = '*.js'
+            p = os.path.join(path, js)
+            filenames = glob.glob(p)
+            for fname in self.reqfiles:
+                fname = path + '/' + fname
+                if fname in filenames:
+                    self.print_lines(fname)
+
+    @classmethod
+    def main(self, argv):
+        path = 'js'
+        try:
+            opts, args = getopt.getopt(argv,"hf:p:",["file=", "path="])
+        except getopt.GetoptError:
+            print __file__ + ' -h'
+            sys.exit()
+        if len(argv) > 0:
+          for opt, arg in opts:
+              if opt in ("-h"):
+                  print 'Help:'
+                  print ''
+                  print __file__ + '-f <file> -p <path>'
+                  print ''
+                  print '<opt> \t <opt> \t\t <description>'
+                  print '-f \t --file \t Name of the file where script searching for require files:'
+                  print '\t \t \t ' + self.startwith + 'file_name.js' + self.endwith
+                  print '-p \t --path \t Path to "' + path + '" directory'
+                  print ''
+                  sys.exit()
+              elif opt in ("-f", "--file"):
+                  self.searchfile = arg
+              elif opt in ("-p", "--path"):
+                  path = arg
+        self.merge_js_files(path)
+        print self.code
+
+if Utils.__module__ == "__main__":
+    Utils.main(sys.argv[1:])
diff --git a/wrt.gyp b/wrt.gyp
index 663ee2c..38a9337 100644 (file)
--- a/wrt.gyp
+++ b/wrt.gyp
         },
       ],
     },  # target electron_shell_copy
+    {
+      'target_name': 'extension_wrt',
+      'type': 'none',
+      'dependencies': [
+          '<(DEPTH)/tizen/extensions/extensions.gyp:widget_plugin',
+      ],
+    }, # end of target 'extension_wrt'
   ],
 }