diff --git a/thirdparty/tcl/HPKBUILD b/thirdparty/tcl/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..088974b457812e31aaaebf8cb54f3274e52f68df --- /dev/null +++ b/thirdparty/tcl/HPKBUILD @@ -0,0 +1,70 @@ +# Contributor: wupingyuan +# Maintainer: wupingyuan +pkgname=tcl +pkgver=8.6.13 +pkgrel=0 +pkgdesc="Tool Command Language (Tcl) is an interpreted language and very portable interpreter for that language. Tcl is embeddable and extensible, and has been widely used since its creation in 1988 by John Ousterhout." +url="https://sourceforge.net/projects/tcl/" +archs=("armeabi-v7a" "arm64-v8a") +license=("BSD") +depends=() +makedepends=() +source="https://sourceforge.net/projects/$pkgname/files/Tcl/$pkgver/$pkgname$pkgver-src.tar.gz" + +autounpack=true +downloadpackage=true +buildtools="configure" +builddir=$pkgname$pkgver +packagename=$builddir.src.tar.gz +source envset.sh +host= + +prepare() { + mkdir -p $builddir/$ARCH-build + if [ $ARCH == "armeabi-v7a" ] + then + setarm32ENV + host=arm-linux + fi + if [ $ARCH == "arm64-v8a" ] + then + setarm64ENV + host=aarch64-linux + fi +} + +build() { + cd $builddir/$ARCH-build + ../unix/configure "$@" --host=$host > `pwd`/build.log 2>&1 + make -j4 >> `pwd`/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $builddir/$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 test +} + +cleanbuild(){ + rm -rf ${PWD}/$builddir #${PWD}/$packageName +} diff --git a/thirdparty/tcl/README.OpenSource b/thirdparty/tcl/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..e7ee8cc1af454848965e835112e13752f3349fc0 --- /dev/null +++ b/thirdparty/tcl/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "tcl", + "License": "BSD", + "License File": "license.terms", + "Version Number": "8.6.13", + "Owner": "wupingyuan@huawei.com", + "Upstream URL": "https://sourceforge.net/projects/tcl/files/Tcl/8.6.13/tcl8.6.13-src.tar.gz", + "Description": "Tool Command Language (Tcl) is an interpreted language and very portable interpreter for that language. Tcl is embeddable and extensible, and has been widely used since its creation in 1988 by John Ousterhout." + } +] diff --git a/thirdparty/tcl/README_zh.md b/thirdparty/tcl/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..16c7f36b01e23b1b268a9f281d119ff3937ecd95 --- /dev/null +++ b/thirdparty/tcl/README_zh.md @@ -0,0 +1,12 @@ +# tcl三方库说明 +## 功能简介 +tcl是一种解释语言,也是该语言的一种非常便携的解释器。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Beta2 +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:8.6.13 +- 当前适配的功能:支持tcl解释器 +- [BSD](https://sourceforge.net/projects/tcl/) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/tcl/SHA512SUM b/thirdparty/tcl/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..99844322967785e3dfb2ef4b2cbcb6d4b5326cd5 --- /dev/null +++ b/thirdparty/tcl/SHA512SUM @@ -0,0 +1 @@ +b597f6b62fd71457e96445401a4f8aa662c2678de8a52127c60b0abddebf1fd4452ba5364420902a15b263c0118fc91167550fd1ad2d24fa4ab2204e372c027e tcl8.6.13.src.tar.gz \ No newline at end of file diff --git a/thirdparty/tcl/docs/hap_integrate.md b/thirdparty/tcl/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..4645deeed3038f632f2f268074a3000f9d481c3f --- /dev/null +++ b/thirdparty/tcl/docs/hap_integrate.md @@ -0,0 +1,81 @@ +# tcl集成到应用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/tcl #三方库tcl的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将tcl拷贝至tools/main目录下 + ``` + cd tpc_c_cplusplus + cp thirdparty/tcl tools/main -rf + ``` +- 在tools目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + ``` + cd tools + ./build.sh tcl + ``` +- 三方库头文件及生成的库 + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + ``` + tcl/arm64-v8a tcl/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 拷贝动态库到`\\entry\libs\${OHOS_ARCH}\`目录: + 动态库需要在`\\entry\libs\${OHOS_ARCH}\`目录,才能集成到hap包中,所以需要将对应的so文件拷贝到对应CPU架构的目录 + + ![thirdparty_install_dir](pic/tcl_install_dir_1.jpg) + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + + ![thirdparty_install_dir](pic/tcl_install_dir_2.jpg) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ``` + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/libtcl8.6.so) + target_link_libraries(entry PRIVATE ${CMAKE_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/libsqlite3.40.0.so) + target_link_libraries(entry PRIVATE ${CMAKE_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/libitcl4.2.3.so) + target_link_libraries(entry PRIVATE ${CMAKE_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/libtdbc1.1.5.so) + target_link_libraries(entry PRIVATE ${CMAKE_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/libtdbcmysql1.1.5.so) + target_link_libraries(entry PRIVATE ${CMAKE_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/libtdbcodbc1.1.5.so) + target_link_libraries(entry PRIVATE ${CMAKE_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/libtdbcpostgres1.1.5.so) + target_link_libraries(entry PRIVATE ${CMAKE_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/libthread2.8.8.so) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/tcl/${OHOS_ARCH}/include) + ``` + ![tcl_usage](pic/tcl_usage.jpg) +## 测试三方库 +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +进入到构建目录执行make test-tcl运行测试用例(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录)(备注:需要联网测试,其中unixInit.test和thread.test没过,unixInit.test是因为用例需要匹配查找iso8859-15|utf-8编码,而ohos中查找到的是ascii编码因此没有通过。thread.test是因为pthread_join()接口在多次调用后,threadId在用例中会有重复的现象,ohos的多线程pthread_join()没有做校验处理,导致失败) + + ![tcl_test](pic/tcl_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/tcl/docs/pic/tcl_install_dir_1.jpg b/thirdparty/tcl/docs/pic/tcl_install_dir_1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c96e6b1dd91d649853677efa15a5a6c468c7e92f Binary files /dev/null and b/thirdparty/tcl/docs/pic/tcl_install_dir_1.jpg differ diff --git a/thirdparty/tcl/docs/pic/tcl_install_dir_2.jpg b/thirdparty/tcl/docs/pic/tcl_install_dir_2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5eecf9e91cea23cc354f35e39feb325e5b9ceb33 Binary files /dev/null and b/thirdparty/tcl/docs/pic/tcl_install_dir_2.jpg differ diff --git a/thirdparty/tcl/docs/pic/tcl_test.jpg b/thirdparty/tcl/docs/pic/tcl_test.jpg new file mode 100644 index 0000000000000000000000000000000000000000..cf27327d19e0ff07021fffb9c095aaa34eca5c4d Binary files /dev/null and b/thirdparty/tcl/docs/pic/tcl_test.jpg differ diff --git a/thirdparty/tcl/docs/pic/tcl_usage.jpg b/thirdparty/tcl/docs/pic/tcl_usage.jpg new file mode 100644 index 0000000000000000000000000000000000000000..eb6fa055666a64697b0d7233764655b6a7dfa15b Binary files /dev/null and b/thirdparty/tcl/docs/pic/tcl_usage.jpg differ