From 0569b1fa51a98c03e3d2d821ae6292a98cd83cae Mon Sep 17 00:00:00 2001 From: wenlong12 Date: Thu, 28 Jul 2022 14:51:36 +0800 Subject: [PATCH] del napi mock for bytrace Signed-off-by:wenlong12 Signed-off-by: wenlong12 --- interfaces/kits/BUILD.gn | 5 +-- interfaces/kits/js/napi/BUILD.gn | 22 +--------- interfaces/kits/js/napi/bytrace.cpp | 40 ------------------- .../kits/js/napi/bytrace_napi_common.cpp | 29 +++++++++++--- interfaces/kits/js/napi/hitracemeter.cpp | 40 ------------------- 5 files changed, 25 insertions(+), 111 deletions(-) delete mode 100644 interfaces/kits/js/napi/bytrace.cpp delete mode 100644 interfaces/kits/js/napi/hitracemeter.cpp diff --git a/interfaces/kits/BUILD.gn b/interfaces/kits/BUILD.gn index 4200e0f..175588b 100644 --- a/interfaces/kits/BUILD.gn +++ b/interfaces/kits/BUILD.gn @@ -15,9 +15,6 @@ import("//build/ohos.gni") group("jsapi_kits_target") { if (support_jsapi) { - deps = [ - "//developtools/bytrace/interfaces/kits/js/napi:bytrace", - "//developtools/bytrace/interfaces/kits/js/napi:hitracemeter_napi", - ] + deps = [ "//developtools/bytrace/interfaces/kits/js/napi:bytrace" ] } } diff --git a/interfaces/kits/js/napi/BUILD.gn b/interfaces/kits/js/napi/BUILD.gn index 2ae7512..c2bf5f4 100644 --- a/interfaces/kits/js/napi/BUILD.gn +++ b/interfaces/kits/js/napi/BUILD.gn @@ -15,27 +15,7 @@ import("//build/ohos.gni") import("//developtools/bytrace/bytrace.gni") ohos_shared_library("bytrace") { - sources = [ - "bytrace.cpp", - "bytrace_napi_common.cpp", - ] - deps = [ "//foundation/arkui/napi:ace_napi" ] - external_deps = [ - "hitrace_native:hitrace_meter", - "hiviewdfx_hilog_native:libhilog", - ] - - relative_install_dir = "module" - - subsystem_name = "developtools" - part_name = "bytrace" -} - -ohos_shared_library("hitracemeter_napi") { - sources = [ - "bytrace_napi_common.cpp", - "hitracemeter.cpp", - ] + sources = [ "bytrace_napi_common.cpp" ] deps = [ "//foundation/arkui/napi:ace_napi" ] external_deps = [ "hitrace_native:hitrace_meter", diff --git a/interfaces/kits/js/napi/bytrace.cpp b/interfaces/kits/js/napi/bytrace.cpp deleted file mode 100644 index 7388a92..0000000 --- a/interfaces/kits/js/napi/bytrace.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * 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 "bytrace_napi_common.h" - -using namespace OHOS::Developtools::BytraceNapi; - -/* - * bytrace module definition - */ -static napi_module bytrace_module = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = "bytrace", - .nm_register_func = BytraceInit, - .nm_modname = "bytrace", - .nm_priv = ((void *)0), - .reserved = {0} -}; - -/* - * Module registration - */ -extern "C" __attribute__((constructor)) void RegisterModule(void) -{ - napi_module_register(&bytrace_module); -} diff --git a/interfaces/kits/js/napi/bytrace_napi_common.cpp b/interfaces/kits/js/napi/bytrace_napi_common.cpp index 7a75fa7..2b708f2 100644 --- a/interfaces/kits/js/napi/bytrace_napi_common.cpp +++ b/interfaces/kits/js/napi/bytrace_napi_common.cpp @@ -168,13 +168,11 @@ static napi_value JSTraceCount(napi_env env, napi_callback_info info) return nullptr; } -namespace OHOS { -namespace Developtools { -namespace BytraceNapi { /* * function for module exports */ -napi_value BytraceInit(napi_env env, napi_value exports) +EXTERN_C_START +static napi_value BytraceInit(napi_env env, napi_value exports) { static napi_property_descriptor desc[] = { DECLARE_NAPI_FUNCTION("startTrace", JSTraceStart), @@ -184,6 +182,25 @@ napi_value BytraceInit(napi_env env, napi_value exports) NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc)); return exports; } -} -} +EXTERN_C_END + +/* + * bytrace module definition + */ +static napi_module bytrace_module = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = "bytrace", + .nm_register_func = BytraceInit, + .nm_modname = "bytrace", + .nm_priv = ((void *)0), + .reserved = {0} +}; + +/* + * Module registration + */ +extern "C" __attribute__((constructor)) void RegisterModule(void) +{ + napi_module_register(&bytrace_module); } diff --git a/interfaces/kits/js/napi/hitracemeter.cpp b/interfaces/kits/js/napi/hitracemeter.cpp deleted file mode 100644 index 3d105af..0000000 --- a/interfaces/kits/js/napi/hitracemeter.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * 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 "bytrace_napi_common.h" - -using namespace OHOS::Developtools::BytraceNapi; - -/* - * hiTraceMeter module definition - */ -static napi_module hitracemeter_module = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = "hiTraceMeter", - .nm_register_func = BytraceInit, - .nm_modname = "hiTraceMeter", - .nm_priv = ((void *)0), - .reserved = {0} -}; - -/* - * Module registration - */ -extern "C" __attribute__((constructor)) void RegisterModule(void) -{ - napi_module_register(&hitracemeter_module); -}