From: SangYong Park Date: Fri, 1 Feb 2019 01:43:06 +0000 (+0900) Subject: Add wrt-loader X-Git-Tag: submit/tizen/20190201.051141^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=947839dba6e1a946d418660cc4ce3a7d00722202;p=platform%2Fframework%2Fweb%2Fwrtjs.git Add wrt-loader wrt-loader is moved from chromium-efl Change-Id: Ic78fab2bcab3d688217154ba546ae1b85d3aa48c Signed-off-by: SangYong Park --- diff --git a/.gn b/.gn new file mode 100644 index 00000000..9fe0b422 --- /dev/null +++ b/.gn @@ -0,0 +1 @@ +buildconfig = "//BUILDCONFIG.gn" diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 00000000..1a9e2122 --- /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 index 00000000..4777b575 --- /dev/null +++ b/BUILDCONFIG.gn @@ -0,0 +1 @@ +set_default_toolchain("//:gcc") diff --git a/build/tools/gn b/build/tools/gn new file mode 100755 index 00000000..d76b38f3 Binary files /dev/null and b/build/tools/gn differ diff --git a/loader/BUILD.gn b/loader/BUILD.gn new file mode 100644 index 00000000..9dfc0def --- /dev/null +++ b/loader/BUILD.gn @@ -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 index 00000000..1f09e727 --- /dev/null +++ b/loader/wrt_loader.cc @@ -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 +#include + +// 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(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 index 00000000..632aa1f9 --- /dev/null +++ b/packaging/wrt.loader @@ -0,0 +1,6 @@ +[LOADER] +NAME wrt-loader +EXE /usr/bin/wrt-loader +APP_TYPE webapp +DETECTION_METHOD TIMEOUT|DEMAND +TIMEOUT 5000 diff --git a/packaging/wrtjs.spec b/packaging/wrtjs.spec index 758f4597..8e9886db 100755 --- a/packaging/wrtjs.spec +++ b/packaging/wrtjs.spec @@ -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}/*