diff --git a/thirdparty/unzip/HPKBUILD b/thirdparty/unzip/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..97b04b84460eb5c0430738540b027cfbdea07a91 --- /dev/null +++ b/thirdparty/unzip/HPKBUILD @@ -0,0 +1,77 @@ +# Contributor: Jeff Han +# Maintainer: Jeff Han +pkgname=unzip +pkgver=60 +pkgrel=0 +pkgdesc="" +url="" +archs=("armeabi-v7a" "arm64-v8a") +license=("Info-ZIP license") +depends=("bzip2") +makedepends=() + +source="https://sourceforge.net/projects/infozip/files/UnZip%206.x%20%28latest%29/UnZip%206.0/$pkgname$pkgver.tar.gz" + +autounpack=true +downloadpackage=true +buildtools="make" + +builddir=$pkgname${pkgver} +packagename=$builddir.tar.gz + +cc= +as= +# zip 采用makefile编译构建,为了保留构建环境(方便测试)。因此同一份源码在解压后分为两份,各自编译互不干扰 +prepare() { + cp -rf $builddir $builddir-$ARCH-build + # 将 bzip2 源码加入到 unzip 项目,使 unzip 支持 bzip2 算法,如果不需要 bzip2 算法可以不拷贝。此处 copy 有 bzip2 带版本号的目录,导致 bzip2 的版本变更会影响到 unzip 的编译,为了避免两个项目耦合过深,所以在 unzip 项目,我这里设置为默认是不支持 bzip2 注释28行。如果需要只需解开28行注释确认版本号目录即可。 + # cp -rf `pwd`/../bzip2/bzip2-1.0.6/* $builddir-$ARCH-build/bzip2/ + cd $builddir-$ARCH-build + if [ $ARCH == "armeabi-v7a" ] + then + cc=${OHOS_SDK}/native/llvm/bin/arm-linux-ohos-clang + as=${OHOS_SDK}/native/llvm/bin/llvm-as + fi + if [ $ARCH == "arm64-v8a" ] + then + cc=${OHOS_SDK}/native/llvm/bin/aarch64-linux-ohos-clang + as=${OHOS_SDK}/native/llvm/bin/llvm-as + fi + cd $OLDPWD # 1> /dev/null +} + +build() { + cd $builddir-$ARCH-build + make CC=${cc} AS=${as} -f unix/Makefile -j4 generic > `pwd`/build.log 2>&1 + ret=$? + if [ $ret == 0 ] + then + make CC=${cc} AS=${as} -f unix/Makefile -j4 generic_shlib >> `pwd`/build.log 2>&1 + ret=$? + fi + cd $OLDPWD + return $ret +} + +package() { + cd $builddir-$ARCH-build + make prefix=$LYCIUM_ROOT/usr/$pkgname/$ARCH -f unix/Makefile install >> `pwd`/build.log 2>&1 + # make install没有拷贝so和.h文件,需cp到usr目录 + mkdir -p $LYCIUM_ROOT/usr/$pkgname/$ARCH/include + cp ./*.h $LYCIUM_ROOT/usr/$pkgname/$ARCH/include + mkdir -p $LYCIUM_ROOT/usr/$pkgname/$ARCH/lib + cp ./*.so $LYCIUM_ROOT/usr/$pkgname/$ARCH/lib + + cd $OLDPWD + unset cc as +} + +check() { + echo "The test must be on an OpenHarmony device!" + # make check +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/$builddir $builddir-armeabi-v7a-build $builddir-arm64-v8a-build #${PWD}/$packagename +} diff --git a/thirdparty/unzip/OAT.xml b/thirdparty/unzip/OAT.xml new file mode 100644 index 0000000000000000000000000000000000000000..7f235d6c1e883ca58f7d47e9b1d3d32293bf9552 --- /dev/null +++ b/thirdparty/unzip/OAT.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/thirdparty/unzip/README.OpenSource b/thirdparty/unzip/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..5869dd38bb79a2e1117c7f85c119bda6643d115e --- /dev/null +++ b/thirdparty/unzip/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "unzip", + "License": "Info-ZIP license", + "License File": "LICENSE", + "Version Number": "60", + "Owner": "llh_01129@163.com", + "Upstream URL": "https://sourceforge.net/projects/infozip", + "Description": "Info-ZIP portable compression/archiver utilities (Zip, UnZip, WiZ, etc.)" + } +] diff --git a/thirdparty/unzip/README_zh.md b/thirdparty/unzip/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..e153078be672eb9b270a5a2dbd20ba2984073acd --- /dev/null +++ b/thirdparty/unzip/README_zh.md @@ -0,0 +1,11 @@ +# unzip三方库说明 +## 功能简介 +unzip为zip压缩文件的解压缩程序。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Release(3.1.0.500) +- SDK:API9 Release(3.2.12.2) +- 三方库版本:60 +- 当前适配的功能:解压缩zip文件 +- [Info-ZIP license](https://sourceforge.net/projects/infozip/) +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/unzip/SHA512SUM b/thirdparty/unzip/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..256cf5d29b4e73b762c627295b4c67a77a377ec7 --- /dev/null +++ b/thirdparty/unzip/SHA512SUM @@ -0,0 +1 @@ +0694e403ebc57b37218e00ec1a406cae5cc9c5b52b6798e0d4590840b6cdbf9ddc0d9471f67af783e960f8fa2e620394d51384257dca23d06bcd90224a80ce5d unzip60.tar.gz diff --git a/thirdparty/unzip/docs/hap_integrate.md b/thirdparty/unzip/docs/hap_integrate.md new file mode 100755 index 0000000000000000000000000000000000000000..3ae002bcb16f91299c89f46c0b70961ef5002e63 --- /dev/null +++ b/thirdparty/unzip/docs/hap_integrate.md @@ -0,0 +1,76 @@ +# unzip集成到应用hap +本库是在RK3568开发板上基于OpenHarmony3.2 Release版本的镜像验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 +## 开发环境 +- ubuntu20.04 +- [OpenHarmony3.2.1Release镜像](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2.1%2Fdayu200_standard_arm32.tar.gz) +- [ohos_sdk_public 3.2.12.5](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2.1%2Fohos-sdk-windows_linux-public.tar.gz) +- [DevEco Studio 3.1 release](https://contentcenter-vali-drcn.dbankcdn.cn/pvt_2/DeveloperAlliance_package_901_9/16/v3/YO_7mAQNTbS8jekrvez5IA/devecostudio-windows-3.1.0.500.zip?HW-CC-KV=V1&HW-CC-Date=20230512T073650Z&HW-CC-Expire=315360000&HW-CC-Sign=90814E421B9A6D8DB4757FAFC21A965CF890A387DF9A2633B4AB797AD77E6485) +- [准备三方库构建环境](../../../tools/README.md#编译环境准备) +- [准备三方库测试环境](../../../tools/README.md#ci环境准备) + +## 编译三方库 +- 下载本仓库 + ``` + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` +- 三方库目录结构 + ``` + tpc_c_cplusplus/thirdparty/unzip #三方库unzip的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将xerces拷贝至tools/main目录下 + ``` + cd tpc_c_cplusplus + cp thirdparty/unzip tools/main -rf + cp thirdparty/bzip2 tools/main -rf + ``` +- 在tools目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + ``` + cd tools + ./build.sh unzip bzip2 + ``` +- 三方库头文件及生成的库 + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ``` + unzip/arm64-v8a unzip/armeabi-v7a bzip2/arm64-v8a bzip2/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 +- 拷贝动态库到`\\entry\libs\${OHOS_ARCH}\`目录: + 动态库需要在`\\entry\libs\${OHOS_ARCH}\`目录,才能集成到hap包中,所以需要将对应的so文件拷贝到对应CPU架构的目录 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + +  ![unzip_install](pic/unzip_install.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ``` + + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/libunzip.so.0) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/unzip/${OHOS_ARCH}/include) + + ``` + ![unzip_usage](pic/unzip_usage.png) +## 测试三方库 +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +进入到构建目录执行make test -f ./unix/Makefile 运行测试用例(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) + +![unzip_test](pic/unzip_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) diff --git a/thirdparty/unzip/docs/pic/unzip_install.png b/thirdparty/unzip/docs/pic/unzip_install.png new file mode 100644 index 0000000000000000000000000000000000000000..ca5ffd8b375b2f0eff9aa7e26b6af7412ebb3bdc Binary files /dev/null and b/thirdparty/unzip/docs/pic/unzip_install.png differ diff --git a/thirdparty/unzip/docs/pic/unzip_test.png b/thirdparty/unzip/docs/pic/unzip_test.png new file mode 100644 index 0000000000000000000000000000000000000000..595d84782830956891dd1aebfbc947de57ab6bb6 Binary files /dev/null and b/thirdparty/unzip/docs/pic/unzip_test.png differ diff --git a/thirdparty/unzip/docs/pic/unzip_usage.png b/thirdparty/unzip/docs/pic/unzip_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..e164be450b13c78709c8bdf76d6cac2a5508b064 Binary files /dev/null and b/thirdparty/unzip/docs/pic/unzip_usage.png differ