diff --git a/thirdparty/harfbuzz/HPKBUILD b/thirdparty/harfbuzz/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..a76d17bf16d96fb3f4968a91c53ddc2decae080f --- /dev/null +++ b/thirdparty/harfbuzz/HPKBUILD @@ -0,0 +1,86 @@ +# Contributor: 小肉头君 +# Maintainer: 小肉头君 + +pkgname=harfbuzz +pkgver=7.1.0 +pkgrel=0 +pkgdesc="HarfBuzz text shaping engine." +url="https://github.com/harfbuzz/harfbuzz" +archs=("armeabi-v7a" "arm64-v8a") +license=("Old MIT") +depends=() +makedepends=() +source="https://github.com/$pkgname/$pkgname/archive/refs/tags/$pkgver.tar.gz" + +autounpack=true +downloadpackage=true +buildtools="configure" + +builddir=$pkgname-$pkgver +packagename=$builddir.tar.gz + +source envset.sh +autogenflag=true +host= + +prepare() { + mkdir -p $builddir/$ARCH-build + if [ $ARCH == "armeabi-v7a" ] + then + setarm32ENV + host=arm-linux + fi + if [ $ARCH == "arm64-v8a" ] + then + setarm64ENV + host=aarch64-linux + fi + if $autogenflag + then + cd $builddir + ./autogen.sh > `pwd`/build.log 2>&1 + cd $OLDPWD + autogenflag=false + fi +} + +build() { + cd $builddir/$ARCH-build + ../configure "$@" --host=$host --with-freetype=no --with-icu=no --with-glib=no -with-cairo=no --enable-static > `pwd`/build.log 2>&1 + make -j4 >> `pwd`/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +# 安装打包 +package() { + cd $builddir + make -C $ARCH-build install >> `pwd`/$ARCH-build/build.log 2>&1 + cd $OLDPWD +} + +# 测试,需要在 ohos 设备上进行 +check() { + cd $builddir/$ARCH-build/src + make test-algs test-array test-bimap test-iter test-machinery test-map test-multimap test-number test-ot-tag test-priority-queue test-set test-serialize test-unicode-ranges test-vector test-repacker test-classdef-graph \ + check-c-linkage-decls.py check-externs.py check-header-guards.py check-includes.py check-static-inits.py check-symbols.py check-libstdc++.py >> `pwd`/../build.log 2>&1 + if [ $ARCH == "armeabi-v7a" ] + then + unsetarm32ENV + fi + if [ $ARCH == "arm64-v8a" ] + then + unsetarm64ENV + fi + cd $OLDPWD + unset host + echo "The test must be on an OpenHarmony device!" + # real test CMD + # make -C src check-TESTS +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/$builddir #${PWD}/$packagename +} \ No newline at end of file diff --git a/thirdparty/harfbuzz/README.OpenSource b/thirdparty/harfbuzz/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..ebce3afd6bfdb6ad6538aacda6938804816c49fe --- /dev/null +++ b/thirdparty/harfbuzz/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "harfbuzz", + "License": "Old MIT", + "License File": "LICENSES", + "Version Number": "7.1.0", + "Owner": "chenbaodi@huawei.com", + "Upstream URL": "https://github.com/harfbuzz/harfbuzz/archive/refs/tags/7.3.0.tar.gz", + "Description": "HarfBuzz text shaping engine" + } +] diff --git a/thirdparty/harfbuzz/README_zh.md b/thirdparty/harfbuzz/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..09832214f7118bec05eaf6cf390189d5048c975e --- /dev/null +++ b/thirdparty/harfbuzz/README_zh.md @@ -0,0 +1,12 @@ +# harfbuzz三方库说明 +## 功能简介 +harfbuzz是一个有OpenType文本整形能力的库。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Beta2 +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:7.1.0 +- 当前适配的功能:支持OpenType文本整形能力 +- [Old MIT](https://github.com/harfbuzz/harfbuzz/blob/main/COPYING) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/harfbuzz/SHA512SUM b/thirdparty/harfbuzz/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..4ef719855f9fa0a4cf601f9638885bd9dee60683 --- /dev/null +++ b/thirdparty/harfbuzz/SHA512SUM @@ -0,0 +1 @@ +aaef6801c73492624f19dececd956c03fda82a441b81553dfcd0bd47e5120b1d61acfef422a6cd0ded490d16ee4ee9088abdc0faba2a84884905e7cd63fe59d6 harfbuzz-7.1.0.tar.gz diff --git a/thirdparty/harfbuzz/docs/hap_integrate.md b/thirdparty/harfbuzz/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..6abbe7e20d5e086ba4727e02c04aad0473405640 --- /dev/null +++ b/thirdparty/harfbuzz/docs/hap_integrate.md @@ -0,0 +1,96 @@ +# harfbuzz 集成到应用hap + +本库是在RK3568开发板上基于OpenHarmony3.2 Release版本的镜像验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 + +## 开发环境 + +- ubuntu20.04 +- [OpenHarmony3.2Release镜像](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fdayu200_standard_arm32.tar.gz) +- [ohos_sdk_public 3.2.11.9 (API Version 9 Release)](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fohos-sdk-windows_linux-public.tar.gz) +- [DevEco Studio 3.1 Beta2](https://gitee.com/link?target=https%3A%2F%2Fcontentcenter-vali-drcn.dbankcdn.cn%2Fpvt_2%2FDeveloperAlliance_package_901_9%2Ff3%2Fv3%2FuJyuq3syQ2ak4hE1QZmAug%2Fdevecostudio-windows-3.1.0.400.zip%3FHW-CC-KV%3DV1%26HW-CC-Date%3D20230408T013335Z%26HW-CC-Expire%3D315360000%26HW-CC-Sign%3D96262721EDC9B34E6F62E66884AB7AE2A94C2A7B8C28D6F7FC891F46EB211A70) +- [准备三方库构建环境](../../../tools/README.md#编译环境准备) +- [准备三方库测试环境](../../../tools/README.md#ci环境准备) + +## 编译三方库 + +- 下载本仓库 + + ```shell + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 三方库目录结构 + + ``` + tpc_c_cplusplus/thirdparty/harfbuzz #三方库harfbuzz的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将harfbuzz拷贝至tools/main目录下 + + ``` + cd tpc_c_cplusplus + cp thirdparty/harfbuzz tools/main -rf + ``` + +- 在tools目录下编译三方库 + + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + + ``` + cd tools + ./build.sh harfbuzz + ``` + +- 三方库头文件及生成的库 + + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ``` + harfbuzz/arm64-v8a harfbuzz/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示: + +  ![thirdparty_install_dir](pic/harfbuzz_install_dir1.png) + +- 拷贝动态库到`\\entry\libs\${OHOS_ARCH}\`目录: + + 动态库需要在`\\entry\libs\${OHOS_ARCH}\`目录,才能集成到hap包中,所以需要将对应的so文件拷贝到对应CPU架构的目录: + +  ![thirdparty_install_dir](pic/harfbuzz_install_dir2.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句: + + ``` + #将三方库加入工程中,harfbuzz是对应的三方库名 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/harfbuzz/${OHOS_ARCH}/lib/libharfbuzz.so.0) + #将三方库的头文件加入工程中,harfbuzz是对应的三方库名 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/harfbuzz/${OHOS_ARCH}/include) + ``` + ![harfbuzz_usage](pic/harfbuzz_usage.png) + +## 测试三方库 + +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +进入到构建目录执行make check运行测试用例(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) + +有7个测试用例没通过,是因为这7个测试用例强依赖python环境,ohos设备不支持,所以没通过。 + + ![harfbuzz_test](pic/harfbuzz_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) +- [通过DevEco Studio开发一个NAPI工程](https://gitee.com/openharmony-sig/knowledge_demo_temp/blob/master/docs/napi_study/docs/hello_napi.md) \ No newline at end of file diff --git a/thirdparty/harfbuzz/docs/pic/harfbuzz_install_dir1.png b/thirdparty/harfbuzz/docs/pic/harfbuzz_install_dir1.png new file mode 100644 index 0000000000000000000000000000000000000000..c82ef7c6224587b17cb102c9c2a04f828163db81 Binary files /dev/null and b/thirdparty/harfbuzz/docs/pic/harfbuzz_install_dir1.png differ diff --git a/thirdparty/harfbuzz/docs/pic/harfbuzz_install_dir2.png b/thirdparty/harfbuzz/docs/pic/harfbuzz_install_dir2.png new file mode 100644 index 0000000000000000000000000000000000000000..e4fea691d369a88ac40986b57f01c19b50fab17e Binary files /dev/null and b/thirdparty/harfbuzz/docs/pic/harfbuzz_install_dir2.png differ diff --git a/thirdparty/harfbuzz/docs/pic/harfbuzz_test.png b/thirdparty/harfbuzz/docs/pic/harfbuzz_test.png new file mode 100644 index 0000000000000000000000000000000000000000..1e5a0d18863fead0022d69d9b08f01ba9a254db4 Binary files /dev/null and b/thirdparty/harfbuzz/docs/pic/harfbuzz_test.png differ diff --git a/thirdparty/harfbuzz/docs/pic/harfbuzz_usage.png b/thirdparty/harfbuzz/docs/pic/harfbuzz_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..2efe18a0069d54188bd179ed5a7b2285dbc3e4fd Binary files /dev/null and b/thirdparty/harfbuzz/docs/pic/harfbuzz_usage.png differ