Add wrt-loader 26/199026/1 accepted/tizen/unified/20190207.120337 submit/tizen/20190201.051141
authorSangYong Park <sy302.park@samsung.com>
Fri, 1 Feb 2019 01:43:06 +0000 (10:43 +0900)
committerSangYong Park <sy302.park@samsung.com>
Fri, 1 Feb 2019 01:43:06 +0000 (10:43 +0900)
wrt-loader is moved from chromium-efl

Change-Id: Ic78fab2bcab3d688217154ba546ae1b85d3aa48c
Signed-off-by: SangYong Park <sy302.park@samsung.com>
.gn [new file with mode: 0644]
BUILD.gn [new file with mode: 0644]
BUILDCONFIG.gn [new file with mode: 0644]
build/tools/gn [new file with mode: 0755]
loader/BUILD.gn [new file with mode: 0644]
loader/wrt_loader.cc [new file with mode: 0644]
packaging/wrt.loader [new file with mode: 0644]
packaging/wrtjs.spec

diff --git a/.gn b/.gn
new file mode 100644 (file)
index 0000000..9fe0b42
--- /dev/null
+++ b/.gn
@@ -0,0 +1 @@
+buildconfig = "//BUILDCONFIG.gn"
diff --git a/BUILD.gn b/BUILD.gn
new file mode 100644 (file)
index 0000000..1a9e212
--- /dev/null
+++ b/BUILD.gn
@@ -0,0 +1,36 @@
+toolchain("gcc") {
+  lib_switch = "-l"
+  lib_dir_switch = "-L"
+
+  tool("cc") {
+    depfile = "{{output}}.d"
+    command = "gcc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
+    depsformat = "gcc"
+    outputs = [ "{{target_out_dir}}/{{source_name_part}}.o" ]
+  }
+  tool("cxx") {
+    depfile = "{{output}}.d"
+    command = "c++ -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
+    depsformat = "gcc"
+    description = "CXX {{output}}"
+    outputs = [ "{{target_out_dir}}/{{source_name_part}}.o" ]
+  }
+  tool("link") {
+    exename = "{{target_output_name}}{{output_extension}}"
+    outfile = "{{output_dir}}/$exename"
+    default_output_dir = "{{root_out_dir}}"
+    command = "g++ {{ldflags}} -o \"$outfile\" {{inputs}} {{libs}}"
+    description = "LINK $outfile"
+    outputs = [ outfile ]
+  }
+  tool("stamp") {
+    command = "touch {{output}}"
+    description = "STAMP {{output}}"
+  }
+}
+
+group("wrt_group") {
+  deps = [
+    "//loader:wrt-loader",
+  ]
+}
diff --git a/BUILDCONFIG.gn b/BUILDCONFIG.gn
new file mode 100644 (file)
index 0000000..4777b57
--- /dev/null
@@ -0,0 +1 @@
+set_default_toolchain("//:gcc")
diff --git a/build/tools/gn b/build/tools/gn
new file mode 100755 (executable)
index 0000000..d76b38f
Binary files /dev/null and b/build/tools/gn differ
diff --git a/loader/BUILD.gn b/loader/BUILD.gn
new file mode 100644 (file)
index 0000000..9dfc0de
--- /dev/null
@@ -0,0 +1,11 @@
+config("executable_config") {
+  cflags = [ "-fPIE" ]
+  asmflags = [ "-fPIE" ]
+  ldflags = [ "-pie" ]
+}
+
+executable("wrt-loader") {
+  sources = [ "wrt_loader.cc" ]
+  libs = [ "dl", "dlog" ]
+  configs = [ ":executable_config" ]
+}
diff --git a/loader/wrt_loader.cc b/loader/wrt_loader.cc
new file mode 100644 (file)
index 0000000..1f09e72
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+#include <dlfcn.h>
+#include <dlog/dlog.h>
+
+// loader file must have "User" execute label, because launchpad daemon runs
+// with "System::Privileged" label.
+int main(int argc, char* argv[]) {
+  dlog_print(DLOG_INFO, "CHROMIUM", "Begin wrt-loader");
+  void* handle = dlopen("/usr/bin/wrt", RTLD_NOW);
+  if (!handle) {
+    dlog_print(DLOG_ERROR, "CHROMIUM", "Failed to load wrt (%s)", dlerror());
+    return 1;
+  }
+
+  typedef int (*MAIN_FUNC)(int argc, char* argv[]);
+
+  MAIN_FUNC real_main = reinterpret_cast<MAIN_FUNC>(dlsym(handle, "main"));
+  if (!real_main) {
+    dlog_print(DLOG_ERROR, "CHROMIUM", "Failed to load real_main (%s)", dlerror());
+    return 1;
+  }
+
+  int ret = real_main(argc, argv);
+  dlclose(handle);
+
+  return ret;
+}
diff --git a/packaging/wrt.loader b/packaging/wrt.loader
new file mode 100644 (file)
index 0000000..632aa1f
--- /dev/null
@@ -0,0 +1,6 @@
+[LOADER]
+NAME              wrt-loader
+EXE               /usr/bin/wrt-loader
+APP_TYPE          webapp
+DETECTION_METHOD  TIMEOUT|DEMAND
+TIMEOUT           5000
index 758f459..8e9886d 100755 (executable)
@@ -5,23 +5,42 @@ Release:    1
 Group:      Web Framework/Web Runtime
 License:    Apache-2.0
 URL:        https://www.tizen.org
-Source:    %{name}-%{version}.tar.gz
+Source:     %{name}-%{version}.tar.gz
 
-BuildRequires: python, ninja, nodejs, nodejs-npm
+%if "%{?tizen_profile_name}" != "tv"
+BuildRequires: ninja
+BuildRequires: pkgconfig(dlog)
+%endif
 
 %description
-Web Runtime Engine based on Electron EFL
+Web Runtime Engine based on Electron
 
 %prep
 %setup -q
 
 %build
-%define _resourcedir /usr/share/chromium-efl/wrt/app
+%if "%{?tizen_profile_name}" != "tv"
+  %define _outdir $PWD/out
+  ./build/tools/gn gen %{_outdir}
+  ninja -C %{_outdir} wrt-loader
+%endif
 
 %install
+%define _resourcedir /usr/share/chromium-efl/wrt/app
+install -d %{buildroot}%{_bindir}
+install -d %{buildroot}%{_datadir}/aul
 install -d %{buildroot}%{_resourcedir}
+
+%if "%{?tizen_profile_name}" != "tv"
+  install -m 0755 %{_outdir}/wrt-loader %{buildroot}%{_bindir}
+%else
+  ln -s %{_bindir}/wrt %{buildroot}%{_bindir}/wrt-loader
+%endif
+install -m 0644 packaging/wrt.loader %{buildroot}%{_datadir}/aul/
 cp -r wrt_app/* %{buildroot}%{_resourcedir}/
 
+%post
+
 %postun
 
 %clean
@@ -30,4 +49,10 @@ rm -fr %{buildroot}
 %files
 %manifest packaging/wrtjs.manifest
 %license LICENSE
+%if "%{?tizen_profile_name}" != "tv"
+  %caps(cap_setgid,cap_sys_admin=ei) %{_bindir}/wrt-loader
+%else
+  %{_bindir}/wrt-loader
+%endif
+%{_datadir}/aul/wrt.loader
 %{_resourcedir}/*