From cf2e284767f93805873f291a9dffc73853d8647c Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Mon, 9 Mar 2020 05:35:03 -0700 Subject: [PATCH] [Service] Refactor loading procedure for extension plugins The plugins.json is copied to tizen-extensions-crosswalk-service to be referred by extension loader. Note that this doesn't include plugins.json for release product tv to avoid conflicts with legacy wrt-service. Change-Id: I63e4aba3028db3398e0451a37d61dd19007eb35b Signed-off-by: Youngsoo Choi --- wrt_app/common/extensions.json => packaging/plugins.json | 0 packaging/wrtjs.spec | 11 +++++++++++ tizen/build/common.sh | 12 +++++++++--- wrt_app/common/wrt_xwalk_extension.js | 10 ++-------- 4 files changed, 22 insertions(+), 11 deletions(-) rename wrt_app/common/extensions.json => packaging/plugins.json (100%) diff --git a/wrt_app/common/extensions.json b/packaging/plugins.json similarity index 100% rename from wrt_app/common/extensions.json rename to packaging/plugins.json diff --git a/packaging/wrtjs.spec b/packaging/wrtjs.spec index 9d24b2f..1511dcc 100755 --- a/packaging/wrtjs.spec +++ b/packaging/wrtjs.spec @@ -7,6 +7,10 @@ License: Apache-2.0 URL: https://www.tizen.org Source: %{name}-%{version}.tar.gz +%if "%{?profile}" != "tv" || "%{?_local_build}" == "1" +%define crosswalk_extensions_service tizen-extensions-crosswalk-service +%endif + %if "%{?tizen_profile_name}" != "tv" BuildRequires: ninja BuildRequires: pkgconfig(dlog) @@ -45,6 +49,10 @@ install -d %{buildroot}%{_resourcedir} %endif %endif %endif +%if "%{?profile}" != "tv" || "%{?_local_build}" == "1" + mkdir -p %{buildroot}%{_libdir}/%{crosswalk_extensions_service} + cp packaging/plugins.json %{buildroot}%{_libdir}/%{crosswalk_extensions_service} +%endif cp -r wrt_app/* %{buildroot}%{_resourcedir}/ %post @@ -65,4 +73,7 @@ rm -fr %{buildroot} %if "%{_vd_cfg_product_type}" != "LFD" %{_datadir}/aul/wrt.loader %endif +%if "%{?profile}" != "tv" || "%{?_local_build}" == "1" + %{_libdir}/%{crosswalk_extensions_service}/plugins.json +%endif %{_resourcedir}/* diff --git a/tizen/build/common.sh b/tizen/build/common.sh index 806ed5d..e3c3137 100755 --- a/tizen/build/common.sh +++ b/tizen/build/common.sh @@ -32,6 +32,7 @@ function setupAndExecuteTargetBuild() { local PROFILE local ARCHITECTURE local CONF_FLAG + local LOCAL_BUILD=1 local -a ARGS # "|| :" means "or always succeeding built-in command" @@ -39,9 +40,7 @@ function setupAndExecuteTargetBuild() { ARCHITECTURE=$(echo "$@" | grep -Po "(?<=\-A\s)[^\s]*" | uniq || :) GBS_ROOT=$(echo "$@" | grep -Po "(?<=\-B\s)[^\s]*" | uniq || :) - local count=0 while [[ $# > 0 ]]; do - count=$(( $count + 1 )) case "$1" in --standard*) PROFILE=tz_$(echo $1 | sed 's/--//g') @@ -49,15 +48,22 @@ function setupAndExecuteTargetBuild() { --emulator*) PROFILE=tz_$(echo $1 | sed 's/--//g') ;; + --release) + LOCAL_BUILD=0 + ;; --tizen*) ;; *) - ARGS[$count]="$1" + ARGS+=("$1") ;; esac shift; done + if [ "$LOCAL_BUILD" == "1" ]; then + ARGS+=(--define "_local_build 1") + fi + if [ "$PROFILE" == "" ]; then if [[ $platform == "tv" ]]; then PROFILE=tztv_6.0_arm-nikem diff --git a/wrt_app/common/wrt_xwalk_extension.js b/wrt_app/common/wrt_xwalk_extension.js index 86a6575..d04b65f 100644 --- a/wrt_app/common/wrt_xwalk_extension.js +++ b/wrt_app/common/wrt_xwalk_extension.js @@ -21,18 +21,12 @@ var extensions_ = {}; class XWalkExtension { constructor() { - let plugins = require('./extensions.json'); - const binding = process.wrtBinding('wrt_xwalk_extension') var extensions = binding.getExtensions(); for (var i = 0; i < extensions.length; i++) { extensions[i].loaded = false; - for (var idx in plugins) { - if (extensions[i].name === plugins[idx].name) { - console.log("Load extension : " + extensions[i].name); - extensions_[extensions[i].name] = extensions[i]; - } - } + console.log("Load extension : " + extensions[i].name); + extensions_[extensions[i].name] = extensions[i]; } for (var name in extensions_) { if (!extensions_[name].use_trampoline) { -- 2.7.4