diff --git a/thirdparty/lua-amf3/HPKBUILD b/thirdparty/lua-amf3/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..b156a1a0156fcbbd7afde9708fa2807e7e0f3a5c --- /dev/null +++ b/thirdparty/lua-amf3/HPKBUILD @@ -0,0 +1,72 @@ +# Contributor: Chen Xu +# Maintainer: Chen Xu +pkgname=lua-amf3 +pkgver=2.0.5 +pkgrel=0 +pkgdesc="lua-amf3 provides fast AMF3 encoding/decoding routines for Lua." +url="https://github.com/neoxic/lua-amf3" +archs=("armeabi-v7a" "arm64-v8a") +license=("MIT License") +depends=("LuaJIT") +makedepends=() +source="https://github.com/neoxic/$pkgname/archive/refs/tags/$pkgver.tar.gz" + +autounpack=true +downloadpackage=true + +builddir=$pkgname-${pkgver} +packagename=$builddir.tar.gz + +source envset.sh + +prepare() { + mkdir -p $builddir/$ARCH-build + if [ $ARCH == "armeabi-v7a" ] + then + setarm32ENV + fi + if [ $ARCH == "arm64-v8a" ] + then + setarm64ENV + fi +} + +build() { + cd $builddir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake "$@" -DUSE_LUA_VERSION=jit -DCMAKE_PREFIX_PATH=${LYCIUM_ROOT}/usr/LuaJIT/$ARCH \ + -DCMAKE_SHARED_LINKER_FLAGS="-L${LYCIUM_ROOT}/usr/LuaJIT/$ARCH/lib -lluajit-5.1" \ + -DLUA_COMMAND="${LYCIUM_ROOT}/usr/LuaJIT/$ARCH/bin/luajit-2.1.0-beta3" \ + -DOHOS_ARCH=$ARCH -B$ARCH-build -S./ -L > `pwd`/$ARCH-build/build.log 2>&1 + + # 编译 + make -j4 -C $ARCH-build VERBOSE=1 >> `pwd`/$ARCH-build/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $builddir + make -C $ARCH-build install VERBOSE=1 >> `pwd`/$ARCH-build/build.log 2>&1 + cd $OLDPWD +} + +check() { + if [ $ARCH == "armeabi-v7a" ] + then + unsetarm32ENV + fi + if [ $ARCH == "arm64-v8a" ] + then + unsetarm64ENV + fi + echo "The test must be on an OpenHarmony device!" + # export ROOT_PATH=/data/local/tmp/lycium + # cd ${ROOT_PATH}/main/lua-amf3/lua-amf3-2.0.5/arm64-v8a-build + # ctest +} + +# 清理环境 +cleanbuild() { + rm -rf ${PWD}/$builddir $builddir-armeabi-v7a-build $builddir-arm64-v8a-build #${PWD}/$packagename +} diff --git a/thirdparty/lua-amf3/HPKCHECK b/thirdparty/lua-amf3/HPKCHECK new file mode 100644 index 0000000000000000000000000000000000000000..7f3e48cc7cbc729801a6c67edb9dbf9e58611c15 --- /dev/null +++ b/thirdparty/lua-amf3/HPKCHECK @@ -0,0 +1,19 @@ +# Contributor: Chen Xu +# Maintainer: Chen Xu + +source HPKBUILD > /dev/null 2>&1 +logfile=${LYCIUM_THIRDPARTY_ROOT}/${pkgname}/${pkgname}_${ARCH}_${OHOS_SDK_VER}_test.log + +openharmonycheck() { + res=0 + cd $builddir/$ARCH-build + ctest > ${logfile} 2>&1 + res=$? + if [ $res -ne 0 ] + then + mkdir ${LYCIUM_FAULT_PATH}/${pkgname} + cp Testing/Temporary/LastTest.log ${LYCIUM_FAULT_PATH}/${pkgname}/ + fi + cd $OLDPWD + return $res +} diff --git a/thirdparty/lua-amf3/OAT.xml b/thirdparty/lua-amf3/OAT.xml new file mode 100644 index 0000000000000000000000000000000000000000..59b89c6535b6c4ce513410a7645a51ddf2d48abd --- /dev/null +++ b/thirdparty/lua-amf3/OAT.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/thirdparty/lua-amf3/README.OpenSource b/thirdparty/lua-amf3/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..12d6a751126a6cbbc6d9eaaf16550988e56279a9 --- /dev/null +++ b/thirdparty/lua-amf3/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "lua-amf3", + "License": "MIT License", + "License File": "LICENSE", + "Version Number": "2.0.5", + "Owner": "chenxu.unix@gmail.com", + "Upstream URL": "https://github.com/neoxic/lua-amf3.git", + "Description": "lua-amf3 provides fast AMF3 encoding/decoding routines for Lua." + } +] diff --git a/thirdparty/lua-amf3/README_zh.md b/thirdparty/lua-amf3/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..c6a2023fb48ace61fc1d2204f90802add7d9b9b7 --- /dev/null +++ b/thirdparty/lua-amf3/README_zh.md @@ -0,0 +1,11 @@ +# lua-amf3三方库说明 +## 功能简介 +lua-amf3为lua提供AMF二进制格式数据编解码功能。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Release +- SDK版本:ohos_sdk_public 4.0.8.1 (API Version 10 Release) +- 三方库版本:2.0.5 +- 当前适配的功能:读取解析xml + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/lua-amf3/SHA512SUM b/thirdparty/lua-amf3/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..03559a54949963b4689b34ddd69fef6eef9566de --- /dev/null +++ b/thirdparty/lua-amf3/SHA512SUM @@ -0,0 +1 @@ +e8bd2a57a1313bdb9f454de5d9662ed272cde73658f35726861d697be08b97f8b9ced39b01633a4eb23d5e10a795ca443b45adcc7511e0c953ee8305ea4fdec6 lua-amf3-2.0.5.tar.gz diff --git a/thirdparty/lua-amf3/docs/hap_integrate.md b/thirdparty/lua-amf3/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..36d5dfa4967486d3e8939781482b7e208ddce40a --- /dev/null +++ b/thirdparty/lua-amf3/docs/hap_integrate.md @@ -0,0 +1,74 @@ +# lua-amf3集成到应用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) +- [准备三方库构建环境](../../../lycium/README.md#1编译环境准备) +- [准备三方库测试环境](../../../lycium/README.md#3ci环境准备) +## 编译三方库 +- 下载本仓库 + ``` + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` +- 三方库目录结构 + ``` + tpc_c_cplusplus/thirdparty/lua-amf3 #三方库lua-amf3的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── OAT.xml #OAT文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 在lycium目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../lycium/README.md#1编译环境准备) + + ``` + cd lycium + ./build.sh lua-amf3 + ``` +- 三方库头文件及生成的库 + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + ``` + lua-amf3/armeabi-v7a lua-amf3/arm64-v8a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty\lua-amf3\arm64-v8a\include目录和thirdparty\lua-amf3\armeabi-v7a\include目录,将编译机器上面的tpc_c_cplusplus/thirdparty/lua-amf3/lua-amf3-2.0.5/src路径下的amf3.h文件拷贝到工程的cpp\thirdparty\lua-amf3\arm64-v8a\include目录下 +32位的拷贝到工程的cpp\thirdparty\lua-amf3\armeabi-v7a\include目录下 +- 在IDE的libs目录下新增arm64-v8a目录和armeabi-v7a目录,分别将64位和32位的amf3.so文件放到该目录下,如下图所示: + + ![thirdparty_install_dir](pic/screen_cut.jpg) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ``` + #将三方库加入工程中 + target_link_libraries(entry PRIVATE -L${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/amf3.so) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/lua-amf3/${OHOS_ARCH}/include) + ``` + +## 测试三方库 +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../lycium/README.md#3ci环境准备) + +- 进入到构建目录,执行如下命令(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) +注意:以下为64位命令,如需测试32位,请将arm64-v8a替换为armeabi-v7a。 +``` +ctest +``` + +测试用例运行结果如下: + + ![lua-amf3_test](pic/run_screen_cut.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/lua-amf3/docs/pic/run_screen_cut.jpg b/thirdparty/lua-amf3/docs/pic/run_screen_cut.jpg new file mode 100644 index 0000000000000000000000000000000000000000..fbb7cc1ec2848cb4364aff7494ad00cce9fc5028 Binary files /dev/null and b/thirdparty/lua-amf3/docs/pic/run_screen_cut.jpg differ diff --git a/thirdparty/lua-amf3/docs/pic/screen_cut.jpg b/thirdparty/lua-amf3/docs/pic/screen_cut.jpg new file mode 100755 index 0000000000000000000000000000000000000000..2427b3b2a25008a50994a1a907b0a590c00cd914 Binary files /dev/null and b/thirdparty/lua-amf3/docs/pic/screen_cut.jpg differ