diff --git a/thirdparty/bdwgc-8.0.0/HPKBUILD b/thirdparty/bdwgc-8.0.0/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..ddfd09383734843fdb9e362896a4584d76b10378 --- /dev/null +++ b/thirdparty/bdwgc-8.0.0/HPKBUILD @@ -0,0 +1,73 @@ +# Copyright (c) 2023 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. + +# Contributor: wangjialun<2271411@stu.neu.edu.cn>, zhangqian<2371418@stu.neu.edu.cn>, wangyihao<2471389@stu.neu.edu.cn>, wangying +# Maintainer: wangyihao<2471389@stu.neu.edu.cn>, wangjialun<2271411@stu.neu.edu.cn>, zhangqian<2371418@stu.neu.edu.cn>, wangying + +pkgname=bdwgc-8.0.0 +pkgver=v8.0.0 +pkgrel=0 +pkgdesc="bdwgc is a conservative garbage collector for C and C++." +url="https://github.com/ivmai/bdwgc/tree/v8.0.0" +archs=("armeabi-v7a" "arm64-v8a") +license=("MIT license") +depends=() +makedepends=() +source="https://github.com/ivmai/bdwgc/archive/refs/tags/v8.0.0.zip" + +downloadpackage=true +autounpack=true +buildtools=cmake +patchflag=true + +builddir=bdwgc-8.0.0 +packagename=bdwgc-v8.0.0.zip + +# 为编译设置环境,如设置环境变量,创建编译目录等 +prepare() { + if $patchflag + then + cd $builddir + patch -p1 < `pwd`/../bdwgc-8.0.0_oh_pkg.patch + # patch只需要打一次,关闭打patch + patchflag=false + cd $OLDPWD + fi + mkdir -p $builddir/$ARCH-build +} + +build() { + cd $builddir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake "$@" -DCMAKE_C_FLAGS="-Wno-unused-command-line-argument" \ + -DCMAKE_CXX_FLAGS="-Wno-unused-command-line-argument" -B$ARCH-build -S./ > $buildlog 2>&1 + $MAKE VERBOSE=1 -C $ARCH-build >> $buildlog 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $builddir + $MAKE -C $ARCH-build install >> $buildlog 2>&1 + cd $OLDPWD +} + + +check() { + echo "The test must be on an OpenHarmony device!" +} + + +cleanbuild() { + rm -rf ${PWD}/$builddir +} \ No newline at end of file diff --git a/thirdparty/bdwgc-8.0.0/HPKCHECK b/thirdparty/bdwgc-8.0.0/HPKCHECK new file mode 100644 index 0000000000000000000000000000000000000000..30cecfd08661d3dea9f0badda98230d47abe5169 --- /dev/null +++ b/thirdparty/bdwgc-8.0.0/HPKCHECK @@ -0,0 +1,29 @@ +# Copyright (c) 2023 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. + +# Contributor: wangjialun<2271411@stu.neu.edu.cn>, zhangqian<2371418@stu.neu.edu.cn>, wangyihao<2471389@stu.neu.edu.cn>, wangying +# Maintainer: wangyihao<2471389@stu.neu.edu.cn>, wangjialun<2271411@stu.neu.edu.cn>, zhangqian<2371418@stu.neu.edu.cn>, wangying + +source HPKBUILD > /dev/null 2>&1 # 导入HPKBUILD文件 +logfile=${LYCIUM_THIRDPARTY_ROOT}/${pkgname}/${pkgname}_${OHOS_SDK_VER}_test.log + +# 在OH环境执行测试的接口 +openharmonycheck() { + res=0 + cd ${builddir}/${ARCH}-build # 进入到测试目录 + ctest > ${logfile} 2>&1 # 执行测试命令并将测试结果导出到${logfile} + res=$? + cd $OLDPWD + + return $res +} \ No newline at end of file diff --git a/thirdparty/bdwgc-8.0.0/OAT.xml b/thirdparty/bdwgc-8.0.0/OAT.xml new file mode 100644 index 0000000000000000000000000000000000000000..eeb1f946d683c0b81976cd06522096062a6901b9 --- /dev/null +++ b/thirdparty/bdwgc-8.0.0/OAT.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/thirdparty/bdwgc-8.0.0/README.OpenSource b/thirdparty/bdwgc-8.0.0/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..fbf869ae3c30c930c0d1fc1884b592b1c8784e76 --- /dev/null +++ b/thirdparty/bdwgc-8.0.0/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "bdwgc-8.0.0", + "License": "MIT license", + "License File": "https://github.com/ivmai/bdwgc/blob/master/LICENSE", + "Version Number": "v8.0.0", + "Owner": "2942375747@qq.com", + "Upstream URL": "https://github.com/ivmai/bdwgc", + "Description": "bdwgc is a conservative garbage collector for C and C++." + } +] \ No newline at end of file diff --git a/thirdparty/bdwgc-8.0.0/README_zh.md b/thirdparty/bdwgc-8.0.0/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..5a4f7a792f2d906ca8d29f8aaf21f256cdc06160 --- /dev/null +++ b/thirdparty/bdwgc-8.0.0/README_zh.md @@ -0,0 +1,9 @@ +# bdwgc-8.0.0三方库说明 +## 功能简介 +bdwgc-8.0.0是一个面向C和c++的保守垃圾收集器 +## 三方库版本: +- v8.0.0 +## 使用约束: +- [IDE和SDK版本](../../docs/constraint.md) +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/bdwgc-8.0.0/SHA512SUM b/thirdparty/bdwgc-8.0.0/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..802cd20c0326b151941b8946ca7a3c45998c21f7 --- /dev/null +++ b/thirdparty/bdwgc-8.0.0/SHA512SUM @@ -0,0 +1 @@ +36f81a9ee99ef32905e2e1ed8601da6d1bd03d064291b30706aa7609e69eb4db8723b6c03ff7caf3c0fb9389fe151a4dfd58dec7e302fb403649a9f9c2c6be22 bdwgc-v8.0.0.zip \ No newline at end of file diff --git a/thirdparty/bdwgc-8.0.0/bdwgc-8.0.0_oh_pkg.patch b/thirdparty/bdwgc-8.0.0/bdwgc-8.0.0_oh_pkg.patch new file mode 100644 index 0000000000000000000000000000000000000000..c65e9a9b4669a9d94f4b7bf3f0505d9f04e75098 --- /dev/null +++ b/thirdparty/bdwgc-8.0.0/bdwgc-8.0.0_oh_pkg.patch @@ -0,0 +1,151 @@ +--- bdwgc-8.0.0_old/os_dep.c 2018-09-05 06:10:55.000000000 +0800 ++++ bdwgc-8.0.0/os_dep.c 2024-09-02 11:21:27.546371962 +0800 +@@ -18,7 +18,7 @@ + + #if !defined(OS2) && !defined(PCR) && !defined(AMIGA) && !defined(MACOS) \ + && !defined(MSWINCE) && !defined(SN_TARGET_ORBIS) \ +- && !defined(SN_TARGET_PSP2) && !defined(__CC_ARM) ++ && !defined(SN_TARGET_PSP2) && !defined(__CC_ARM) && !defined(__OHOS__) + # include + # if !defined(MSWIN32) && !defined(MSWIN_XBOX1) + # include +@@ -504,14 +504,14 @@ + ptr_t GC_data_start = NULL; + + EXTERN_C_BEGIN +- extern char **environ; ++ // extern char **environ; + EXTERN_C_END + + GC_INNER void GC_init_netbsd_elf(void) + { + /* This may need to be environ, without the underscore, for */ + /* some versions. */ +- GC_data_start = GC_find_limit((ptr_t)&environ, FALSE); ++ // GC_data_start = GC_find_limit((ptr_t)&environ, FALSE); + } + #endif /* NETBSD */ + +@@ -1531,7 +1531,7 @@ + /* with SunOS dynamic loading), or GC_mark_roots needs to check for */ + /* them (as we do with PCR). Called with allocator lock held. */ + # ifdef OS2 +- ++#ifndef __OHOS__ + void GC_register_data_segments(void) + { + PTIB ptib; +@@ -1717,6 +1717,7 @@ + # else + # define GetWriteWatch_alloc_flag 0 + # endif /* !GWW_VDB */ ++#endif + + # if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32) + +@@ -1916,7 +1917,7 @@ + if (base != limit) GC_add_roots_inner(base, limit, FALSE); + } + #endif /* MSWIN32 */ +- ++#if !defined(__OHOS__) + void GC_register_data_segments(void) + { + # ifdef MSWIN32 +@@ -1924,7 +1925,7 @@ + /* any other GC global variable would fit too. */ + # endif + } +- ++#endif + # else /* !OS2 && !Windows */ + + # if (defined(SVR4) || defined(AIX) || defined(DGUX) \ +@@ -2007,7 +2008,7 @@ + # undef GC_AMIGA_DS + + #elif defined(OPENBSD) +- ++#if !defined(__OHOS__) + /* Depending on arch alignment, there can be multiple holes */ + /* between DATASTART and DATAEND. Scan in DATASTART .. DATAEND */ + /* and register each region. */ +@@ -2027,7 +2028,7 @@ + region_start = GC_skip_hole_openbsd(region_end, DATAEND); + } + } +- ++#endif + # else /* !OS2 && !Windows && !AMIGA && !OPENBSD */ + + # if !defined(PCR) && !defined(MACOS) && defined(REDIRECT_MALLOC) \ +@@ -2036,7 +2037,7 @@ + extern caddr_t sbrk(int); + EXTERN_C_END + # endif +- ++#if !defined(__OHOS__) + void GC_register_data_segments(void) + { + # if !defined(PCR) && !defined(MACOS) +@@ -2105,7 +2106,7 @@ + /* Dynamic libraries are added at every collection, since they may */ + /* change. */ + } +- ++#endif + # endif /* !AMIGA */ + # endif /* !MSWIN32 && !MSWINCE */ + # endif /* !OS2 */ +--- bdwgc-8.0.0_old/misc.c 2018-09-05 06:10:55.000000000 +0800 ++++ bdwgc-8.0.0/misc.c 2024-09-02 11:40:15.563734838 +0800 +@@ -1277,7 +1277,10 @@ + + /* Add initial guess of root sets. Do this first, since sbrk(0) */ + /* might be used. */ +- if (GC_REGISTER_MAIN_STATIC_DATA()) GC_register_data_segments(); ++ if (GC_REGISTER_MAIN_STATIC_DATA()) ++ #ifndef __OHOS__ ++ GC_register_data_segments(); ++ #endif + GC_init_headers(); + GC_bl_init(); + GC_mark_init(); + +--- bdwgc-8.0.0_old/CMakeLists.txt 2018-09-05 06:10:55.000000000 +0800 ++++ bdwgc-8.0.0/CMakeLists.txt 2024-09-02 18:26:14.137861542 +0800 +@@ -248,14 +248,25 @@ + + ADD_LIBRARY( gcmt-dll SHARED ${SRC}) + +-IF(WIN32) +- ADD_EXECUTABLE(cord cord/cordbscs.c cord/cordxtra.c +- cord/tests/de.c cord/tests/de_win.c) +- SET_TARGET_PROPERTIES(cord PROPERTIES WIN32_EXECUTABLE TRUE) +- SET_TARGET_PROPERTIES(cord PROPERTIES +- COMPILE_DEFINITIONS GC_NOT_DLL) +- TARGET_LINK_LIBRARIES(cord gc-lib) +- TARGET_LINK_LIBRARIES(cord gdi32) +-ENDIF(WIN32) ++#IF(WIN32) ++# ADD_EXECUTABLE(cord cord/cordbscs.c cord/cordxtra.c ++# cord/tests/de.c cord/tests/de_win.c) ++# SET_TARGET_PROPERTIES(cord PROPERTIES WIN32_EXECUTABLE TRUE) ++# SET_TARGET_PROPERTIES(cord PROPERTIES ++# COMPILE_DEFINITIONS GC_NOT_DLL) ++# TARGET_LINK_LIBRARIES(cord gc-lib) ++# TARGET_LINK_LIBRARIES(cord gdi32) ++#ENDIF(WIN32) ++set(TARGET_NAME bdwgc-8.0.0) ++set(TARGET_INSTALL_INCLUDEDIR "include") ++set(TARGET_INSTALL_LIBDIR "lib") ++# װ̬ ++install(TARGETS gcmt-lib ++ ARCHIVE DESTINATION ${TARGET_INSTALL_LIBDIR}) ++ ++# װ ++install(TARGETS gcmt-lib ++ LIBRARY DESTINATION ${TARGET_INSTALL_LIBDIR}) ++ + + ADD_SUBDIRECTORY(tests) diff --git a/thirdparty/bdwgc-8.0.0/docs/hap_integrate.md b/thirdparty/bdwgc-8.0.0/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..0120b7fd1523388e37259efefac88b47314d3ec6 --- /dev/null +++ b/thirdparty/bdwgc-8.0.0/docs/hap_integrate.md @@ -0,0 +1,76 @@ +# bdwgc-8.0.0集成到应用hap + +本库是在RK3568开发板上基于OpenHarmony3.2 Release版本的镜像验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 + +## 开发环境 + +- [开发环境准备](../../../docs/hap_integrate_environment.md) + +## 编译三方库 + +- 下载本仓库 + + ```shell + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 三方库目录结构 + + ```shell + tpc_c_cplusplus/thirdparty/bdwgc-8.0.0 #三方库bdwgc-8.0.0的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── HPKCHECK #测试脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md #三方库简介 + ``` + +- 在lycium目录下编译三方库 + + 编译环境的搭建参考[准备三方库构建环境](../../../lycium/README.md#1编译环境准备) + + ```shell + cd lycium + ./build.sh bdwgc-8.0.0 + ``` + +- 三方库头文件及生成的库 + + 在lycium目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ```shell + bdwgc-8.0.0/arm64-v8a bdwgc-8.0.0/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +- 编译出可执行的文件进行测试,[准备三方库测试环境](../../../lycium/README.md#3ci环境准备) +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的头文件拷贝到该目录下,将编译生成的三方库以及依赖库全部(动态库名字带版本号和不带版本号的都需要)拷贝到工程的libs目录下,如下图所示: +   + +  ![thirdparty_install_dir](pic/bdwgc_install_dir.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + + ```shell + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/bdwgc/${OHOS_ARCH}/lib/libgcmt-lib.a) + ``` + +## 测试三方库 +进入到构建目录运行测试用例(注意arm64-v8a为构建64位的目录,armeabi-v7a为构建32位的目录),执行结果如图所示 + +```shell + cd /data/tpc_c_cplusplus/thirdparty/bdwgc-8.0.0/bdwgc-8.0.0/arm64-v8a-build/ + ./ctest +``` + ![bdwgc_test](pic/bdwgc_test.png) + +## 参考资料 + +- [润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld) +- [OpenHarmony三方库地址](https://gitee.com/openharmony-tpc) +- [OpenHarmony知识体系](https://gitee.com/openharmony-sig/knowledge) \ No newline at end of file diff --git a/thirdparty/bdwgc-8.0.0/docs/pic/bdwgc_install_dir.png b/thirdparty/bdwgc-8.0.0/docs/pic/bdwgc_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..a0dbbf20b92693df38b1efb5ee22c85282b2c3e2 Binary files /dev/null and b/thirdparty/bdwgc-8.0.0/docs/pic/bdwgc_install_dir.png differ diff --git a/thirdparty/bdwgc-8.0.0/docs/pic/bdwgc_test.png b/thirdparty/bdwgc-8.0.0/docs/pic/bdwgc_test.png new file mode 100644 index 0000000000000000000000000000000000000000..326cf80e10ed22b3cd2726f96efda67f96447392 Binary files /dev/null and b/thirdparty/bdwgc-8.0.0/docs/pic/bdwgc_test.png differ