diff --git a/thirdparty/glm/HPKBUILD b/thirdparty/glm/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..eaddfef454f1cccc97e5cf9f5b5038780fd9f762 --- /dev/null +++ b/thirdparty/glm/HPKBUILD @@ -0,0 +1,58 @@ +# Contributor: wupingyuan +# Maintainer: wupingyuan +pkgname=glm +pkgver=0.9.9.8 +pkgrel=0 +pkgdesc="OpenGL Mathematics (GLM) is a header only C++ mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specifications." +url="https://github.com/g-truc/glm" +archs=("armeabi-v7a" "arm64-v8a") +license=("MIT") +depends=() +makedepends=() + +source="https://github.com/g-truc/$pkgname/archive/refs/tags/$pkgver.tar.gz" + +autounpack=true +downloadpackage=true +patchflag=true +builddir=$pkgname-${pkgver} +packagename=$builddir.tar.gz + +prepare() { + mkdir -p $builddir/$ARCH-build + if $patchflag + then + cd $builddir + # 由于编译test用例的时候报错:clang++: : error: argument unused during compilation: '--gcc-toolchain=/home/wu/openharmony/ohos-sdk/linux/native/llvm' [-Werror,-Wunused-command-line-argument]和没有install命令因此打patch + patch -p1 < `pwd`/../glm_oh_pkg.patch + patchflag=false + cd $OLDPWD + fi +} + +build() { + cd $builddir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake "$@" -DOHOS_ARCH=$ARCH -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -B$ARCH-build -S./ -L > `pwd`/$ARCH-build/build.log 2>&1 + make -j4 -C $ARCH-build >> `pwd`/$ARCH-build/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $builddir + make -C $ARCH-build install >> `pwd`/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +check() { + echo "The test must be on an OpenHarmony device!" + # 在OpenHarmony开发板中执行用例 + # ctest +} + +cleanbuild(){ + rm -rf ${PWD}/$builddir #${PWD}/$packagename +} diff --git a/thirdparty/glm/OAT.xml b/thirdparty/glm/OAT.xml new file mode 100644 index 0000000000000000000000000000000000000000..96937ea08644b79312d0ced7c0b3eb1e845108ee --- /dev/null +++ b/thirdparty/glm/OAT.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/thirdparty/glm/README.OpenSource b/thirdparty/glm/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..54defbc7b1759d6641d98c11420a39b60ed52d98 --- /dev/null +++ b/thirdparty/glm/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "glm", + "License": "BSD-3-Clause license", + "License File": "LICENSES", + "Version Number": "0.9.9.8", + "Owner": "qiandinge@isoftstone.com", + "Upstream URL": "https://github.com/g-truc/glm/archive/refs/tags/0.9.9.8.tar.gz", + "Description": "OpenGL Mathematics (GLM)" + } +] \ No newline at end of file diff --git a/thirdparty/glm/README_zh.md b/thirdparty/glm/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..e02a7d8816d1fdff2845a056a95f60ac49bc76ea --- /dev/null +++ b/thirdparty/glm/README_zh.md @@ -0,0 +1,12 @@ +# glm三方库说明 +## 功能简介 +OpenGL Mathematics(GLM)是一个基于OpenGL着色语言(GLSL)规范的图形软件的仅限标题的C++数学库。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Release +- SDK版本:ohos_sdk_public 4.0.8.1 (API Version 10 Release) +- 三方库版本:0.9.9.8 +- 当前适配的功能:OpenGL着色语言(GLSL)规范的图形软件的仅限标题的C++数学库 +- [BSD-3-Clause license](https://github.com/g-truc/glm/blob/0.9.9.8/copying.txt) + +## 集成方式 ++ [应用hap包集成](docs/hap_ingtegrate.md) \ No newline at end of file diff --git a/thirdparty/glm/SHA512SUM b/thirdparty/glm/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..ceb0712a4f24bc0a5ca6846eae3c5e3e4e6c5f08 --- /dev/null +++ b/thirdparty/glm/SHA512SUM @@ -0,0 +1,2 @@ +9484b0c12175414237c5b9486a2990099b1cb727e442f25ecda18b081aa661f7e92a44481f642989553cd3da7992a773441ee5688991bd539ce19fb66a5ce9e8 glm-0.9.9.8.tar.gz +770a4cce940211f601a3571ff87b5b0e51fe6e9cca79d44e4ad1fc9440d63a03719f0acb8f73c01ddb5007738995679133c86c570e29cacdb4484e26a9f48d28 glm_oh_pkg.patch diff --git a/thirdparty/glm/docs/hap_ingtegrate.md b/thirdparty/glm/docs/hap_ingtegrate.md new file mode 100644 index 0000000000000000000000000000000000000000..61f09dd9e367933828fa20220036174eab63fc03 --- /dev/null +++ b/thirdparty/glm/docs/hap_ingtegrate.md @@ -0,0 +1,91 @@ +# glm集成到应用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环境准备) + +## 编译三方库 + +- 下载本仓库 + + ```shell + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 三方库目录结构 + + ```shell + tpc_c_cplusplus/thirdparty/glm #三方库glm的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将glm拷贝至tools/main目录下 + + ```shell + cd tpc_c_cplusplus + cp thirdparty/glm tools/main -rf + ``` + +- 在tools目录下编译三方库 + + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + + ```shell + cd tools + ./build.sh glm + ``` + +- 三方库头文件及生成的库 + + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ```shell + glm/arm64-v8a glm/armeabi-v7a + ``` +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 +   + + ![thirdparty_install_dir](pic/glm_install_dir.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + + ```shell + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glm/${OHOS_ARCH}/lib/libglm_static.a) + + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glm/${OHOS_ARCH}/include) + ``` + + ![glm_usage](pic/glm_usage.png) + +## 测试三方库 + +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +进入到构建目录,执行如下命令ctest(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) + + + ![glm_test](pic/glm_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) diff --git a/thirdparty/glm/docs/pic/glm_install_dir.png b/thirdparty/glm/docs/pic/glm_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..22f41d96a5e4ace9138c406f58c0cdd743cc4674 Binary files /dev/null and b/thirdparty/glm/docs/pic/glm_install_dir.png differ diff --git a/thirdparty/glm/docs/pic/glm_test.png b/thirdparty/glm/docs/pic/glm_test.png new file mode 100644 index 0000000000000000000000000000000000000000..45bd49d6d0770d1c66d1d7343649fe58aee6704b Binary files /dev/null and b/thirdparty/glm/docs/pic/glm_test.png differ diff --git a/thirdparty/glm/docs/pic/glm_usage.png b/thirdparty/glm/docs/pic/glm_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..771ed60bf63f4de0c0719707a176b205176e34c0 Binary files /dev/null and b/thirdparty/glm/docs/pic/glm_usage.png differ diff --git a/thirdparty/glm/glm_oh_pkg.patch b/thirdparty/glm/glm_oh_pkg.patch new file mode 100644 index 0000000000000000000000000000000000000000..635989191b7e552e5fb1f525037d98d01cd9c2a4 --- /dev/null +++ b/thirdparty/glm/glm_oh_pkg.patch @@ -0,0 +1,25 @@ +diff -Naur glm-0.9.9.8/CMakeLists.txt glm-0.9.9.8-patch/CMakeLists.txt +--- glm-0.9.9.8/CMakeLists.txt 2023-06-08 14:03:36.843252172 +0800 ++++ glm-0.9.9.8-patch/CMakeLists.txt 2023-06-08 14:50:28.914399961 +0800 +@@ -12,4 +12,9 @@ + + add_subdirectory(test) + ++install(DIRECTORY glm DESTINATION include ++ FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h") ++install(FILES ${OHOS_ARCH}-build/glm/libglm_shared.so DESTINATION lib) ++install(FILES ${OHOS_ARCH}-build/glm/libglm_static.a DESTINATION lib) ++ + endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) +diff -Naur glm-0.9.9.8/test/CMakeLists.txt glm-0.9.9.8-patch/test/CMakeLists.txt +--- glm-0.9.9.8/test/CMakeLists.txt 2023-06-08 14:03:36.895253483 +0800 ++++ glm-0.9.9.8-patch/test/CMakeLists.txt 2023-06-08 14:06:50.772482956 +0800 +@@ -197,7 +197,7 @@ + message("GLM: Clang - ${CMAKE_CXX_COMPILER_ID} compiler") + endif() + +- add_compile_options(-Werror -Weverything) ++ #add_compile_options(-Werror -Weverything) + add_compile_options(-Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-c++11-long-long -Wno-padded -Wno-gnu-anonymous-struct -Wno-nested-anon-types) + add_compile_options(-Wno-undefined-reinterpret-cast -Wno-sign-conversion -Wno-unused-variable -Wno-missing-prototypes -Wno-unreachable-code -Wno-missing-variable-declarations -Wno-sign-compare -Wno-global-constructors -Wno-unused-macros -Wno-format-nonliteral) +