!6 同步到sp3分支
From: @muyuying1 Reviewed-by: @yukaii Signed-off-by: @yukaii
This commit is contained in:
commit
291c86b8b3
92
0000-commonlibrary-c_utils.patch
Normal file
92
0000-commonlibrary-c_utils.patch
Normal file
@ -0,0 +1,92 @@
|
||||
From e9a2e27d96e8951cb5a55601102def04e93ae4b3 Mon Sep 17 00:00:00 2001
|
||||
From: heppen <hepeng68@huawei.com>
|
||||
Date: Fri, 26 May 2023 09:52:04 +0800
|
||||
Subject: [PATCH] =?UTF-8?q?commonlibrary/c=5Futils:=20=E5=A4=B4=E6=96=87?=
|
||||
=?UTF-8?q?=E4=BB=B6=E7=BC=BA=E5=A4=B1/=E7=B1=BB=E5=9E=8B=E8=BD=AC?=
|
||||
=?UTF-8?q?=E6=8D=A2=E4=B8=8D=E5=8C=B9=E9=85=8D=E4=B8=A4=E7=B1=BB=E7=BC=96?=
|
||||
=?UTF-8?q?=E8=AF=91=E9=97=AE=E9=A2=98=E8=A7=A3=E5=86=B3?=
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
---
|
||||
base/src/event_reactor.h | 1 +
|
||||
base/src/file_ex.cpp | 3 ++-
|
||||
base/src/parcel.cpp | 1 +
|
||||
base/src/string_ex.cpp | 2 ++
|
||||
base/src/thread_pool.cpp | 1 +
|
||||
5 files changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/base/src/event_reactor.h b/base/src/event_reactor.h
|
||||
index 794e44a5..1a282ec5 100644
|
||||
--- a/base/src/event_reactor.h
|
||||
+++ b/base/src/event_reactor.h
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <list>
|
||||
+#include <functional>
|
||||
|
||||
namespace OHOS {
|
||||
namespace Utils {
|
||||
diff --git a/base/src/file_ex.cpp b/base/src/file_ex.cpp
|
||||
index 578b1bea..a9e05727 100644
|
||||
--- a/base/src/file_ex.cpp
|
||||
+++ b/base/src/file_ex.cpp
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <cstdio>
|
||||
#include <securec.h>
|
||||
#include <cstring>
|
||||
+#include <limits.h>
|
||||
#include "directory_ex.h"
|
||||
#include "utils_log.h"
|
||||
|
||||
@@ -262,7 +263,7 @@ bool SaveBufferToFile(const string& filePath, const vector<char>& content, bool
|
||||
}
|
||||
|
||||
// if the file is not exist,create it first!
|
||||
- uint32_t mode = truncated ? (ios::out | ios::binary | ios::trunc) : (ios::out | ios::binary | ios::app);
|
||||
+ ios_base::openmode mode = truncated ? (ios::out | ios::binary | ios::trunc) : (ios::out | ios::binary | ios::app);
|
||||
ofstream file;
|
||||
file.open(filePath.c_str(), mode);
|
||||
if (!file.is_open()) {
|
||||
diff --git a/base/src/parcel.cpp b/base/src/parcel.cpp
|
||||
index 4d623532..b0012bc8 100644
|
||||
--- a/base/src/parcel.cpp
|
||||
+++ b/base/src/parcel.cpp
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "parcel.h"
|
||||
#include "securec.h"
|
||||
#include "utils_log.h"
|
||||
+#include <limits.h>
|
||||
|
||||
namespace OHOS {
|
||||
|
||||
diff --git a/base/src/string_ex.cpp b/base/src/string_ex.cpp
|
||||
index 32340ae1..782e4193 100644
|
||||
--- a/base/src/string_ex.cpp
|
||||
+++ b/base/src/string_ex.cpp
|
||||
@@ -20,6 +20,8 @@
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
+#include <algorithm>
|
||||
+#include <limits.h>
|
||||
using namespace std;
|
||||
|
||||
namespace OHOS {
|
||||
diff --git a/base/src/thread_pool.cpp b/base/src/thread_pool.cpp
|
||||
index 9951929f..b4e663c2 100644
|
||||
--- a/base/src/thread_pool.cpp
|
||||
+++ b/base/src/thread_pool.cpp
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <pthread.h>
|
||||
+#include <cstring>
|
||||
|
||||
namespace OHOS {
|
||||
|
||||
--
|
||||
2.33.0
|
||||
|
||||
67
0001-commonlibrary-c_utils-linux-ashmem.h.patch
Normal file
67
0001-commonlibrary-c_utils-linux-ashmem.h.patch
Normal file
@ -0,0 +1,67 @@
|
||||
From 87ec1e798711ffca7a18fed9ad1ef9b6485f6cc7 Mon Sep 17 00:00:00 2001
|
||||
From: liheavy <lihaiwei8@huawei.com>
|
||||
Date: Sat, 27 May 2023 09:57:50 +0800
|
||||
Subject: [PATCH] =?UTF-8?q?commonlibrary/c=5Futils:=20=E5=A2=9E=E5=8A=A0li?=
|
||||
=?UTF-8?q?nux=E7=9A=84ashmem.h=E5=A4=B4=E6=96=87=E4=BB=B6?=
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
---
|
||||
.../c_utils/base/include/linux/ashmem.h | 44 +++++++++++++++++++
|
||||
1 file changed, 44 insertions(+)
|
||||
create mode 100644 base/include/linux/ashmem.h
|
||||
|
||||
diff --git a/base/include/linux/ashmem.h b/base/include/linux/ashmem.h
|
||||
new file mode 100644
|
||||
index 00000000..174667f9
|
||||
--- /dev/null
|
||||
+++ b/base/include/linux/ashmem.h
|
||||
@@ -0,0 +1,44 @@
|
||||
+/****************************************************************************
|
||||
+ ****************************************************************************
|
||||
+ ***
|
||||
+ *** This header was automatically generated from a Linux kernel header
|
||||
+ *** of the same name, to make information necessary for userspace to
|
||||
+ *** call into the kernel available to libc. It contains only constants,
|
||||
+ *** structures, and macros generated from the original header, and thus,
|
||||
+ *** contains no copyrightable information.
|
||||
+ ***
|
||||
+ *** To edit the content of this header, modify the corresponding
|
||||
+ *** source file (e.g. under external/kernel-headers/original/) then
|
||||
+ *** run bionic/libc/kernel/tools/update_all.py
|
||||
+ ***
|
||||
+ *** Any manual change here will be lost the next time this script will
|
||||
+ *** be run. You've been warned!
|
||||
+ ***
|
||||
+ ****************************************************************************
|
||||
+ ****************************************************************************/
|
||||
+#ifndef _UAPI_LINUX_ASHMEM_H
|
||||
+#define _UAPI_LINUX_ASHMEM_H
|
||||
+#include <linux/ioctl.h>
|
||||
+#include <linux/types.h>
|
||||
+#define ASHMEM_NAME_LEN 256
|
||||
+#define ASHMEM_NAME_DEF "dev/ashmem"
|
||||
+#define ASHMEM_NOT_PURGED 0
|
||||
+#define ASHMEM_WAS_PURGED 1
|
||||
+#define ASHMEM_IS_UNPINNED 0
|
||||
+#define ASHMEM_IS_PINNED 1
|
||||
+struct ashmem_pin {
|
||||
+ __u32 offset;
|
||||
+ __u32 len;
|
||||
+};
|
||||
+#define __ASHMEMIOC 0x77
|
||||
+#define ASHMEM_SET_NAME _IOW(__ASHMEMIOC, 1, char[ASHMEM_NAME_LEN])
|
||||
+#define ASHMEM_GET_NAME _IOR(__ASHMEMIOC, 2, char[ASHMEM_NAME_LEN])
|
||||
+#define ASHMEM_SET_SIZE _IOW(__ASHMEMIOC, 3, size_t)
|
||||
+#define ASHMEM_GET_SIZE _IO(__ASHMEMIOC, 4)
|
||||
+#define ASHMEM_SET_PROT_MASK _IOW(__ASHMEMIOC, 5, unsigned long)
|
||||
+#define ASHMEM_GET_PROT_MASK _IO(__ASHMEMIOC, 6)
|
||||
+#define ASHMEM_PIN _IOW(__ASHMEMIOC, 7, struct ashmem_pin)
|
||||
+#define ASHMEM_UNPIN _IOW(__ASHMEMIOC, 8, struct ashmem_pin)
|
||||
+#define ASHMEM_GET_PIN_STATUS _IO(__ASHMEMIOC, 9)
|
||||
+#define ASHMEM_PURGE_ALL_CACHES _IO(__ASHMEMIOC, 10)
|
||||
+#endif
|
||||
--
|
||||
2.33.0
|
||||
|
||||
30
bounds_checking_function.BUILD.gn
Normal file
30
bounds_checking_function.BUILD.gn
Normal file
@ -0,0 +1,30 @@
|
||||
# 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.
|
||||
import("//build/ohos.gni")
|
||||
|
||||
config("libsec_public_config") {
|
||||
include_dirs = [ "include" ]
|
||||
libs = [ "boundscheck" ]
|
||||
}
|
||||
|
||||
group("libsec_static") {
|
||||
#libs = [ "boundscheck" ]
|
||||
public_configs = [ ":libsec_public_config" ]
|
||||
all_dependent_configs = [ ":libsec_public_config" ]
|
||||
}
|
||||
|
||||
group("libsec_shared") {
|
||||
#libs = [ "boundscheck" ]
|
||||
public_configs = [ ":libsec_public_config" ]
|
||||
all_dependent_configs = [ ":libsec_public_config" ]
|
||||
}
|
||||
34
c_utils.BUILD.gn
Normal file
34
c_utils.BUILD.gn
Normal file
@ -0,0 +1,34 @@
|
||||
# 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.
|
||||
import("//build/ohos.gni")
|
||||
|
||||
config("utils_configs") {
|
||||
include_dirs = [ "include" ]
|
||||
libs = [ "utils.z" ]
|
||||
}
|
||||
|
||||
config("utilsbase_config") {
|
||||
include_dirs = [ "include" ]
|
||||
libs = [ "utilsbase.z" ]
|
||||
}
|
||||
|
||||
group("utilsbase") {
|
||||
all_dependent_configs = [ ":utilsbase_config" ]
|
||||
public_configs = [ ":utilsbase_config" ]
|
||||
}
|
||||
|
||||
group("utils") {
|
||||
all_dependent_configs = [ ":utils_configs" ]
|
||||
public_configs = [ ":utils_configs" ]
|
||||
public_deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
|
||||
}
|
||||
103
c_utils.bundle.json
Normal file
103
c_utils.bundle.json
Normal file
@ -0,0 +1,103 @@
|
||||
{
|
||||
"name": "@openharmony/c_utils",
|
||||
"version": "3.1.0",
|
||||
"description": "c_utils",
|
||||
"publishAs": "code-segment",
|
||||
"segment": {
|
||||
"destPath": "commonlibrary/c_utils"
|
||||
},
|
||||
"scripts": {
|
||||
"install": "DEST_PATH=${DEP_BUNDLE_BASE}/commonlibrary/c_utils/base && mkdir -p $DEST_PATH && cp -r ./* $DEST_PATH"
|
||||
},
|
||||
"author": {},
|
||||
"repository": "",
|
||||
"license": "Apache License 2.0",
|
||||
"component": {
|
||||
"name": "c_utils",
|
||||
"subsystem": "commonlibrary",
|
||||
"adapted_system_type": [ "standard" ],
|
||||
"deps": {
|
||||
"components": [
|
||||
"hilog_native"
|
||||
],
|
||||
"third_party": []
|
||||
},
|
||||
"build": {
|
||||
"sub_component": [
|
||||
],
|
||||
"inner_kits": [
|
||||
{
|
||||
"name": "//commonlibrary/c_utils/base:utils",
|
||||
"header": {
|
||||
"header_files": [
|
||||
"ashmem.h",
|
||||
"common_errors.h",
|
||||
"common_timer_errors.h",
|
||||
"datetime_ex.h",
|
||||
"directory_ex.h",
|
||||
"errors.h",
|
||||
"file_ex.h",
|
||||
"flat_obj.h",
|
||||
"nocopyable.h",
|
||||
"observer.h",
|
||||
"parcel.h",
|
||||
"pubdef.h",
|
||||
"refbase.h",
|
||||
"rwlock.h",
|
||||
"safe_block_queue.h",
|
||||
"safe_map.h",
|
||||
"safe_queue.h",
|
||||
"securec.h",
|
||||
"securectype.h",
|
||||
"semaphore_ex.h",
|
||||
"singleton.h",
|
||||
"sorted_vector.h",
|
||||
"string_ex.h",
|
||||
"thread_ex.h",
|
||||
"thread_pool.h",
|
||||
"timer.h",
|
||||
"unique_fd.h"
|
||||
],
|
||||
"header_base": "//commonlibrary/c_utils/base/include"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "//commonlibrary/c_utils/base:utilsbase",
|
||||
"header": {
|
||||
"header_files": [
|
||||
"ashmem.h",
|
||||
"common_errors.h",
|
||||
"common_timer_errors.h",
|
||||
"datetime_ex.h",
|
||||
"directory_ex.h",
|
||||
"errors.h",
|
||||
"file_ex.h",
|
||||
"flat_obj.h",
|
||||
"nocopyable.h",
|
||||
"observer.h",
|
||||
"parcel.h",
|
||||
"pubdef.h",
|
||||
"refbase.h",
|
||||
"rwlock.h",
|
||||
"safe_block_queue.h",
|
||||
"safe_map.h",
|
||||
"safe_queue.h",
|
||||
"securec.h",
|
||||
"securectype.h",
|
||||
"semaphore_ex.h",
|
||||
"singleton.h",
|
||||
"sorted_vector.h",
|
||||
"string_ex.h",
|
||||
"thread_ex.h",
|
||||
"thread_pool.h",
|
||||
"timer.h",
|
||||
"unique_fd.h"
|
||||
],
|
||||
"header_base": "//commonlibrary/c_utils/base/include"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
commonlibrary_c_utils-OpenHarmony-v3.2-Release.tar.gz
Normal file
BIN
commonlibrary_c_utils-OpenHarmony-v3.2-Release.tar.gz
Normal file
Binary file not shown.
121
commonlibrary_c_utils.spec
Normal file
121
commonlibrary_c_utils.spec
Normal file
@ -0,0 +1,121 @@
|
||||
# 不输出debug信息,不产生debug包
|
||||
%define debug_package %{nil}
|
||||
# 定义openHarmony软件包的版本变量,所有包应该都是OpenHarmony-v3.2-Release
|
||||
%global oh_version OpenHarmony-v3.2-Release
|
||||
# 定义下编译根目录变量,作为编译根目录
|
||||
%global build_opt /opt/distributed-middleware-build
|
||||
%global c_utils_path %{_builddir}/commonlibrary
|
||||
%global bundle_dir %{build_opt}/openeuler/compiler_gn/commonlibrary/c_utils
|
||||
%global gn_dir %{build_opt}/openeuler/compiler_gn/commonlibrary/c_utils/base
|
||||
# rpm包名称
|
||||
Name: commonlibrary_c_utils
|
||||
# rpm包版本号
|
||||
Version: 1.0.0
|
||||
# rpm包Release号,每次修改需要+1,changelog同步修改
|
||||
Release: 1
|
||||
# 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/commonlibrary_c_utils
|
||||
# tar包的下载地址,由于gitee下载路径是不带软件包名的,会导致和name不匹配,
|
||||
# 所以此处在后面用注释方式修改spec识别的tar包名称
|
||||
Source1: https://gitee.com/openharmony/commonlibrary_c_utils/repository/archive/%{oh_version}.tar.gz #/%{name}-%{oh_version}.tar.gz
|
||||
Source2: c_utils.bundle.json
|
||||
Source3: c_utils.BUILD.gn
|
||||
#Source4: bounds_checking_function.BUILD.gn
|
||||
# 补丁定义
|
||||
Patch1: 0000-commonlibrary-c_utils.patch
|
||||
Patch2: 0001-commonlibrary-c_utils-linux-ashmem.h.patch
|
||||
# 编译依赖,提交代码时需要分析依赖层级,从底往上提交代码。
|
||||
BuildRequires: distributed-build, hilog, clang15, llvm15, lld15, python3, ninja-build, gn
|
||||
BuildRequires: python3-jinja2 python3-pyyaml
|
||||
BuildRequires: libatomic libicu-devel libxml2-devel openssl-devel
|
||||
|
||||
# 软件包的详细描述
|
||||
%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路径下
|
||||
# build directory
|
||||
rm -rf %{_builddir}/*
|
||||
cd %{_builddir}
|
||||
cp -a %{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}/
|
||||
|
||||
mkdir -p %{c_utils_path}
|
||||
# 统一用setup,不用autosetup,distributed-build除外
|
||||
%setup -q -D -T -a 1 -c -n %{c_utils_path}
|
||||
mv %{name}-%{oh_version} %{_builddir}/commonlibrary/c_utils
|
||||
# patch命令统一使用-P来指定第几个patch
|
||||
%patch -P1 -p1 -d %{c_utils_path}/c_utils
|
||||
%patch -P2 -p1 -d %{c_utils_path}/c_utils
|
||||
|
||||
# 拷贝依赖的组件的gn文件
|
||||
mkdir -p %{_builddir}/base/hiviewdfx
|
||||
|
||||
cp -rf %{_builddir}/build/openeuler/compiler_gn/base/hiviewdfx/hilog %{_builddir}/base/hiviewdfx
|
||||
|
||||
# 编译阶段
|
||||
%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}/c_utils
|
||||
install -d -m 0755 %{buildroot}/%{_includedir}/c_utils/linux
|
||||
install -d -m 0755 %{buildroot}/%{_includedir}/src
|
||||
install -d -m 0755 %{buildroot}%{build_opt}/openeuler/compiler_gn/commonlibrary/c_utils/base/
|
||||
install -d -m 0755 %{buildroot}%{build_opt}/openeuler/compiler_gn/third_party/bounds_checking_function/
|
||||
|
||||
install -d -m 0755 %{buildroot}/%{_libdir}
|
||||
install -d -m 0755 %{buildroot}/%{bundle_dir}
|
||||
install -d -m 0755 %{buildroot}/%{gn_dir}
|
||||
|
||||
%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
|
||||
|
||||
install -m 0755 %{_builddir}/%{module_out_path}/commonlibrary/c_utils/libutils.z.so %{buildroot}/%{_libdir}
|
||||
# 到源码路径下拷贝头文件及其目录到%{buildroot}/usr/include/c_utils,保持目录结构相同
|
||||
install -m 554 %{_builddir}/commonlibrary/c_utils/base/include/*.h %{buildroot}/%{_includedir}/c_utils
|
||||
install -m 554 %{_builddir}/commonlibrary/c_utils/base/include/linux/*.h %{buildroot}/%{_includedir}/c_utils/linux
|
||||
install -m 554 %{_builddir}/commonlibrary/c_utils/base/src/event_reactor.h %{buildroot}/%{_includedir}/src
|
||||
|
||||
# copy bundle.json and BUILD.gn
|
||||
cp %{SOURCE2} %{buildroot}/%{bundle_dir}/bundle.json
|
||||
cp %{SOURCE3} %{buildroot}/%{gn_dir}/BUILD.gn
|
||||
|
||||
# create soft link
|
||||
ln -s /usr/include/c_utils %{buildroot}%{build_opt}/openeuler/compiler_gn/commonlibrary/c_utils/base/include
|
||||
|
||||
# rpm安装后需要安装到系统中的文件,及上面说的so和头文件
|
||||
%files
|
||||
%{_libdir}/*.so
|
||||
%{_includedir}/c_utils/*
|
||||
%{_includedir}/c_utils/linux/*
|
||||
%{_includedir}/src/*
|
||||
%{build_opt}/*
|
||||
|
||||
# 变更日志
|
||||
%changelog
|
||||
* Thu Jun 15 2023 chrisshangguan <shangguanjingshi@huawei.com> - 1.0.0-1
|
||||
- Init and adapt to openeuler
|
||||
Loading…
x
Reference in New Issue
Block a user