diff --git a/thirdparty/uchardet/HPKBUILD b/thirdparty/uchardet/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..4b6e10af1b281fe7c0f0de80d90feb9370267904 --- /dev/null +++ b/thirdparty/uchardet/HPKBUILD @@ -0,0 +1,49 @@ +# Contributor: Jeff Han +# Maintainer: Jeff Han +pkgname=uchardet +pkgver=v0.0.8 +pkgrel=0 +pkgdesc="uchardet is an encoding detector library, which takes a sequence of bytes in an unknown character encoding without any additional information, and attempts to determine the encoding of the text. Returned encoding names are iconv-compatible." +url="https://www.freedesktop.org/wiki/Software/uchardet/" +archs=("armeabi-v7a" "arm64-v8a") +license=("MOZILLA PUBLIC LICENSE" "GPLV2" "LGPLV2") +depends=() +makedepends=() + +source="https://gitlab.freedesktop.org/$pkgname/$pkgname/-/archive/$pkgver/$pkgname-$pkgver.tar.gz" + +autounpack=true +downloadpackage=true + +builddir=$pkgname-${pkgver} +packagename=$builddir.tar.gz + +prepare() { + mkdir -p $builddir/$ARCH-build +} + +build() { + cd $builddir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake "$@" -DOHOS_ARCH=$ARCH -B$ARCH-build -S./ -L > `pwd`/$ARCH-build/build.log 2>&1 + make -j4 -C $ARCH-build >> `pwd`/$ARCH-build/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 +} + +check() { + echo "The test must be on an OpenHarmony device!" + # real test CMD + # ctest +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/$builddir #${PWD}/$packagename +} diff --git a/thirdparty/uchardet/README.OpenSource b/thirdparty/uchardet/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..f252c236ef5238d288fe9668631bfe844f9c4a12 --- /dev/null +++ b/thirdparty/uchardet/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "uchardet", + "License": " MOZILLA PUBLIC LICENSE GPLV2 LGPLV2 ", + "License File": "COPYING", + "Version Number": "v0.0.8", + "Owner": "hanjinfei@foxmail.com", + "Upstream URL": "https://gitlab.freedesktop.org/uchardet/uchardet/-/archive/v0.0.8/uchardet-v0.0.8.tar.gz", + "Description": "uchardet is an encoding detector library, which takes a sequence of bytes in an unknown character encoding without any additional information, and attempts to determine the encoding of the text. Returned encoding names are iconv-compatible." + } +] diff --git a/thirdparty/uchardet/README_zh.md b/thirdparty/uchardet/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..fce8fb10a9bfaeba2053dd66b464aa76788fd026 --- /dev/null +++ b/thirdparty/uchardet/README_zh.md @@ -0,0 +1,12 @@ +# uchardet 三方库说明 +## 功能简介 +uchardet is an encoding detector library, which takes a sequence of bytes in an unknown character encoding without any additional information, and attempts to determine the encoding of the text. Returned encoding names are iconv-compatible. +## 使用约束 +- IDE版本:DevEco Studio 3.1 Beta2 +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:v0.0.8 +- 当前适配的功能:encoding detector +- [ "MOZILLA PUBLIC LICENSE" "GPLV2" "LGPLV2" ](https://www.freedesktop.org/wiki/Software/uchardet/) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/uchardet/SHA512SUM b/thirdparty/uchardet/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..a42d9baa19465346b9e5da4ee20c1d0a64fd3474 --- /dev/null +++ b/thirdparty/uchardet/SHA512SUM @@ -0,0 +1 @@ +8d7a0abe1fcf7e92f9e264252eefa5810176603e3d3d825a23c3f5d23cd4f7cce9a0a9539e84bd70af5b66688394e48af00a00ce759a5a3d69b650f92351b6f2 uchardet-v0.0.8.tar.gz diff --git a/thirdparty/uchardet/docs/hap_integrate.md b/thirdparty/uchardet/docs/hap_integrate.md new file mode 100755 index 0000000000000000000000000000000000000000..1806dca03395f09b7d2f0b6a9d251af7402a33cc --- /dev/null +++ b/thirdparty/uchardet/docs/hap_integrate.md @@ -0,0 +1,72 @@ +# uchardet 集成到应用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环境准备) +## 编译三方库 +- 下载本仓库 + ``` + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` +- 三方库目录结构 + ``` + tpc_c_cplusplus/thirdparty/uchardet #三方库 uchardet 的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将 uchardet 拷贝至tools/main目录下 + ``` + cd tpc_c_cplusplus + cp thirdparty/uchardet tools/main -rf + ``` +- 在tools目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + ``` + cd tools + ./build.sh uchardet + ``` +- 三方库头文件及生成的库 + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ``` + uchardet/arm64-v8a uchardet/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 +- 拷贝动态库到`\\entry\libs\${OHOS_ARCH}\`目录: + 动态库需要在`\\entry\libs\${OHOS_ARCH}\`目录,才能集成到hap包中,所以需要将对应的so文件拷贝到对应CPU架构的目录 +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + ![thirdparty_install_dir](pic/uchardet_install_dir.png) +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ``` + + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/libuchardet.so.0) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/include/uchardet/${OHOS_ARCH}) + + ``` + ![uchardet usage](pic/uchardet_usage.png) +## 测试三方库 +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +进入到构建目录执行ctest运行测试用例(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) + + ![uchardet_test](pic/uchardet_test1.png) + ![uchardet_test](pic/uchardet_test2.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) diff --git a/thirdparty/uchardet/docs/pic/uchardet_install_dir.png b/thirdparty/uchardet/docs/pic/uchardet_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..bfc1a711784e17f23039f95f47025e70d773728a Binary files /dev/null and b/thirdparty/uchardet/docs/pic/uchardet_install_dir.png differ diff --git a/thirdparty/uchardet/docs/pic/uchardet_test1.png b/thirdparty/uchardet/docs/pic/uchardet_test1.png new file mode 100644 index 0000000000000000000000000000000000000000..7d49c460f6007add3c4ca16090efbdb7bb9c02c2 Binary files /dev/null and b/thirdparty/uchardet/docs/pic/uchardet_test1.png differ diff --git a/thirdparty/uchardet/docs/pic/uchardet_test2.png b/thirdparty/uchardet/docs/pic/uchardet_test2.png new file mode 100644 index 0000000000000000000000000000000000000000..19464f08888182daa87ea35f8a4e7fad68f95f2e Binary files /dev/null and b/thirdparty/uchardet/docs/pic/uchardet_test2.png differ diff --git a/thirdparty/uchardet/docs/pic/uchardet_usage.png b/thirdparty/uchardet/docs/pic/uchardet_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..d7086248abbdaa8c618ad956c4166c0d7d32196b Binary files /dev/null and b/thirdparty/uchardet/docs/pic/uchardet_usage.png differ