diff --git a/thirdparty/lua/HPKBUILD b/thirdparty/lua/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..b760e5deebca6547bc2d7a825bc5cdc432976f96 --- /dev/null +++ b/thirdparty/lua/HPKBUILD @@ -0,0 +1,88 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Contributor: xuxingguo <554249301@qq.com> +# Maintainer: xuxingguo <554249301@qq.com> + +pkgname=lua +pkgver=v5.4.6 +pkgrel=0 +pkgdesc="Lua is a powerful, efficient, lightweight, embeddable scripting language." +url="https://www.lua.org" +archs=("armeabi-v7a" "arm64-v8a") +license=("MIT License") +depends=() +makedepends=() +source="https://github.com/lua/$pkgname/archive/refs/tags/$pkgver.tar.gz" + +downloadpackage=true +autounpack=true +buildtools="make" + +builddir=$pkgname-${pkgver:1} +packagename=$builddir.tar.gz + +source envset.sh + +cc= +ar= +ld= +prepare() { + cp -rf $builddir $builddir-$ARCH-build/ + if [ $ARCH == "armeabi-v7a" ];then + setarm32ENV + cc=${OHOS_SDK}/native/llvm/bin/arm-linux-ohos-clang + elif [ $ARCH == "arm64-v8a" ];then + setarm64ENV + cc=${OHOS_SDK}/native/llvm/bin/aarch64-linux-ohos-clang + else + echo "$ARCH not support" + return -1 + fi + + ld=${OHOS_SDK}/native/llvm/bin/ld.lld + ar=${OHOS_SDK}/native/llvm/bin/llvm-ar +} + +build() { + $MAKE CC=${cc} LD=${ld} CFLAGS=-DLUA_USE_LINUX MYLIBS=-ldl -j4 -C $builddir-$ARCH-build VERBOSE=1 > \ + $builddir-$ARCH-build/$buildlog 2>&1 + ret=$? + return $ret +} + +package() { + # lua 5.4.6不支持make install,故需要copy文件 + mkdir -p $LYCIUM_ROOT/usr/$pkgname/$ARCH/include + mkdir -p $LYCIUM_ROOT/usr/$pkgname/$ARCH/lib + mkdir -p $LYCIUM_ROOT/usr/$pkgname/$ARCH/bin + find ./$builddir-$ARCH-build -name '*.so' -exec cp -af {} $LYCIUM_ROOT/usr/$pkgname/$ARCH/lib/ \; + find ./$builddir-$ARCH-build -name 'liblua.a' -exec cp -af {} $LYCIUM_ROOT/usr/$pkgname/$ARCH/lib/ \; + find ./$builddir-$ARCH-build -name 'lua' -exec cp -af {} $LYCIUM_ROOT/usr/$pkgname/$ARCH/bin/ \; + find ./$builddir-$ARCH-build -name 'luac' -exec cp -af {} $LYCIUM_ROOT/usr/$pkgname/$ARCH/bin/ \; + find ./$builddir-$ARCH-build -name '*.h' -exec cp -af {} $LYCIUM_ROOT/usr/$pkgname/$ARCH/include/ \; +} + +recoverpkgbuildenv() { + unset cc ar ld +} + +check() { + echo "The test must be on an OpenHarmony device!" +} + +# 清理环境 +cleanbuild() { + rm -rf $builddir-armeabi-v7a-build $builddir-arm64-v8a-build + rm -rf $builddir # $packagename +} diff --git a/thirdparty/lua/HPKCHECK b/thirdparty/lua/HPKCHECK new file mode 100644 index 0000000000000000000000000000000000000000..6388a878f604ad540a8436d7ccbfa9308dac923a --- /dev/null +++ b/thirdparty/lua/HPKCHECK @@ -0,0 +1,30 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Contributor: xuxingguo <554249301@qq.com> +# Maintainer: xuxingguo <554249301@qq.com> + +source HPKBUILD > /dev/null 2>&1 # 导入HPKBUILD文件 +logfile=${LYCIUM_THIRDPARTY_ROOT}/${pkgname}/${pkgname}_${ARCH}_${OHOS_SDK_VER}_test.log + +# 在OH环境执行测试的接口 +openharmonycheck() { + res=0 + cd $builddir + + ${LYCIUM_ROOT}/../lycium/usr/lua/${ARCH}/bin/lua -v > ${logfile} 2>&1 + res=$? + rm -rf /usr/local/lib + cd $OLDPWD + return $res +} \ No newline at end of file diff --git a/thirdparty/lua/OAT.xml b/thirdparty/lua/OAT.xml new file mode 100644 index 0000000000000000000000000000000000000000..eeb1f946d683c0b81976cd06522096062a6901b9 --- /dev/null +++ b/thirdparty/lua/OAT.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/thirdparty/lua/README.OpenSource b/thirdparty/lua/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..7ee6d8f4820ccd924917948bb006cb5b56833950 --- /dev/null +++ b/thirdparty/lua/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "lua", + "License": "MIT license", + "License File": "readme.html", + "Version Number": "v5.4.6", + "Owner": "xiafeng@huawei.com", + "Upstream URL": "https://www.lua.org", + "Description": "Lua is a powerful, efficient, lightweight, embeddable scripting language." + } +] \ No newline at end of file diff --git a/thirdparty/lua/README_zh.md b/thirdparty/lua/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..9ee3ab768eff09b0aced7c78f58fdacd01cce222 --- /dev/null +++ b/thirdparty/lua/README_zh.md @@ -0,0 +1,11 @@ +# lua三方库说明 +## 功能简介 +Lua是一种强大、高效、轻量级、可嵌入的脚本语言。它支持过程编程、面向对象编程、函数式编程、数据驱动编程和数据描述 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Release +- SDK版本:ohos_sdk_public 4.0.8.1 (API Version 10 Release) +- 三方库版本:v5.4.6 +- 当前适配的功能:支持过程编程、面向对象编程、函数式编程、数据驱动编程和数据描述 + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/lua/SHA512SUM b/thirdparty/lua/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..f41a70257c4026acef3e95b2a65d8f25f67b24e0 --- /dev/null +++ b/thirdparty/lua/SHA512SUM @@ -0,0 +1 @@ +6582711740695500cf291a4e32061d74b046839a4128f2c135ceb27929a840ab85429342ef9b5f0221dffa3e7e4955c42fccdfd501822d42291bc9728cb4b4ae lua-5.4.6.tar.gz \ No newline at end of file diff --git a/thirdparty/lua/docs/hap_integrate.md b/thirdparty/lua/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..6ea65874c826983bbee416dc304b2a6f088cab1b --- /dev/null +++ b/thirdparty/lua/docs/hap_integrate.md @@ -0,0 +1,71 @@ +# lua 集成到应用hap + +本库是在RK3568开发板上基于OpenHarmony3.2 Release版本的镜像验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 + +## 开发环境 + +- [开发环境准备](../../../docs/hap_integrate_environment.md) + +## 编译三方库 + +- 下载本仓库 + + ```shell + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 三方库目录结构 + + ```shell + tpc_c_cplusplus/thirdparty/lua #三方库lua的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── HPKCHECK #测试脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md #三方库简介 + ``` + +- 在lycium目录下编译三方库 + + 编译环境的搭建参考[准备三方库构建环境](../../../lycium/README.md#1编译环境准备) + + ```shell + cd lycium + ./build.sh lua + ``` + +- 三方库头文件及生成的库 + + 在lycium目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ```shell + lua/arm64-v8a lua/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +lua最终生成的是lua可执行文件,无需引入测试编译,引用原生库的测试逻辑即可。 + +## 测试三方库 + +- 将busybox推送到开发板 ,具体步骤如下: + + ```sh + hdc_std.exe file send lua /data/ ## 将测试资源推送到板子 + hdc_std.exe shell ## 进入设备系统 + cd /data + chmod a+x lua ## 设置busybox可执行权限 + ``` + +将lua推送开发板后,可以直接运行lua -v指令并可看到其执行结果,如下图所示: + ![lua_test](pic/lua_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) \ No newline at end of file diff --git a/thirdparty/lua/docs/pic/lua_test.png b/thirdparty/lua/docs/pic/lua_test.png new file mode 100644 index 0000000000000000000000000000000000000000..ec4601e4dc92bfe6f453cf9a40727ab4aed97a00 Binary files /dev/null and b/thirdparty/lua/docs/pic/lua_test.png differ