diff --git a/thirdparty/lpeg/HPKBUILD b/thirdparty/lpeg/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..6e0fd93a6da86cc9104e2b125e67ba341087426b --- /dev/null +++ b/thirdparty/lpeg/HPKBUILD @@ -0,0 +1,85 @@ +# Contributor: Ding Qian <1052888395@qq.com> +# Maintainer: Ding Qian <1052888395@qq.com> +pkgname=lpeg +pkgver=master +pkgrel=0 +pkgdesc="Peg is a new pattern-matching library for Lua" +url="https://github.com/luvit/lpeg" +archs=("armeabi-v7a" "arm64-v8a") +license=("MIT") +depends=("LuaJIT") +makedepends=() +source="https://github.com/luvit/$pkgname.git" +commitid=fda374f3bbac50653bdeba7404d63e13972e6210 + +autounpack=false +downloadpackage=false +buildtools="make" + +builddir=$pkgname-${commitid} +packagename= +cloneflag=true +source envset.sh + +prepare() { + if [ $cloneflag == true ] + then + mkdir $builddir + git clone -b $pkgver $source $builddir + if [ $? != 0 ] + then + return -1 + fi + cd $builddir + git reset --hard $commitid + if [ $? != 0 ] + then + return -2 + fi + cd $OLDPWD + cloneflag=false + fi + + cp -rf $builddir $builddir-$ARCH-build + cd $builddir-$ARCH-build + if [ $ARCH == "armeabi-v7a" ] + then + setarm32ENV + fi + if [ $ARCH == "arm64-v8a" ] + then + setarm64ENV + fi + cd $OLDPWD +} + +build() { + cd $builddir-$ARCH-build + make CC=${CC} AR=${AR} CFLAGS="-Wno-macro-redefined -I ${LYCIUM_ROOT}/usr/LuaJIT/$ARCH/include/luajit-2.1 $CFLAGS" \ + LDFLAGS="${LDFLAGS} -L ${LYCIUM_ROOT}/usr/LuaJIT/$ARCH/lib" -j4 > `pwd`/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $builddir-$ARCH-build + mkdir -p $LYCIUM_ROOT/usr/$pkgname/$ARCH/include/ + mkdir -p $LYCIUM_ROOT/usr/$pkgname/$ARCH/lib/ + mkdir -p $LYCIUM_ROOT/usr/$pkgname/$ARCH/test/ + cp *.h $LYCIUM_ROOT/usr/$pkgname/$ARCH/include/ + cp *.so $LYCIUM_ROOT/usr/$pkgname/$ARCH/lib/ + cp *test* $LYCIUM_ROOT/usr/$pkgname/$ARCH/test/ + cd $OLDPWD + unset cc ar +} + +check() { + echo "The test must be on an OpenHarmony device!" + # TODO +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/$builddir $builddir-armeabi-v7a-build $builddir-arm64-v8a-build +} \ No newline at end of file diff --git a/thirdparty/lpeg/OAT.xml b/thirdparty/lpeg/OAT.xml new file mode 100644 index 0000000000000000000000000000000000000000..96937ea08644b79312d0ced7c0b3eb1e845108ee --- /dev/null +++ b/thirdparty/lpeg/OAT.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/thirdparty/lpeg/README.OpenSource b/thirdparty/lpeg/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..0fa0a2eb8425369ec11e33adc7aab94feee00998 --- /dev/null +++ b/thirdparty/lpeg/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "lpeg", + "License": "MIT license", + "License File": "LICENSES", + "Version Number": "master", + "Owner": "qiandinge@isoftstone.com", + "Upstream URL": "https://github.com/luvit/lpeg/archive/refs/heads/master.zip", + "Description": "LPeg is a new pattern-matching library for Lua, based on Parsing Expression Grammars (PEGs)" + } +] \ No newline at end of file diff --git a/thirdparty/lpeg/README_zh.md b/thirdparty/lpeg/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..f560f7bab9cf99cedcfab69f8ec4d770cb0df6f8 --- /dev/null +++ b/thirdparty/lpeg/README_zh.md @@ -0,0 +1,12 @@ +# lpeg三方库说明 +## 功能简介 +LPEG是一个供lua使用的基于 Parsing Expression Grammars 的模式匹配库 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Release +- SDK版本:ohos_sdk_public 4.0.8.1 (API Version 10 Release) +- 三方库版本:master +- 当前适配的功能:LPEG是一个供lua使用的基于 Parsing Expression Grammars 的模式匹配库 +- [BSD-3-Clause license](http://www.inf.puc-rio.br/~roberto/lpeg/#license) + +## 集成方式 ++ [应用hap包集成](docs/hap_ingtegrate.md) \ No newline at end of file diff --git a/thirdparty/lpeg/SHA512SUM b/thirdparty/lpeg/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..3fdba504f10118257cd0c8e6f9b5dd6f39571e8d --- /dev/null +++ b/thirdparty/lpeg/SHA512SUM @@ -0,0 +1 @@ +c7bfefac102f06dc2504af8f446e12672f1886e751bddf5bc4b0b9093945b5033c5a5acb7236dd2fc7e118a65a61d8f7a7c3ba0e946f8d772862b912aba09bc8 lpeg-master.zip diff --git a/thirdparty/lpeg/docs/hap_ingtegrate.md b/thirdparty/lpeg/docs/hap_ingtegrate.md new file mode 100644 index 0000000000000000000000000000000000000000..b7e80ffb5c3301fe562fae357bb160c780993964 --- /dev/null +++ b/thirdparty/lpeg/docs/hap_ingtegrate.md @@ -0,0 +1,80 @@ +# lpeg集成到应用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 4.0.8.1 (API Version 10 Release)](https://gitee.com/link?target=http%3A%2F%2Fdownload.ci.openharmony.cn%2Fversion%2FMaster_Version%2FOpenHarmony_4.0.8.1%2F20230608_091058%2Fversion-Master_Version-OpenHarmony_4.0.8.1-20230608_091058-ohos-sdk-public.tar.gz) +- [DevEco Studio 3.1 Release](https://gitee.com/link?target=https%3A%2F%2Fcontentcenter-vali-drcn.dbankcdn.cn%2Fpvt_2%2FDeveloperAlliance_package_901_9%2F81%2Fv3%2FtgRUB84wR72nTfE8Ir_xMw%2Fdevecostudio-windows-3.1.0.501.zip%3FHW-CC-KV%3DV1%26HW-CC-Date%3D20230621T074329Z%26HW-CC-Expire%3D315360000%26HW-CC-Sign%3D22F6787DF6093ECB4D4E08F9379B114280E1F65DA710599E48EA38CB24F3DBF2) +- [准备三方库构建环境](../../../tools/README.md#编译环境准备) +- [准备三方库测试环境](../../../tools/README.md#ci环境准备) +## 编译三方库 +- 下载本仓库 + ``` + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` +- 三方库目录结构 + ``` + tpc_c_cplusplus/thirdparty/lpeg #三方库lpeg的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将lpeg拷贝至tools/main目录下 + ``` + cd tpc_c_cplusplus + cp thirdparty/lpeg tools/main -rf + ``` +- 在tools目录下编译三方库 + lpeg库需要依赖LuaJIT这个库,所以在build时需要将依赖库一起编译进来 + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + ``` + cd tools + ./build.sh lpeg LuaJIT + ``` +- 三方库头文件及生成的库 + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + ``` + lpeg/arm64-v8a lpeg/armeabi-v7a + LuaJIT/arm64-v8a LuaJIT/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库和依赖库拷贝到该目录下,如下图所示 +   + ![thirdparty_install_dir](pic/lpeg_install_dir.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ```shell + #将三方库加入工程中 + target_link_libraries(entry PRIVATE -LCMAKECURRENTSOURCEDIR/../../../libs/{OHOS_ARCH}/lpeg.so) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE CMAKECURRENTSOURCEDIR/thirdparty/lpeg/{OHOS_ARCH}/include) + + ``` + +![lpeg_usage](pic/lpeg_usage.png) + +## 测试三方库 +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +- 将编译生成的可执行文件及生成的动态库准备好 + +- 将准备好的文件推送到开发板,进入到构建的目录添加执行文件权限和lib库环境执行ctest + ![lpeg_test](pic/lpeg_test.png) + + +StalenessCheckTest测试选项需要依赖python环境,导致测试错误 +## 参考资料 +- [润和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/lpeg/docs/pic/lpeg_install_dir.png b/thirdparty/lpeg/docs/pic/lpeg_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..c306b45e8ae1b0241814c7d68098342ccc2e0a50 Binary files /dev/null and b/thirdparty/lpeg/docs/pic/lpeg_install_dir.png differ diff --git a/thirdparty/lpeg/docs/pic/lpeg_test.png b/thirdparty/lpeg/docs/pic/lpeg_test.png new file mode 100644 index 0000000000000000000000000000000000000000..3dc5b13f16d4cbb8feae8af0688130cb1303d1e9 Binary files /dev/null and b/thirdparty/lpeg/docs/pic/lpeg_test.png differ diff --git a/thirdparty/lpeg/docs/pic/lpeg_usage.png b/thirdparty/lpeg/docs/pic/lpeg_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..01d7f9a57e6f5f1f11d10acf075d3fb4d1814975 Binary files /dev/null and b/thirdparty/lpeg/docs/pic/lpeg_usage.png differ