init 24.03 files

This commit is contained in:
yykk 2024-04-22 17:35:17 +08:00
parent 0e7f290b5f
commit b13e09c6f9
6 changed files with 570 additions and 0 deletions

View File

@ -0,0 +1,263 @@
diff --git a/frameworks/eventhandler/BUILD.gn b/frameworks/eventhandler/BUILD.gn
index ceed950..7342337 100644
--- a/frameworks/eventhandler/BUILD.gn
+++ b/frameworks/eventhandler/BUILD.gn
@@ -37,7 +37,7 @@ ohos_shared_library("libeventhandler") {
public_configs = [ ":public_libeventhandler_config" ]
external_deps = [
- "hitrace_native:libhitracechain",
+ # "hitrace_native:libhitracechain",
"hiviewdfx_hilog_native:libhilog",
]
diff --git a/frameworks/eventhandler/include/event_handler_utils.h b/frameworks/eventhandler/include/event_handler_utils.h
index 72fbdac..37e862f 100644
--- a/frameworks/eventhandler/include/event_handler_utils.h
+++ b/frameworks/eventhandler/include/event_handler_utils.h
@@ -22,7 +22,7 @@
#include <string>
#include "hilog/log.h"
-#include "hitrace/trace.h"
+// #include "hitrace/trace.h"
#include "inner_event.h"
#define DEFINE_HILOG_LABEL(name) \
@@ -66,30 +66,30 @@ static inline int32_t NanosecondsToTimeout(int64_t nanoseconds)
return (milliseconds > INT32_MAX) ? INT32_MAX : static_cast<int32_t>(milliseconds);
}
-using HiTraceChain = OHOS::HiviewDFX::HiTraceChain;
+// using HiTraceChain = OHOS::HiviewDFX::HiTraceChain;
static inline bool AllowHiTraceOutPut(const std::shared_ptr<HiTraceId>& traceId, bool isSyncEvent)
{
- if ((!traceId) || (!traceId->IsValid())) {
- return false;
- }
- if ((!isSyncEvent) && (!traceId->IsFlagEnabled(HITRACE_FLAG_INCLUDE_ASYNC))) {
- return false;
- }
+ // if ((!traceId) || (!traceId->IsValid())) {
+ // return false;
+ // }
+ // if ((!isSyncEvent) && (!traceId->IsFlagEnabled(HITRACE_FLAG_INCLUDE_ASYNC))) {
+ // return false;
+ // }
return true;
}
-static inline void HiTracePointerOutPut(const std::shared_ptr<HiTraceId>& spanId,
- const InnerEvent::Pointer& event, const char* action, HiTraceTracepointType type)
-{
- if (!event->HasTask()) {
- HiTraceChain::Tracepoint(type, *spanId, "%s event, event id: %d", action, event->GetInnerEventId());
- } else if (!event->GetTaskName().empty()) {
- HiTraceChain::Tracepoint(type, *spanId, "%s task with name, name: %s", action, event->GetTaskName().c_str());
- } else {
- HiTraceChain::Tracepoint(type, *spanId, "%s UnNamed Task", action);
- }
-}
+// static inline void HiTracePointerOutPut(const std::shared_ptr<HiTraceId>& spanId,
+// const InnerEvent::Pointer& event, const char* action, HiTraceTracepointType type)
+// {
+// if (!event->HasTask()) {
+// HiTraceChain::Tracepoint(type, *spanId, "%s event, event id: %d", action, event->GetInnerEventId());
+// } else if (!event->GetTaskName().empty()) {
+// HiTraceChain::Tracepoint(type, *spanId, "%s task with name, name: %s", action, event->GetTaskName().c_str());
+// } else {
+// HiTraceChain::Tracepoint(type, *spanId, "%s UnNamed Task", action);
+// }
+// }
static inline void GetLastErr(char *errmsg, size_t size = MAX_ERRORMSG_LEN)
{
diff --git a/frameworks/eventhandler/src/event_handler.cpp b/frameworks/eventhandler/src/event_handler.cpp
index ab6e876..8477424 100644
--- a/frameworks/eventhandler/src/event_handler.cpp
+++ b/frameworks/eventhandler/src/event_handler.cpp
@@ -74,11 +74,11 @@ bool EventHandler::SendEvent(InnerEvent::Pointer &event, int64_t delayTime, Prio
event->SetOwner(shared_from_this());
// get traceId from event, if HiTraceChain::begin has been called, would get a valid trace id.
- auto traceId = event->GetOrCreateTraceId();
+ // auto traceId = event->GetOrCreateTraceId();
// if traceId is valid, out put trace information
- if (AllowHiTraceOutPut(traceId, event->HasWaiter())) {
- HiTracePointerOutPut(traceId, event, "Send", HiTraceTracepointType::HITRACE_TP_CS);
- }
+ // if (AllowHiTraceOutPut(traceId, event->HasWaiter())) {
+ // HiTracePointerOutPut(traceId, event, "Send", HiTraceTracepointType::HITRACE_TP_CS);
+ // }
eventRunner_->GetEventQueue()->Insert(event, priority);
return true;
@@ -117,7 +117,7 @@ bool EventHandler::SendSyncEvent(InnerEvent::Pointer &event, Priority priority)
}
// get traceId from event, if HiTraceChain::begin has been called, would get a valid trace id.
- auto spanId = event->GetOrCreateTraceId();
+ // auto spanId = event->GetOrCreateTraceId();
// Create waiter, used to block.
auto waiter = event->CreateWaiter();
@@ -128,9 +128,9 @@ bool EventHandler::SendSyncEvent(InnerEvent::Pointer &event, Priority priority)
// Wait until event is processed(recycled).
waiter->Wait();
- if ((spanId) && (spanId->IsValid())) {
- HiTraceChain::Tracepoint(HiTraceTracepointType::HITRACE_TP_CR, *spanId, "event is processed");
- }
+ // if ((spanId) && (spanId->IsValid())) {
+ // HiTraceChain::Tracepoint(HiTraceTracepointType::HITRACE_TP_CR, *spanId, "event is processed");
+ // }
return true;
}
@@ -305,13 +305,13 @@ void EventHandler::DistributeEvent(const InnerEvent::Pointer &event)
currentEventHandler = shared_from_this();
- auto spanId = event->GetTraceId();
- auto traceId = HiTraceChain::GetId();
- bool allowTraceOutPut = AllowHiTraceOutPut(spanId, event->HasWaiter());
- if (allowTraceOutPut) {
- HiTraceChain::SetId(*spanId);
- HiTracePointerOutPut(spanId, event, "Receive", HiTraceTracepointType::HITRACE_TP_SR);
- }
+ // auto spanId = event->GetTraceId();
+ // auto traceId = HiTraceChain::GetId();
+ // bool allowTraceOutPut = AllowHiTraceOutPut(spanId, event->HasWaiter());
+ // if (allowTraceOutPut) {
+ // HiTraceChain::SetId(*spanId);
+ // HiTracePointerOutPut(spanId, event, "Receive", HiTraceTracepointType::HITRACE_TP_SR);
+ // }
InnerEvent::TimePoint nowStart = InnerEvent::Clock::now();
DeliveryTimeAction(event, nowStart);
@@ -326,13 +326,13 @@ void EventHandler::DistributeEvent(const InnerEvent::Pointer &event)
DistributeTimeAction(event, nowStart);
- if (allowTraceOutPut) {
- HiTraceChain::Tracepoint(HiTraceTracepointType::HITRACE_TP_SS, *spanId, "Event Distribute over");
- HiTraceChain::ClearId();
- if (traceId.IsValid()) {
- HiTraceChain::SetId(traceId);
- }
- }
+ // if (allowTraceOutPut) {
+ // HiTraceChain::Tracepoint(HiTraceTracepointType::HITRACE_TP_SS, *spanId, "Event Distribute over");
+ // HiTraceChain::ClearId();
+ // if (traceId.IsValid()) {
+ // HiTraceChain::SetId(traceId);
+ // }
+ // }
}
void EventHandler::Dump(Dumper &dumper)
diff --git a/frameworks/eventhandler/src/inner_event.cpp b/frameworks/eventhandler/src/inner_event.cpp
index 654b44e..90e0c49 100644
--- a/frameworks/eventhandler/src/inner_event.cpp
+++ b/frameworks/eventhandler/src/inner_event.cpp
@@ -209,9 +209,9 @@ void InnerEvent::ClearEvent()
}
}
- if (hiTraceId_) {
- hiTraceId_.reset();
- }
+ // if (hiTraceId_) {
+ // hiTraceId_.reset();
+ // }
// Clear owner
owner_.reset();
@@ -233,25 +233,25 @@ bool InnerEvent::HasWaiter() const
return (waiter_ != nullptr);
}
-const std::shared_ptr<HiTraceId> InnerEvent::GetOrCreateTraceId()
-{
- if (hiTraceId_) {
- return hiTraceId_;
- }
-
- auto traceId = HiTraceChain::GetId();
- if (!traceId.IsValid()) {
- return nullptr;
- }
-
- hiTraceId_ = std::make_shared<HiTraceId>(HiTraceChain::CreateSpan());
- return hiTraceId_;
-}
-
-const std::shared_ptr<HiTraceId> InnerEvent::GetTraceId()
-{
- return hiTraceId_;
-}
+// const std::shared_ptr<HiTraceId> InnerEvent::GetOrCreateTraceId()
+// {
+ // if (hiTraceId_) {
+ // return hiTraceId_;
+ // }
+
+ // auto traceId = HiTraceChain::GetId();
+ // if (!traceId.IsValid()) {
+ // return nullptr;
+ // }
+
+ // hiTraceId_ = std::make_shared<HiTraceId>(HiTraceChain::CreateSpan());
+ // return hiTraceId_;
+// }
+
+// const std::shared_ptr<HiTraceId> InnerEvent::GetTraceId()
+// {
+// // return hiTraceId_;
+// }
std::string InnerEvent::Dump()
{
diff --git a/interfaces/inner_api/event_queue.h b/interfaces/inner_api/event_queue.h
index 1b4d82c..e98500d 100644
--- a/interfaces/inner_api/event_queue.h
+++ b/interfaces/inner_api/event_queue.h
@@ -20,6 +20,7 @@
#include <list>
#include <map>
#include <mutex>
+#include <atomic>
#include "inner_event.h"
#include "event_handler_errors.h"
diff --git a/interfaces/inner_api/inner_event.h b/interfaces/inner_api/inner_event.h
index b8fb32c..1bedc46 100644
--- a/interfaces/inner_api/inner_event.h
+++ b/interfaces/inner_api/inner_event.h
@@ -437,14 +437,14 @@ private:
*
* @return return hiTrace Id.
*/
- const std::shared_ptr<HiTraceId> GetOrCreateTraceId();
+ // const std::shared_ptr<HiTraceId> GetOrCreateTraceId();
/**
* return trace id.
*
* @return return hiTrace Id.
*/
- const std::shared_ptr<HiTraceId> GetTraceId();
+ // const std::shared_ptr<HiTraceId> GetTraceId();
/*
* Calculate the type id for different smart pointers.
@@ -522,7 +522,7 @@ private:
std::shared_ptr<Waiter> waiter_;
// use to store hitrace Id
- std::shared_ptr<HiTraceId> hiTraceId_;
+ // std::shared_ptr<HiTraceId> hiTraceId_;
};
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -0,0 +1,91 @@
From 53cabe6ad687bac70f51cb39d265116ff8c8d883 Mon Sep 17 00:00:00 2001
From: s_c_c <shichuchao@huawei.com>
Date: Mon, 25 Mar 2024 17:04:16 +0800
Subject: [PATCH] feat for embedded fix eventhandler compile errors
---
frameworks/eventhandler/BUILD.gn | 3 ++-
frameworks/eventhandler/include/event_handler_utils.h | 3 ++-
frameworks/napi/BUILD.gn | 3 ++-
frameworks/native/BUILD.gn | 6 +++---
4 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/frameworks/eventhandler/BUILD.gn b/frameworks/eventhandler/BUILD.gn
index 7342337..a4be522 100644
--- a/frameworks/eventhandler/BUILD.gn
+++ b/frameworks/eventhandler/BUILD.gn
@@ -14,11 +14,12 @@
import("//build/ohos.gni")
import("../../eventhandler.gni")
import("inner_api_sources.gni")
+import("//build/config/sysroot.gni")
config("libeventhandler_config") {
include_dirs = [
"${inner_api_path}",
- "//commonlibrary/c_utils/base/include",
+ "${sysroot}/usr/include/c_utils",
"include",
]
}
diff --git a/frameworks/eventhandler/include/event_handler_utils.h b/frameworks/eventhandler/include/event_handler_utils.h
index 37e862f..84be89d 100644
--- a/frameworks/eventhandler/include/event_handler_utils.h
+++ b/frameworks/eventhandler/include/event_handler_utils.h
@@ -94,7 +94,8 @@ static inline bool AllowHiTraceOutPut(const std::shared_ptr<HiTraceId>& traceId,
static inline void GetLastErr(char *errmsg, size_t size = MAX_ERRORMSG_LEN)
{
size = size > MAX_ERRORMSG_LEN ? MAX_ERRORMSG_LEN : size;
- strerror_r(errno, errmsg, size);
+ char *ret = strerror_r(errno, errmsg, size);
+ (void)ret;
}
} // namespace AppExecFwk
} // namespace OHOS
diff --git a/frameworks/napi/BUILD.gn b/frameworks/napi/BUILD.gn
index 7b6f32f..d946e4e 100644
--- a/frameworks/napi/BUILD.gn
+++ b/frameworks/napi/BUILD.gn
@@ -14,6 +14,7 @@
import("//build/ohos.gni")
import("//build/ohos/ace/ace.gni")
import("../../eventhandler.gni")
+import("//build/config/sysroot.gni")
ohos_shared_library("emitter") {
include_dirs = [
@@ -21,7 +22,7 @@ ohos_shared_library("emitter") {
"${inner_api_path}",
"//third_party/node/src",
"//third_party/libuv/include",
- "//commonlibrary/c_utils/base/include",
+ "${sysroot}/usr/include/c_utils",
]
sources = [
diff --git a/frameworks/native/BUILD.gn b/frameworks/native/BUILD.gn
index 55e8208..6c98a96 100644
--- a/frameworks/native/BUILD.gn
+++ b/frameworks/native/BUILD.gn
@@ -13,15 +13,15 @@
import("//build/ohos.gni")
import("../../eventhandler.gni")
+import("//build/config/sysroot.gni")
ohos_shared_library("eventhandler_native") {
sources = [ "src/native_interface_eventhandler.cpp" ]
include_dirs = [
"${kits_path}/native",
- "//commonlibrary/c_utils/base/include",
- "//base/hiviewdfx/interfaces/innerkits/libhilog/include",
- "//base/hiviewdfx/interfaces/innerkits/libhitrace/include",
+ "${sysroot}/usr/include/c_utils",
+ "${sysroot}/usr/include/hilog",
]
cflags = [ "-Wno-error=inconsistent-missing-override" ]
--
2.20.1 (Apple Git-117)

19
eventhandler.BUILD.gn Normal file
View File

@ -0,0 +1,19 @@
import("//build/ohos.gni")
import("//build/config/sysroot.gni")
config("libeventhandler_config") {
include_dirs = [ "${sysroot}/usr/include/eventhandler" ]
libs = ["eventhandler.z"]
}
group("libeventhandler") {
public_configs = [ ":libeventhandler_config" ]
}
config("eventhandler_native_config") {
include_dirs = [ "${sysroot}/usr/include/eventhandler" ]
libs = ["eventhandler_native.z"]
}
group("eventhandler_native") {
public_configs = [ ":eventhandler_native_config" ]
}

74
eventhandler.bundle.json Normal file
View File

@ -0,0 +1,74 @@
{
"name": "@ohos/eventhandler",
"description": "事件处理服务",
"version": "3.1",
"license": "Apache 2.0",
"segment": {
"destPath": "base/notification/eventhandler/frameworks/eventhandler"
},
"component": {
"name": "eventhandler",
"subsystem": "notification",
"syscap": [
"SystemCapability.Notification.Emitter"
],
"features": [],
"adapted_system_type": [
"standard"
],
"rom": "500KB",
"ram": "1000KB",
"deps": {
"components": [
"hitrace_native",
"hiviewdfx_hilog_native",
"hichecker_native"
],
"third_party": []
},
"build": {
"group_type": {
"base_group": [
],
"fwk_group": [
],
"service_group": [
]
},
"inner_kits": [
{
"header": {
"header_base": "//base/notification/eventhandler/libeventhandler",
"header_files": [
"event_handler_errors.h",
"event_handler.h",
"event_queue.h",
"event_runner.h",
"inner_event.h",
"file_descriptor_listener.h",
"native_implement_eventhandler.h"
]
},
"name": "//base/notification/eventhandler:libeventhandler"
},
{
"header": {
"header_base": "//base/notification/eventhandler:eventhandler_native",
"header_files": [
"native_interface_eventhandler.h"
]
},
"name": "//base/notification/eventhandler:eventhandler_native"
}
],
"test": [
"//base/notification/eventhandler/frameworks/eventhandler/test:unittest",
"//base/notification/eventhandler/frameworks/test/moduletest:moduletest",
"//base/notification/eventhandler/test/fuzztest:fuzztest",
"//base/notification/eventhandler/test/systemtest:systemtest"
]
}
}
}

View File

@ -0,0 +1,123 @@
# 不输出debug信息不产生debug包
%define debug_package %{nil}
# 定义openHarmony软件包的版本变量所有包应该都是OpenHarmony-v3.2-Release
%global oh_version OpenHarmony-v3.2-Release
# 定义下编译根目录变量,此处用/root/rpmbuild/BUILD/distributed_build作为编译根目录
%global build_opt /opt/distributed-middleware-build
%global bundle_dir %{build_opt}/openeuler/compiler_gn/base/notification/eventhandler
%global eventhandler_path %{_builddir}/base/notification
# rpm包名称
Name: notification_eventhandler
# rpm包版本号
Version: 1.0.0
# rpm包Release号每次修改需要+1changelog同步修改
Release: 2
# rpm简介
Summary: C++ common basic library for distributed module construction and operation
# License openHarmony的应该都是Apache License 2.0
License: Apache License 2.0
# 软件包上游社区
Url: https://gitee.com/openharmony/notification_eventhandler
# tar包的下载地址由于gitee下载路径是不带软件包名的会导致和name不匹配
# 所以此处在后面用注释方式修改spec识别的tar包名称属于取巧但无可奈何。
Source1: https://gitee.com/openharmony/notification_eventhandler/repository/archive/%{oh_version}.tar.gz #/%{name}-%{oh_version}.tar.gz
Source2: eventhandler.bundle.json
Source3: eventhandler.BUILD.gn
# 补丁定义
Patch0001: 0001-notification-eventhandler.patch
Patch0002: 0002-feat-for-embedded-fix-eventhandler-compile-errors.patch
# 编译依赖,提交代码时需要分析依赖层级,从底往上提交代码。
BuildRequires: distributed-build, hilog, commonlibrary_c_utils
BuildRequires: python3-jinja2, python3-pyyaml
BuildRequires: libatomic, libicu-devel, libxml2-devel, compat-openssl11-devel
Requires: hilog
# 软件包的详细描述
%description
Provide some commonly used C++ development tool classes for standard systems, This repository is compatible with compilation on the OpenEuler operating system
# 软件包编译前的准备阶段
%prep
# 解压tar包到commonlibrary_c_utils-OpenHarmony-v3.2-Release路径下
rm -rf %{_builddir}/*
# build directory
cp -rf %{build_opt} %{_builddir}/build
[ ! -L "%{_builddir}/build.sh" ] && ln -s %{_builddir}/build/build_scripts/build.sh %{_builddir}/build.sh
[ ! -L "%{_builddir}/.gn" ] && ln -s %{_builddir}/build/core/gn/dotfile.gn %{_builddir}/.gn
[ ! -L "%{_builddir}/build.py" ] && ln -s %{_builddir}/build/lite/build.py %{_builddir}/build.py
cp -r %{_builddir}/build/openeuler/vendor %{_builddir}/
cp -r %{_builddir}/build/openeuler/compiler_gn/third_party %{_builddir}/
# 统一用setup不用autosetupdistributed-build除外
mkdir -p %{eventhandler_path}
%setup -q -D -T -a 1 -c -n %{eventhandler_path}
mv %{name}-%{oh_version} %{eventhandler_path}/eventhandler
# patch命令统一使用-P来指定第几个patch
%patch -P1 -p1 -d %{eventhandler_path}/eventhandler
%patch -P2 -p1 -d %{eventhandler_path}/eventhandler
# 拷贝依赖的组件的gn文件
mkdir -p %{_builddir}/base/hiviewdfx
mkdir -p %{_builddir}/commonlibrary
cp -rf %{_builddir}/build/openeuler/compiler_gn/base/hiviewdfx/hilog %{_builddir}/base/hiviewdfx
cp -rf %{_builddir}/build/openeuler/compiler_gn/commonlibrary/c_utils %{_builddir}/commonlibrary
# 编译阶段
%build
rm -rf %{_builddir}/out
%ifarch x86_64
bash %{_builddir}/build.sh --product-name openeuler --target-cpu x86_64
%endif
%ifarch aarch64
bash %{_builddir}/build.sh --product-name openeuler --target-cpu arm64
%endif
# 安装阶段
%install
install -d -m 0755 %{buildroot}/%{_includedir}/eventhandler
install -d -m 0755 %{buildroot}/%{bundle_dir}/
# 建so文件目录 /usr/lib64
install -d -m 0755 %{buildroot}/%{_libdir}
# innerkits/linux-arm64/eventhandler
%ifarch aarch64
%define module_out_path out/openeuler/linux_clang_arm64
%endif
%ifarch x86_64
%define module_out_path out/openeuler/linux_clang_x86_64
%endif
#copy shared library files
%define so_out_path %{module_out_path}/notification/eventhandler
install -m 0755 %{_builddir}/%{so_out_path}/libeventhandler_native.z.so %{buildroot}/%{_libdir}
install -m 0755 %{_builddir}/%{so_out_path}/libeventhandler.z.so %{buildroot}/%{_libdir}
# %define sdk_out_path %{module_out_path}/eventhandler
# cp -rf %{_builddir}/${sdk_out_path}/* %{buildroot}/%{bundle_dir}/
cp -rf %{SOURCE2} %{buildroot}/%{bundle_dir}/bundle.json
# 到源码路径下拷贝头文件及其目录到%{buildroot}/usr/include/eventhandler下保持目录结构相同
install -m 554 %{_builddir}/base/notification/eventhandler/interfaces/inner_api/*.h %{buildroot}/%{_includedir}/eventhandler
#copy correct eventhandler BUILD.gn
cp -rf %{SOURCE3} %{buildroot}%{bundle_dir}/BUILD.gn
# rpm安装后需要安装到系统中的文件及上面说的so和头文件
%files
%{_libdir}/*.so
%{_includedir}/eventhandler/*
%{bundle_dir}/*
# 变更日志
%changelog
* Tue Mar 19 2024 s_c_c <shichuchao@huawei.com> - 1.0.0-2
- Fix compile errors and sysroot path for embedded
* Thu Jun 15 2023 chrisshangguan <shangguanjingshi@huawei.com> - 1.0.0-1
- Init and adapt to openeuler