diff --git a/thirdparty/libxls/HPKBUILD b/thirdparty/libxls/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..93cf62fd93172a242ba40c8e987c4b87c7b06762 --- /dev/null +++ b/thirdparty/libxls/HPKBUILD @@ -0,0 +1,85 @@ +# Contributor: wupingyuan +# Maintainer: wupingyuan +pkgname=libxls +pkgver=v1.6.2 +pkgrel=0 +pkgdesc="This is libxls, a C library for reading Excel files in the nasty old binary OLE format, plus a command-line tool for converting XLS to CSV (named, appropriately enough, xls2csv)." +url="https://github.com/libxls/libxls" +archs=("armeabi-v7a" "arm64-v8a") +license=("BSD") +depends=() +makedepends=() +install= +source="https://github.com/$pkgname/$pkgname/archive/refs/tags/$pkgver.tar.gz" + +autounpack=true +downloadpackage=true +buildtools="configure" +builddir=$pkgname-${pkgver:1} +packagename=$builddir.tar.gz +source envset.sh +host= + +prepare() { + if $patchflag + then + cd $builddir + # 由于configure.ac中的函数引起编译报错以下: + # AX_CXX_COMPILE_STDCXX_11:syntax error near unexpected token `,' + # AC_FUNC_MALLOC:undefined reference to malloc + # AC_FUNC_REALLOC:undefined reference to realloc + patch -p1 < `pwd`/../libxls_oh_pkg.patch + patchflag=false + cd $OLDPWD + fi + cp -r $builddir $pkgname-$ARCH-build + if [ $ARCH == "armeabi-v7a" ] + then + setarm32ENV + host=arm-linux + fi + if [ $ARCH == "arm64-v8a" ] + then + setarm64ENV + host=aarch64-linux + fi + cd $pkgname-$ARCH-build + autoreconf -i > `pwd`/build.log 2>&1 + cd $OLDPWD +} + +build() { + cd $pkgname-$ARCH-build + ./configure "$@" --host=$host --enable-static >> `pwd`/build.log 2>&1 + make -j4 >> `pwd`/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $pkgname-$ARCH-build + make install >> `pwd`/build.log 2>&1 + ret=$? + cd $OLDPWD + if [ $ARCH == "armeabi-v7a" ] + then + unsetarm32ENV + fi + if [ $ARCH == "arm64-v8a" ] + then + unsetarm64ENV + fi + unset host + return $ret +} + +check() { + echo "The test must be on an OpenHarmony device!" + # 在OpenHarmony开发板中执行用例 + # make check +} + +cleanbuild(){ + rm -rf ${PWD}/$builddir $builddir-armeabi-v7a-build $builddir-arm64-v8a-build #${PWD}/$packagename +} diff --git a/thirdparty/libxls/README.OpenSource b/thirdparty/libxls/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..91412c7e4a7a7b8b36815705ab9d4b7a1e458ef7 --- /dev/null +++ b/thirdparty/libxls/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "libxls", + "License": "BSD", + "License File": "LICENSE", + "Version Number": "v1.6.2", + "Owner": "wupingyuan@huawei.com", + "Upstream URL": "https://github.com/libxls/libxls/archive/refs/tags/v1.6.2.tar.gz", + "Description": "This is libxls, a C library for reading Excel files in the nasty old binary OLE format, plus a command-line tool for converting XLS to CSV (named, appropriately enough, xls2csv)." + } +] diff --git a/thirdparty/libxls/README_zh.md b/thirdparty/libxls/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..b6a94ec604905d99c7860d6856dd72ccab9d3448 --- /dev/null +++ b/thirdparty/libxls/README_zh.md @@ -0,0 +1,12 @@ +# libxls三方库说明 +## 功能简介 +libxls是一个解析Excel表格的库。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Beta2 +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:v1.6.2 +- 当前适配的功能:解析Excel表格 +- [BSD](https://github.com/libxls/libxls) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/libxls/SHA512SUM b/thirdparty/libxls/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..f8ed4eee9392f1c653de586f0dd91e2ee55b9d6b --- /dev/null +++ b/thirdparty/libxls/SHA512SUM @@ -0,0 +1,2 @@ +9eb8dc78d9070ebe5af2629a358cea0f41db9e4accdfc2651093eaffaaeff5595e986346fa41a3b57740234f4a70d5aa394e5234f90e94ba41a782de574e4d00 libxls-1.6.2.tar.gz +073a62c231182203c68c0f6b4cc2b8218ac693c9be3b667bc12a14e66be8a8a2e8a04c47e53421479460076d7b9e2038f8a11e01981a7e4016b160f45c460a5b libxls_oh_pkg.patch \ No newline at end of file diff --git a/thirdparty/libxls/docs/hap_integrate.md b/thirdparty/libxls/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..dbc30be703595c65374c0aced7975faae2c83aaf --- /dev/null +++ b/thirdparty/libxls/docs/hap_integrate.md @@ -0,0 +1,68 @@ +# libxls集成到应用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/libxls #三方库libxls的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── libxls_oh_pkg.patch #补丁 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将libxls拷贝至tools/main目录下 + ``` + cd tpc_c_cplusplus + cp thirdparty/libxls tools/main -rf + ``` +- 在tools目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + ``` + cd tools + ./build.sh libxls + ``` +- 三方库头文件及生成的库 + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + ``` + libxls/arm64-v8a libxls/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + ![thirdparty_install_dir](pic/libxls_install_dir.jpg) +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ``` + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libxls/${OHOS_ARCH}/lib/libxlsreader.a) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libxls/${OHOS_ARCH}/include) + ``` + ![libxls_usage](pic/libxls_usage.jpg) +## 测试三方库 +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +进入到构建目录执行make check运行测试用例(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) + + ![libxls_test](pic/libxls_test.jpg) + +## 参考资料 +- [润和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/libxls/docs/pic/libxls_install_dir.jpg b/thirdparty/libxls/docs/pic/libxls_install_dir.jpg new file mode 100644 index 0000000000000000000000000000000000000000..66ff67e4734e6cc57e839faf07cbe1f302f4de57 Binary files /dev/null and b/thirdparty/libxls/docs/pic/libxls_install_dir.jpg differ diff --git a/thirdparty/libxls/docs/pic/libxls_test.jpg b/thirdparty/libxls/docs/pic/libxls_test.jpg new file mode 100644 index 0000000000000000000000000000000000000000..58afc6c6ac98b42c93fb2187fed8011edfa5c970 Binary files /dev/null and b/thirdparty/libxls/docs/pic/libxls_test.jpg differ diff --git a/thirdparty/libxls/docs/pic/libxls_usage.jpg b/thirdparty/libxls/docs/pic/libxls_usage.jpg new file mode 100644 index 0000000000000000000000000000000000000000..46ab32706a7c92c26362009ca44d19f981281146 Binary files /dev/null and b/thirdparty/libxls/docs/pic/libxls_usage.jpg differ diff --git a/thirdparty/libxls/libxls_oh_pkg.patch b/thirdparty/libxls/libxls_oh_pkg.patch new file mode 100644 index 0000000000000000000000000000000000000000..600c5c7437dd1fc9e6b14292641b2c61539343bf --- /dev/null +++ b/thirdparty/libxls/libxls_oh_pkg.patch @@ -0,0 +1,23 @@ +diff -Naur libxls-1.6.2/configure.ac libxls-1.6.2-patch/configure.ac +--- libxls-1.6.2/configure.ac 2021-01-04 12:31:47.000000000 +0800 ++++ libxls-1.6.2-patch/configure.ac 2023-04-21 14:23:05.765474123 +0800 +@@ -37,7 +37,7 @@ + AC_PROG_CC + AC_PROG_CC_C99 + AC_PROG_CXX +-AX_CXX_COMPILE_STDCXX_11([], [optional]) ++#AX_CXX_COMPILE_STDCXX_11([], [optional]) + + AS_IF([test "x$HAVE_CXX11" != x1], [ + AC_MSG_NOTICE([---]) +@@ -48,8 +48,8 @@ + + AC_CHECK_FUNCS([strdup wcstombs_l]) + AC_CHECK_HEADERS([wchar.h xlocale.h]) +-AC_FUNC_MALLOC +-AC_FUNC_REALLOC ++#AC_FUNC_MALLOC ++#AC_FUNC_REALLOC + AC_TYPE_SIZE_T + + AC_ARG_ENABLE([fuzz-testing], AS_HELP_STRING([--enable-fuzz-testing], ["Enable fuzz testing (requires Clang 6 or later)"]), [