diff --git a/thirdparty/unixODBC/HPKBUILD b/thirdparty/unixODBC/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..0cf78558d05cceb3b8c0c12550a042b2cdee8d43 --- /dev/null +++ b/thirdparty/unixODBC/HPKBUILD @@ -0,0 +1,83 @@ +# Contributor: Jeff Han +# Maintainer: Jeff Han +pkgname=unixODBC +pkgver=2.3.11 +pkgrel=0 +pkgdesc="" +url="" +archs=("armeabi-v7a" "arm64-v8a") +license=("LGPL-2.1") +depends=() +makedepends=() + +source="https://github.com/lurcher/$pkgname/releases/download/$pkgver/$pkgname-$pkgver.tar.gz" + +autounpack=true +downloadpackage=true +buildtools="configure" + +builddir=$pkgname-${pkgver} +packagename=$builddir.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 + ../configure "$@" --host=$host --enable-static --disable-shared > `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 + cd $OLDPWD + if [ $ARCH == "armeabi-v7a" ] + then + unsetarm32ENV + fi + if [ $ARCH == "arm64-v8a" ] + then + unsetarm64ENV + fi + unset host +} + +check() { + cd $builddir/$ARCH-build + sed -i '/.*all-am: Makefile $(LTLIBRARIES)/c\all-am: #Makefile $(LTLIBRARIES)' extras/Makefile + sed -i '/.*all-am: Makefile $(LTLIBRARIES)/c\all-am: #Makefile $(LTLIBRARIES)' log/Makefile + sed -i '/.*all-am: Makefile $(LTLIBRARIES)/c\all-am: #Makefile $(LTLIBRARIES)' lst/Makefile + sed -i '/.*all-am: Makefile $(LTLIBRARIES)/c\all-am: #Makefile $(LTLIBRARIES)' ini/Makefile + sed -i '/.*all-am: Makefile $(LTLIBRARIES)/c\all-am: #Makefile $(LTLIBRARIES)' libltdl/Makefile + sed -i '/.*all-am: Makefile $(LTLIBRARIES)/c\all-am: #Makefile $(LTLIBRARIES)' odbcinst/Makefile + sed -i '/.*all-am: Makefile $(LTLIBRARIES)/c\all-am: #Makefile $(LTLIBRARIES)' DriverManager/Makefile + sed -i '/.*all-am: Makefile $(LTLIBRARIES)/c\all-am: #Makefile $(PROGRAMS)' exe/Makefile + sed -i '/.*all-am: Makefile $(LTLIBRARIES)/c\all-am: #Makefile $(LTLIBRARIES)' cur/Makefile + cd $OLDPWD + echo "The test must be on an OpenHarmony device!" + # real test CMD + # make check +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/$builddir #${PWD}/$packagename +} diff --git a/thirdparty/unixODBC/OAT.xml b/thirdparty/unixODBC/OAT.xml new file mode 100644 index 0000000000000000000000000000000000000000..96937ea08644b79312d0ced7c0b3eb1e845108ee --- /dev/null +++ b/thirdparty/unixODBC/OAT.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/thirdparty/unixODBC/README.OpenSource b/thirdparty/unixODBC/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..f5ba12693afa1bc96409216e1391496ac59d5881 --- /dev/null +++ b/thirdparty/unixODBC/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "unixODBC", + "License": "GNU Lesser General Public License v2.1", + "License File": "https://github.com/lurcher/unixODBC/blob/master/LICENSE", + "Version Number": "2.3.11", + "Owner": "sttangc@isoftstone.com", + "Upstream URL": "https://github.com/lurcher/unixODBC/releases/download/2.3.11/unixODBC-2.3.11.tar.gz", + "Description": "The unixODBC Project goals are to develop and promote unixODBC to be the definitive standard for ODBC on non MS Windows platforms." + } +] diff --git a/thirdparty/unixODBC/README_zh.md b/thirdparty/unixODBC/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..11f913a5a09594560911ef65d075d5be0049b591 --- /dev/null +++ b/thirdparty/unixODBC/README_zh.md @@ -0,0 +1,12 @@ +# unixODBC三方库说明 +## 功能简介 +unixODBC项目的目标是开发和推广unixODBC,使其成为非MS Windows平台上ODBC的最终标准。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Beta2 +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:2.3.11 +- 当前适配的功能:unixODBC项目的目标是开发和推广unixODBC,使其成为非MS Windows平台上ODBC的最终标准。 +- [GNU Lesser General Public License v2.1](https://github.com/lurcher/unixODBC/blob/master/LICENSE) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/unixODBC/SHA512SUM b/thirdparty/unixODBC/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..74fee9c98963efd12db0008261719883ec16c5e0 --- /dev/null +++ b/thirdparty/unixODBC/SHA512SUM @@ -0,0 +1 @@ +dddc32f90a7962e6988e1130a8093c6fb8b9ff532cad270d572250324aecbc739f45f9d8021d217313910bab25b08e69009b4f87456575535e93be1f46f5f13d unixODBC-2.3.11.tar.gz diff --git a/thirdparty/unixODBC/docs/hap_integrate.md b/thirdparty/unixODBC/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..28605a95906a2b865b6b10473e5f620e0c9d2543 --- /dev/null +++ b/thirdparty/unixODBC/docs/hap_integrate.md @@ -0,0 +1,70 @@ +# unixODBC集成到应用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/unixODBC #三方库unixODBC的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将unixODBC拷贝至tools/main目录下 + ``` + cd tpc_c_cplusplus + cp thirdparty/unixODBC tools/main -rf + ``` +- 在tools目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + ``` + cd tools + ./build.sh unixODBC + ``` +- 三方库头文件及生成的库 + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + ``` + unixODBC/arm64-v8a unixODBC/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + ![thirdparty_install_dir](pic/unixODBC_install_dir.png) +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ``` + #将三方库加入工程中 + target_link_libraries(entry PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/unixODBC/${OHOS_ARCH}/lib/libodbc.a + ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/unixODBC/${OHOS_ARCH}/lib/libodbccr.a + ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/unixODBC/${OHOS_ARCH}/lib/libodbcinst.a + ) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/unixODBC/${OHOS_ARCH}/include) + ``` + ![unixODBC_usage](pic/unixODBC_usage.png) +## 测试三方库 +三方库的测试使用make check命令来做测试 + +进入到构建目录执行命令make check,运行测试(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) + ![unixODBC_test_result](pic/unixODBC_test_result.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) diff --git a/thirdparty/unixODBC/docs/pic/unixODBC_install_dir.png b/thirdparty/unixODBC/docs/pic/unixODBC_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..46989b5252100b72f6df3d47494cd8d3163732a8 Binary files /dev/null and b/thirdparty/unixODBC/docs/pic/unixODBC_install_dir.png differ diff --git a/thirdparty/unixODBC/docs/pic/unixODBC_test_result.png b/thirdparty/unixODBC/docs/pic/unixODBC_test_result.png new file mode 100644 index 0000000000000000000000000000000000000000..6ae39600cf88b1aa6dbb15ed67c537188ce1ac43 Binary files /dev/null and b/thirdparty/unixODBC/docs/pic/unixODBC_test_result.png differ diff --git a/thirdparty/unixODBC/docs/pic/unixODBC_usage.png b/thirdparty/unixODBC/docs/pic/unixODBC_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..b06fddd623bdcc1b2b7be4f251cece5d931ebe7b Binary files /dev/null and b/thirdparty/unixODBC/docs/pic/unixODBC_usage.png differ