diff --git a/README_zh.md b/README_zh.md index 192da1ee93f320681110865de6c73f486a51f8f0..6ca93132913df312089cf7c735a5070f5153793e 100755 --- a/README_zh.md +++ b/README_zh.md @@ -1,7 +1,7 @@ # tpc_c_cplusplus ## 简介 -本仓库主要用于存放已经适配OpenHarmony的C/C++三方库的适配脚本,三方库的适配/使用指导;每个三方库目录下包含了GN化的适配指导、编译脚本和包含了cmake的适配指导、编译脚本。 +本仓库主要用于存放已经适配OpenHarmony的C/C++三方库的适配脚本和OpenHarmony三方库适配指导文档、三方库适配相关的工具。 @@ -10,22 +10,9 @@ ``` tpc_c_cplusplus ├── README_zh.md #仓库主页 -├── common #仓库通用说明文档的文件夹 -├── thirdparty_template #三方库模板文件夹 -│ ├──README_zh.md #三方库简介 -│ ├──README.OpenSource #说明三方库源码的下载地址,版本,license等信息 -│ ├──ohos.build #三方库组件定义文件 -│ ├──CMakeLists.txt #构建脚本,支持hap包集成 -│ ├──BUILD.gn #构建脚本,支持rom包集成 -│ ├──adapted #该目录存放三方库适配需要的代码文件 -│ │ ├──config.h #例如配置文件 -│ │ ├──... #其他适配文件 -│ ├──docs #存放三方库相关文档的文件夹 -│ │ ├──rom_integrate.md #rom集成说明文档 -│ │ ├──hap_integrate.md #hap集成说明文档 -│ │ ├── ... #其他说明文档 -├── thirdparty1 #三方库文件夹,内容和thirdparty_template模板的格式一样 -├── thirdparty2 #三方库文件夹,内容和thirdparty_template模板的格式一样 +├── docs #说明文档/三方库适配文档 +├── tools #三方库适配相关工具 +├── thirdparty #已经适配OpenHarmony的三方库的构建脚本 ...... ``` @@ -35,8 +22,10 @@ tpc_c_cplusplus - [遵守仓库目录结构](#本仓库目录) - [遵守OpenHarmony编码贡献规范](https://gitee.com/openharmony-sig/knowledge_demo_smart_home/blob/master/dev/docs/contribute/README.md) -- [三方库模板目录](thirdparty_template) +- [贡献三方库](thirdparty/README_zh.md) ## 三方库列表 + +- [C/C++三方库列表](docs/thirdparty_list.md) diff --git a/docs/thirdparty_list.md b/docs/thirdparty_list.md new file mode 100755 index 0000000000000000000000000000000000000000..9b5e4e1e017fea7a22d639f2137a2c6050fed8e8 --- /dev/null +++ b/docs/thirdparty_list.md @@ -0,0 +1,24 @@ +# 三方库列表 + +| 三方库名称 | 开源协议 | 南向 | 北向 | +| ------------------------------------------------------------ | --------------------------- | ---- | ---- | +| [xerces-c](../thirdparty/xerces-c/README_zh.md) | Apache License 2.0 | 是 | 是 | +| [modbus](../thirdparty/modbus/README_zh.md) | LGPL v2.1 or Later | 是 | | +| [tinyxpath](../thirdparty/tinyxpath/README_zh.md) | zlib/libpng License | | 是 | +| [bsdiff](../thirdparty/bsdiff/README_zh.md) | BSD 2-clause license | 是 | | +| [concurrentqueue](../thirdparty/concurrentqueue/README_zh.md) | BSD License | 是 | 是 | +| [iconv](../thirdparty/iconv/README_zh.md) | LGPLv3.0 | 是 | | +| [jbig2enc](../thirdparty/jbig2enc/README_zh.md) | Apache License | 是 | | +| [leptonica](../thirdparty/leptonica/README_zh.md) | leptonica-license | 是 | | +| [libmp3lame](../thirdparty/libmp3lame/README_zh.md) | LGPL | 是 | | +| [libtiff](../thirdparty/libtiff/README_zh.md) | libtiff License | 是 | | +| [lzma](../thirdparty/lzma/README_zh.md) | GNU LGPLv2+ | 是 | | +| [minizip-ng](../thirdparty/minizip-ng/README_zh.md) | zlib License | 是 | 是 | +| [mqtt](../thirdparty/mqtt/README_zh.md) | Eclipse Public License v2.0 | 是 | | +| [openjpeg](../thirdparty/openjpeg/README_zh.md) | 2-clauses BSD license | 是 | | +| [rapidjson](../thirdparty/rapidjson/README_zh.md) | MIT license | 是 | | +| [tinyxml2](../thirdparty/tinyxml2/README_zh.md) | zlib license | 是 | 是 | +| [unrar](../thirdparty/unrar/README_zh.md) | Apache License 2.0 | | 是 | +| [xz](../thirdparty/xz/README_zh.md) | GPLv2 | 是 | | +| [zstd](../thirdparty/zstd/README_zh.md) | BSD and GPLv2 | 是 | | + diff --git a/thirdparty/README_zh.md b/thirdparty/README_zh.md new file mode 100755 index 0000000000000000000000000000000000000000..a046dcb7374823d83c97db224513653ce5ef1f86 --- /dev/null +++ b/thirdparty/README_zh.md @@ -0,0 +1,33 @@ +## 目录结构 + +``` +tpc_c_cplusplus/thirdparty +├── README_zh.md #仓库主页 +├── common #仓库通用说明文档的文件夹 +├── thirdparty_template #三方库模板文件夹 +│ ├──README_zh.md #三方库简介 +│ ├──README.OpenSource #说明三方库源码的下载地址,版本,license等信息 +│ ├──bundle.json #三方库组件定义文件 +│ ├──CMakeLists.txt #构建脚本,支持hap包集成 +│ ├──HPKBUILD #交叉构建脚本,使用原库自带脚本编译,支持hap包集成 +│ ├──SHA512SUM #压缩包校验文件,和HPKBUILD一起使用 +│ ├──BUILD.gn #构建脚本,支持rom包集成 +│ ├──adapted #该目录存放三方库适配需要的代码文件 +│ │ ├──config.h #例如配置文件 +│ │ ├──... #其他适配文件 +│ ├──docs #存放三方库相关文档的文件夹 +│ │ ├──rom_integrate.md #rom集成说明文档 +│ │ ├──hap_integrate.md #hap集成说明文档 +│ │ ├── ... #其他说明文档 +├── thirdparty1 #三方库文件夹,内容和thirdparty_template模板的格式一样 +├── thirdparty2 #三方库文件夹,内容和thirdparty_template模板的格式一样 +...... +``` + + + +## 如何贡献 + +- [遵守仓库目录结构](#本仓库目录) +- [遵守OpenHarmony编码贡献规范](https://gitee.com/openharmony-sig/knowledge_demo_smart_home/blob/master/dev/docs/contribute/README.md) +- [三方库模板目录](thirdparty_template) diff --git a/bsdiff/BUILD.gn b/thirdparty/bsdiff/BUILD.gn similarity index 100% rename from bsdiff/BUILD.gn rename to thirdparty/bsdiff/BUILD.gn diff --git a/bsdiff/README.OpenSource b/thirdparty/bsdiff/README.OpenSource similarity index 100% rename from bsdiff/README.OpenSource rename to thirdparty/bsdiff/README.OpenSource diff --git a/bsdiff/README_zh.md b/thirdparty/bsdiff/README_zh.md similarity index 100% rename from bsdiff/README_zh.md rename to thirdparty/bsdiff/README_zh.md diff --git a/bsdiff/bundle.json b/thirdparty/bsdiff/bundle.json similarity index 100% rename from bsdiff/bundle.json rename to thirdparty/bsdiff/bundle.json diff --git a/bsdiff/docs/rom_integrate.md b/thirdparty/bsdiff/docs/rom_integrate.md similarity index 95% rename from bsdiff/docs/rom_integrate.md rename to thirdparty/bsdiff/docs/rom_integrate.md index 41adb5581764f1cc31bf7978c90f97ea4119646d..1684dc12b70ecba28934ea46502bdc5c0292d9d2 100755 --- a/bsdiff/docs/rom_integrate.md +++ b/thirdparty/bsdiff/docs/rom_integrate.md @@ -21,7 +21,7 @@ RK3568开发板如何使用可以参照[润和RK3568开发板标准系统快速 - 仓库代码目录结构说明 ```shell - cd ~/tpc_c_cplusplus/bsdiff/ ## 进入到仓库代码库目录 + cd ~/tpc_c_cplusplus/thirdparty/bsdiff/ ## 进入到仓库代码库目录 ``` ```sh @@ -43,7 +43,7 @@ RK3568开发板如何使用可以参照[润和RK3568开发板标准系统快速 - 将本仓库bsdiff文件夹拷贝到OpenHarmony的third_party下 ```shell - cp -arf ~/tpc_c_cplusplus/bsdiff ~/OpenHarmony/third_party + cp -arf ~/tpc_c_cplusplus/thirdparty/bsdiff ~/OpenHarmony/third_party ``` ### 准备三方库源码 diff --git a/bsdiff/export_api.txt b/thirdparty/bsdiff/export_api.txt similarity index 100% rename from bsdiff/export_api.txt rename to thirdparty/bsdiff/export_api.txt diff --git a/bsdiff/media/ohos_result.png b/thirdparty/bsdiff/media/ohos_result.png similarity index 100% rename from bsdiff/media/ohos_result.png rename to thirdparty/bsdiff/media/ohos_result.png diff --git a/bsdiff/testdata/note.txt b/thirdparty/bsdiff/testdata/note.txt similarity index 100% rename from bsdiff/testdata/note.txt rename to thirdparty/bsdiff/testdata/note.txt diff --git a/bsdiff/testdata/note_new.txt b/thirdparty/bsdiff/testdata/note_new.txt similarity index 100% rename from bsdiff/testdata/note_new.txt rename to thirdparty/bsdiff/testdata/note_new.txt diff --git a/bsdiff/testdata/run_test.sh b/thirdparty/bsdiff/testdata/run_test.sh similarity index 100% rename from bsdiff/testdata/run_test.sh rename to thirdparty/bsdiff/testdata/run_test.sh diff --git a/bsdiff/tested_api.txt b/thirdparty/bsdiff/tested_api.txt similarity index 100% rename from bsdiff/tested_api.txt rename to thirdparty/bsdiff/tested_api.txt diff --git a/concurrentqueue/BUILD.gn b/thirdparty/concurrentqueue/BUILD.gn similarity index 100% rename from concurrentqueue/BUILD.gn rename to thirdparty/concurrentqueue/BUILD.gn diff --git a/concurrentqueue/CHANGELOG.md b/thirdparty/concurrentqueue/CHANGELOG.md similarity index 100% rename from concurrentqueue/CHANGELOG.md rename to thirdparty/concurrentqueue/CHANGELOG.md diff --git a/concurrentqueue/CMakeLists.txt b/thirdparty/concurrentqueue/CMakeLists.txt similarity index 100% rename from concurrentqueue/CMakeLists.txt rename to thirdparty/concurrentqueue/CMakeLists.txt diff --git a/concurrentqueue/README.OpenSource b/thirdparty/concurrentqueue/README.OpenSource similarity index 100% rename from concurrentqueue/README.OpenSource rename to thirdparty/concurrentqueue/README.OpenSource diff --git a/concurrentqueue/README_zh.md b/thirdparty/concurrentqueue/README_zh.md similarity index 100% rename from concurrentqueue/README_zh.md rename to thirdparty/concurrentqueue/README_zh.md diff --git a/concurrentqueue/bundle.json b/thirdparty/concurrentqueue/bundle.json similarity index 100% rename from concurrentqueue/bundle.json rename to thirdparty/concurrentqueue/bundle.json diff --git a/concurrentqueue/docs/hap_integrate.md b/thirdparty/concurrentqueue/docs/hap_integrate.md similarity index 96% rename from concurrentqueue/docs/hap_integrate.md rename to thirdparty/concurrentqueue/docs/hap_integrate.md index 6cf2db88bb141b6a3c29670fa928dc68c04e9295..ba148488e3fa95aca662f3c551e12e7941a62452 100644 --- a/concurrentqueue/docs/hap_integrate.md +++ b/thirdparty/concurrentqueue/docs/hap_integrate.md @@ -7,7 +7,7 @@ - 下载本仓库,并解压 - 三方库目录结构 ``` - tpc_c_cplusplus/concurrentqueue #三方库concurrentqueue的目录结构如下 + tpc_c_cplusplus/thirdparty/concurrentqueue #三方库concurrentqueue的目录结构如下 ├── docs #存放三方库相关文档的文件夹 ├── CmakeLists.txt #构建脚本,支持hap包集成 ├── bundle.json #三方库组件定义文件 diff --git a/concurrentqueue/docs/pic/hap.jpeg b/thirdparty/concurrentqueue/docs/pic/hap.jpeg similarity index 100% rename from concurrentqueue/docs/pic/hap.jpeg rename to thirdparty/concurrentqueue/docs/pic/hap.jpeg diff --git a/concurrentqueue/docs/pic/result.PNG b/thirdparty/concurrentqueue/docs/pic/result.PNG similarity index 100% rename from concurrentqueue/docs/pic/result.PNG rename to thirdparty/concurrentqueue/docs/pic/result.PNG diff --git a/concurrentqueue/docs/rom_integrate.md b/thirdparty/concurrentqueue/docs/rom_integrate.md similarity index 96% rename from concurrentqueue/docs/rom_integrate.md rename to thirdparty/concurrentqueue/docs/rom_integrate.md index 7a5f15fddeec23ec1f56c0fd676f011c44757259..2751e951707ca51b385af727260cbe6e83a9b46c 100644 --- a/concurrentqueue/docs/rom_integrate.md +++ b/thirdparty/concurrentqueue/docs/rom_integrate.md @@ -11,7 +11,7 @@ ``` - 三方库目录结构 ``` - tpc_c_cplusplus/concurrentqueue #三方库concurrentqueue的目录结构如下 + tpc_c_cplusplus/thirdparty/concurrentqueue #三方库concurrentqueue的目录结构如下 ├── docs #存放三方库相关文档的文件夹 ├── BUILD.gn #构建脚本,支持rom包集成 ├── bundle.json #三方库组件定义文件 @@ -20,7 +20,7 @@ ``` - 将三方库拷贝到OpenHarmony源码的third_party目录下 ``` - cp ~/tpc_c_cplusplus/concurrentqueue ~/openharmony/third_party -rf + cp ~/tpc_c_cplusplus/thirdparty/concurrentqueue ~/openharmony/third_party -rf ``` ### 准备三方库源码 ``` diff --git a/iconv/BUILD.gn b/thirdparty/iconv/BUILD.gn similarity index 100% rename from iconv/BUILD.gn rename to thirdparty/iconv/BUILD.gn diff --git a/iconv/Makefile b/thirdparty/iconv/Makefile similarity index 100% rename from iconv/Makefile rename to thirdparty/iconv/Makefile diff --git a/iconv/README.OpenSource b/thirdparty/iconv/README.OpenSource similarity index 100% rename from iconv/README.OpenSource rename to thirdparty/iconv/README.OpenSource diff --git a/iconv/README_zh.md b/thirdparty/iconv/README_zh.md similarity index 100% rename from iconv/README_zh.md rename to thirdparty/iconv/README_zh.md diff --git a/iconv/adapter/include/config.h b/thirdparty/iconv/adapter/include/config.h similarity index 100% rename from iconv/adapter/include/config.h rename to thirdparty/iconv/adapter/include/config.h diff --git a/iconv/adapter/include/iconv.h b/thirdparty/iconv/adapter/include/iconv.h similarity index 100% rename from iconv/adapter/include/iconv.h rename to thirdparty/iconv/adapter/include/iconv.h diff --git a/iconv/adapter/include/libcharset.h b/thirdparty/iconv/adapter/include/libcharset.h similarity index 100% rename from iconv/adapter/include/libcharset.h rename to thirdparty/iconv/adapter/include/libcharset.h diff --git a/iconv/adapter/include/localcharset.h b/thirdparty/iconv/adapter/include/localcharset.h similarity index 100% rename from iconv/adapter/include/localcharset.h rename to thirdparty/iconv/adapter/include/localcharset.h diff --git a/iconv/bundle.json b/thirdparty/iconv/bundle.json similarity index 100% rename from iconv/bundle.json rename to thirdparty/iconv/bundle.json diff --git a/iconv/docs/rom_integrate.md b/thirdparty/iconv/docs/rom_integrate.md similarity index 95% rename from iconv/docs/rom_integrate.md rename to thirdparty/iconv/docs/rom_integrate.md index 14b552ef6a4198c1bffabe827577a6df0603e96c..e195c5a2633c6924a51a74ea1093eec517487615 100755 --- a/iconv/docs/rom_integrate.md +++ b/thirdparty/iconv/docs/rom_integrate.md @@ -12,7 +12,7 @@ RK3568开发板如何使用可以参照[润和RK3568开发板标准系统快速 ``` - 仓库代码目录结构说明 ```shell - cd ~/tpc_c_cplusplus/iconv/ # 进入到仓库代码库目录 + cd ~/tpc_c_cplusplus/thirdparty/iconv/ # 进入到仓库代码库目录 ``` ```sh iconv @@ -35,7 +35,7 @@ RK3568开发板如何使用可以参照[润和RK3568开发板标准系统快速 ``` - 将本仓库iconv文件夹拷贝到OpenHarmony的third_party下 ```shell - cp -arf ~/tpc_c_cplusplus/iconv ~/OpenHarmony/third_party + cp -arf ~/tpc_c_cplusplus/thirdparty/iconv ~/OpenHarmony/third_party ``` ### 准备三方库源码 + 将源码下载到iconv目录并将其解压出来。 diff --git a/iconv/gen_test_file.sh b/thirdparty/iconv/gen_test_file.sh similarity index 100% rename from iconv/gen_test_file.sh rename to thirdparty/iconv/gen_test_file.sh diff --git a/iconv/media/GBK.png b/thirdparty/iconv/media/GBK.png similarity index 100% rename from iconv/media/GBK.png rename to thirdparty/iconv/media/GBK.png diff --git a/iconv/media/GBK_2_UTF8.png b/thirdparty/iconv/media/GBK_2_UTF8.png similarity index 100% rename from iconv/media/GBK_2_UTF8.png rename to thirdparty/iconv/media/GBK_2_UTF8.png diff --git a/iconv/media/UTF-8.png b/thirdparty/iconv/media/UTF-8.png similarity index 100% rename from iconv/media/UTF-8.png rename to thirdparty/iconv/media/UTF-8.png diff --git a/iconv/media/UTF8_2_GBK.png b/thirdparty/iconv/media/UTF8_2_GBK.png similarity index 100% rename from iconv/media/UTF8_2_GBK.png rename to thirdparty/iconv/media/UTF8_2_GBK.png diff --git a/iconv/media/cmp_GBK.png b/thirdparty/iconv/media/cmp_GBK.png similarity index 100% rename from iconv/media/cmp_GBK.png rename to thirdparty/iconv/media/cmp_GBK.png diff --git a/iconv/media/cmp_UTF8.png b/thirdparty/iconv/media/cmp_UTF8.png similarity index 100% rename from iconv/media/cmp_UTF8.png rename to thirdparty/iconv/media/cmp_UTF8.png diff --git a/iconv/test_GBK.txt b/thirdparty/iconv/test_GBK.txt similarity index 100% rename from iconv/test_GBK.txt rename to thirdparty/iconv/test_GBK.txt diff --git a/iconv/test_UTF8.txt b/thirdparty/iconv/test_UTF8.txt similarity index 100% rename from iconv/test_UTF8.txt rename to thirdparty/iconv/test_UTF8.txt diff --git a/jbig2enc/BUILD.gn b/thirdparty/jbig2enc/BUILD.gn similarity index 100% rename from jbig2enc/BUILD.gn rename to thirdparty/jbig2enc/BUILD.gn diff --git a/jbig2enc/README.OpenSource b/thirdparty/jbig2enc/README.OpenSource similarity index 100% rename from jbig2enc/README.OpenSource rename to thirdparty/jbig2enc/README.OpenSource diff --git a/jbig2enc/README_zh.md b/thirdparty/jbig2enc/README_zh.md similarity index 95% rename from jbig2enc/README_zh.md rename to thirdparty/jbig2enc/README_zh.md index 14c8f12678bbb5d708c31fcfa3714ec0a8bb8dcf..e3938fed0706bc759833e35492bb92430ba75cb3 100755 --- a/jbig2enc/README_zh.md +++ b/thirdparty/jbig2enc/README_zh.md @@ -14,4 +14,3 @@ jbig2enc是 JBIG2文件的编码器。 ## 集成方式 - [系统Rom包集成](./docs/rom_integrate.md) - diff --git a/jbig2enc/adapted/init_includes.sh b/thirdparty/jbig2enc/adapted/init_includes.sh similarity index 100% rename from jbig2enc/adapted/init_includes.sh rename to thirdparty/jbig2enc/adapted/init_includes.sh diff --git a/jbig2enc/bundle.json b/thirdparty/jbig2enc/bundle.json similarity index 100% rename from jbig2enc/bundle.json rename to thirdparty/jbig2enc/bundle.json diff --git a/jbig2enc/docs/pic/result.png b/thirdparty/jbig2enc/docs/pic/result.png similarity index 100% rename from jbig2enc/docs/pic/result.png rename to thirdparty/jbig2enc/docs/pic/result.png diff --git a/jbig2enc/docs/rom_integrate.md b/thirdparty/jbig2enc/docs/rom_integrate.md similarity index 95% rename from jbig2enc/docs/rom_integrate.md rename to thirdparty/jbig2enc/docs/rom_integrate.md index 99d0cf49969e8e61216c461fe848a28fb3728033..ae55c926af3b791a656a75301166c3e7007d2f80 100755 --- a/jbig2enc/docs/rom_integrate.md +++ b/thirdparty/jbig2enc/docs/rom_integrate.md @@ -11,7 +11,7 @@ ``` - 三方库目录结构 ``` - tpc_c_cplusplus/jbig2enc #三方库jbig2enc的目录结构如下 + tpc_c_cplusplus/thirdparty/jbig2enc #三方库jbig2enc的目录结构如下 ├── adapted #存放三方库适配需要的代码文件 ├── docs #存放三方库相关文档的文件夹 ├── BUILD.gn #构建脚本,支持rom包集成 @@ -21,7 +21,7 @@ ``` - 将三方库拷贝到OpenHarmony源码的third_party目录下 ``` - cp ~/tpc_c_cplusplus/jbig2enc ~/openharmony/third_party -rf + cp ~/tpc_c_cplusplus/thirdparty/jbig2enc ~/openharmony/third_party -rf ``` ### 准备三方库源码 diff --git a/leptonica/BUILD.gn b/thirdparty/leptonica/BUILD.gn similarity index 100% rename from leptonica/BUILD.gn rename to thirdparty/leptonica/BUILD.gn diff --git a/leptonica/README.OpenSource b/thirdparty/leptonica/README.OpenSource similarity index 100% rename from leptonica/README.OpenSource rename to thirdparty/leptonica/README.OpenSource diff --git a/leptonica/README_zh.md b/thirdparty/leptonica/README_zh.md similarity index 100% rename from leptonica/README_zh.md rename to thirdparty/leptonica/README_zh.md diff --git a/leptonica/adapted/config_auto.h b/thirdparty/leptonica/adapted/config_auto.h similarity index 100% rename from leptonica/adapted/config_auto.h rename to thirdparty/leptonica/adapted/config_auto.h diff --git a/leptonica/adapted/endianness.h b/thirdparty/leptonica/adapted/endianness.h similarity index 100% rename from leptonica/adapted/endianness.h rename to thirdparty/leptonica/adapted/endianness.h diff --git a/leptonica/bundle.json b/thirdparty/leptonica/bundle.json similarity index 100% rename from leptonica/bundle.json rename to thirdparty/leptonica/bundle.json diff --git a/leptonica/docs/pic/color_lifting.png b/thirdparty/leptonica/docs/pic/color_lifting.png similarity index 100% rename from leptonica/docs/pic/color_lifting.png rename to thirdparty/leptonica/docs/pic/color_lifting.png diff --git a/leptonica/docs/pic/generate_pdf.png b/thirdparty/leptonica/docs/pic/generate_pdf.png similarity index 100% rename from leptonica/docs/pic/generate_pdf.png rename to thirdparty/leptonica/docs/pic/generate_pdf.png diff --git a/leptonica/docs/pic/run_adaptmap_dark.png b/thirdparty/leptonica/docs/pic/run_adaptmap_dark.png similarity index 100% rename from leptonica/docs/pic/run_adaptmap_dark.png rename to thirdparty/leptonica/docs/pic/run_adaptmap_dark.png diff --git a/leptonica/docs/rom_integrate.md b/thirdparty/leptonica/docs/rom_integrate.md similarity index 94% rename from leptonica/docs/rom_integrate.md rename to thirdparty/leptonica/docs/rom_integrate.md index bf940e18835f56b8f3a0f1ddb79ad4427d64da76..c6317d52e05a900f43518fc5003e0418c2778aca 100644 --- a/leptonica/docs/rom_integrate.md +++ b/thirdparty/leptonica/docs/rom_integrate.md @@ -20,7 +20,7 @@ - 仓库代码目录结构说明 ```shell - tpc_c_cplusplus/leptonica + tpc_c_cplusplus/thirdparty/leptonica |-- docs # 存放三方库相关文档的文件夹 |-- adapted # 存放三方库适配需要的代码文件 |-- BUILD.gn # 构建脚本,支持rom包集成 @@ -32,7 +32,7 @@ - 将本仓库文件夹拷贝到third_party下 ```shell - cp ~/tpc_c_cplusplus/leptonica ~/openharmony/third_party/ -rf + cp ~/tpc_c_cplusplus/thirdparty/leptonica ~/openharmony/third_party/ -rf ``` ## 准备三方库依赖的四方库 @@ -40,8 +40,8 @@ 本三方库依赖了libgif, libjpg, libpng, openjpeg, zlib, libtiff, libwebp等四方库,除了openjpeg与libtiff外,其他四方库OpenHarmony都已支持。 openjpeg与libtiff的适配参考以下方法: -- [openjpeg的适配](https://gitee.com/openharmony-sig/tpc_c_cplusplus/openjpeg) -- [libtiff的适配](https://gitee.com/openharmony-sig/tpc_c_cplusplus/libtiff) +- [openjpeg的适配](https://gitee.com/openharmony-sig/tpc_c_cplusplus/thirdparty/openjpeg) +- [libtiff的适配](https://gitee.com/openharmony-sig/tpc_c_cplusplus/thirdparty/libtiff) ## 准备三方库源码 @@ -161,5 +161,4 @@ openjpeg与libtiff的适配参考以下方法: - [标准系统编译构建指导](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Beta1/zh-cn/device-dev/subsystems/subsys-build-standard-large.md) - [如何为三方库组件中添加一个三方库](https://gitee.com/openharmony-sig/knowledge/blob/master/docs/openharmony_getstarted/port_thirdparty/README.md) - [OpenHarmony三方库地址](https://gitee.com/openharmony-tpc) -- [OpenHarmony知识体系](https://gitee.com/openharmony-sig/knowledge) - \ No newline at end of file +- [OpenHarmony知识体系](https://gitee.com/openharmony-sig/knowledge) \ No newline at end of file diff --git a/libmp3lame/BUILD.gn b/thirdparty/libmp3lame/BUILD.gn similarity index 100% rename from libmp3lame/BUILD.gn rename to thirdparty/libmp3lame/BUILD.gn diff --git a/libmp3lame/CHANGELOG.md b/thirdparty/libmp3lame/CHANGELOG.md similarity index 100% rename from libmp3lame/CHANGELOG.md rename to thirdparty/libmp3lame/CHANGELOG.md diff --git a/libmp3lame/README.OpenSource b/thirdparty/libmp3lame/README.OpenSource similarity index 100% rename from libmp3lame/README.OpenSource rename to thirdparty/libmp3lame/README.OpenSource diff --git a/libmp3lame/README_zh.md b/thirdparty/libmp3lame/README_zh.md similarity index 100% rename from libmp3lame/README_zh.md rename to thirdparty/libmp3lame/README_zh.md diff --git a/libmp3lame/adapted/config.h b/thirdparty/libmp3lame/adapted/config.h similarity index 100% rename from libmp3lame/adapted/config.h rename to thirdparty/libmp3lame/adapted/config.h diff --git a/libmp3lame/bundle.json b/thirdparty/libmp3lame/bundle.json similarity index 100% rename from libmp3lame/bundle.json rename to thirdparty/libmp3lame/bundle.json diff --git a/libmp3lame/docs/image/result.png b/thirdparty/libmp3lame/docs/image/result.png similarity index 100% rename from libmp3lame/docs/image/result.png rename to thirdparty/libmp3lame/docs/image/result.png diff --git a/libmp3lame/docs/rom_integrate.md b/thirdparty/libmp3lame/docs/rom_integrate.md similarity index 97% rename from libmp3lame/docs/rom_integrate.md rename to thirdparty/libmp3lame/docs/rom_integrate.md index 013c5d420f9beebc19c11695a52ac8a193813b79..0df5784d895b1e83ab4ce6f2da17c9a87cfeec9b 100644 --- a/libmp3lame/docs/rom_integrate.md +++ b/thirdparty/libmp3lame/docs/rom_integrate.md @@ -20,7 +20,7 @@ - 三方库目录结构 ``` - tpc_c_cplusplus/libmp3lame #三方库libmp3lame的目录结构如下 + tpc_c_cplusplus/thirdparty/libmp3lame #三方库libmp3lame的目录结构如下 ├── adapted #存放三方库适配需要的代码文件 ├── docs #存放三方库相关文档的文件夹 ├── BUILD.gn #构建脚本,支持rom包集成 @@ -32,7 +32,7 @@ - 将三方库拷贝到OpenHarmony源码的third_party目录下 ``` - cp ~/tpc_c_cplusplus/libmp3lame ~/openharmony/third_party -rf + cp ~/tpc_c_cplusplus/thirdparty/libmp3lame ~/openharmony/third_party -rf ``` ### 准备三方库源码 diff --git a/libtiff/BUILD.gn b/thirdparty/libtiff/BUILD.gn similarity index 100% rename from libtiff/BUILD.gn rename to thirdparty/libtiff/BUILD.gn diff --git a/libtiff/README.OpenSource b/thirdparty/libtiff/README.OpenSource similarity index 100% rename from libtiff/README.OpenSource rename to thirdparty/libtiff/README.OpenSource diff --git a/libtiff/README_zh.md b/thirdparty/libtiff/README_zh.md similarity index 100% rename from libtiff/README_zh.md rename to thirdparty/libtiff/README_zh.md diff --git a/libtiff/adapted/libport_config.h b/thirdparty/libtiff/adapted/libport_config.h similarity index 100% rename from libtiff/adapted/libport_config.h rename to thirdparty/libtiff/adapted/libport_config.h diff --git a/libtiff/adapted/tif_config.h b/thirdparty/libtiff/adapted/tif_config.h similarity index 100% rename from libtiff/adapted/tif_config.h rename to thirdparty/libtiff/adapted/tif_config.h diff --git a/libtiff/adapted/tiffconf.h b/thirdparty/libtiff/adapted/tiffconf.h similarity index 100% rename from libtiff/adapted/tiffconf.h rename to thirdparty/libtiff/adapted/tiffconf.h diff --git a/libtiff/bundle.json b/thirdparty/libtiff/bundle.json similarity index 100% rename from libtiff/bundle.json rename to thirdparty/libtiff/bundle.json diff --git a/libtiff/docs/pic/result.png b/thirdparty/libtiff/docs/pic/result.png similarity index 100% rename from libtiff/docs/pic/result.png rename to thirdparty/libtiff/docs/pic/result.png diff --git a/libtiff/docs/rom_integrate.md b/thirdparty/libtiff/docs/rom_integrate.md similarity index 95% rename from libtiff/docs/rom_integrate.md rename to thirdparty/libtiff/docs/rom_integrate.md index 22510b1704ef2207f15edea9defdb4183a261605..3dad4f311edb14038c6f49619b794649b02fb903 100755 --- a/libtiff/docs/rom_integrate.md +++ b/thirdparty/libtiff/docs/rom_integrate.md @@ -11,7 +11,7 @@ ``` - 三方库目录结构 ``` - tpc_c_cplusplus/libtiff #三方库xerces-c的目录结构如下 + tpc_c_cplusplus/thirdparty/libtiff #三方库xerces-c的目录结构如下 ├── adapted #存放三方库适配需要的代码文件 ├── docs #存放三方库相关文档的文件夹 ├── BUILD.gn #构建脚本,支持rom包集成 @@ -21,7 +21,7 @@ ``` - 将三方库拷贝到OpenHarmony源码的third_party目录下 ``` - cp ~/tpc_c_cplusplus/libtiff ~/openharmony/third_party -rf + cp ~/tpc_c_cplusplus/thirdparty/libtiff ~/openharmony/third_party -rf ``` ### 准备三方库源码 ``` diff --git a/lzma/BUILD.gn b/thirdparty/lzma/BUILD.gn similarity index 100% rename from lzma/BUILD.gn rename to thirdparty/lzma/BUILD.gn diff --git a/lzma/README.OpenSource b/thirdparty/lzma/README.OpenSource similarity index 100% rename from lzma/README.OpenSource rename to thirdparty/lzma/README.OpenSource diff --git a/lzma/README_zh.md b/thirdparty/lzma/README_zh.md similarity index 100% rename from lzma/README_zh.md rename to thirdparty/lzma/README_zh.md diff --git a/lzma/adapted/config.h b/thirdparty/lzma/adapted/config.h similarity index 100% rename from lzma/adapted/config.h rename to thirdparty/lzma/adapted/config.h diff --git a/lzma/bundle.json b/thirdparty/lzma/bundle.json similarity index 100% rename from lzma/bundle.json rename to thirdparty/lzma/bundle.json diff --git a/lzma/docs/pic/results.png b/thirdparty/lzma/docs/pic/results.png similarity index 100% rename from lzma/docs/pic/results.png rename to thirdparty/lzma/docs/pic/results.png diff --git a/lzma/docs/rom_integrate.md b/thirdparty/lzma/docs/rom_integrate.md similarity index 98% rename from lzma/docs/rom_integrate.md rename to thirdparty/lzma/docs/rom_integrate.md index 721e910fe580863a1aa7880d2096e2b598c9ba85..06e44120f7f29f72d090672e03d9dc2898d667af 100644 --- a/lzma/docs/rom_integrate.md +++ b/thirdparty/lzma/docs/rom_integrate.md @@ -11,7 +11,7 @@ ``` - 三方库目录结构 ``` - tpc_c_cplusplus/lzma + tpc_c_cplusplus/thirdparty/lzma |-- adapted # 存放三方库适配需要的代码文件 |-- docs # 存放三方库相关文档的文件夹 |-- BUILD.gn # 构建脚本,支持rom包集成 @@ -21,7 +21,7 @@ ``` - 将本仓库文件夹拷贝到third_party下 ``` - cp ~/tpc_c_cplusplus/lzma ~/openharmony/third_party/ -rf + cp ~/tpc_c_cplusplus/thirdparty/lzma ~/openharmony/third_party/ -rf ``` ## 准备三方库源码 - 将源码下载到lzma目录并将其解压出来。 diff --git a/minizip-ng/BUILD.gn b/thirdparty/minizip-ng/BUILD.gn similarity index 100% rename from minizip-ng/BUILD.gn rename to thirdparty/minizip-ng/BUILD.gn diff --git a/minizip-ng/CMakeLists.txt b/thirdparty/minizip-ng/CMakeLists.txt similarity index 100% rename from minizip-ng/CMakeLists.txt rename to thirdparty/minizip-ng/CMakeLists.txt diff --git a/minizip-ng/README.OpenSource b/thirdparty/minizip-ng/README.OpenSource similarity index 100% rename from minizip-ng/README.OpenSource rename to thirdparty/minizip-ng/README.OpenSource diff --git a/minizip-ng/README_zh.md b/thirdparty/minizip-ng/README_zh.md similarity index 100% rename from minizip-ng/README_zh.md rename to thirdparty/minizip-ng/README_zh.md diff --git a/minizip-ng/bundle.json b/thirdparty/minizip-ng/bundle.json similarity index 100% rename from minizip-ng/bundle.json rename to thirdparty/minizip-ng/bundle.json diff --git a/minizip-ng/docs/hap_integrate.md b/thirdparty/minizip-ng/docs/hap_integrate.md similarity index 89% rename from minizip-ng/docs/hap_integrate.md rename to thirdparty/minizip-ng/docs/hap_integrate.md index 72957b7b6918d26461e816040bf32116138398ff..a7eb4af16c49536ae2b4452895f2539e32f3480b 100755 --- a/minizip-ng/docs/hap_integrate.md +++ b/thirdparty/minizip-ng/docs/hap_integrate.md @@ -19,7 +19,7 @@ - 仓库代码目录结构说明 ```shell - tpc_c_cplusplus/minizip-ng + tpc_c_cplusplus/thirdparty/minizip-ng ├── docs # 存放三方库相关文档的文件夹 ├── BUILD.gn # 构建脚本,支持rom包集成 ├── bundle.json # 三方库组件定义文件 @@ -48,14 +48,14 @@ - 准备依赖库 minizip依赖了zstd,libiconv,lz4,xz,bzip2以及zlib等库,除了zlib是SDK中已有的,其他库都需要下载。 - - [libiconv适配文件](https://gitee.com/openharmony-sig/tpc_c_cplusplus/blob/master/iconv/docs/rom_integrate.md): 参照文档下载适配代码,将整个iconv文件夹拷贝到/entry/src/main/cpp/third_party
+ - [libiconv适配文件](../../iconv/docs/rom_integrate.md): 参照文档下载适配代码,将整个iconv文件夹拷贝到/entry/src/main/cpp/third_party
[libiconv源码](https://ftp.gnu.org/gnu/libiconv/libiconv-1.7.tar.gz):下载解压后改名为libiconv,并将该源码目录拷贝到iconv文件夹中 - [zstd](https://github.com/facebook/zstd):下载v1.5.2版本,解压后并改为zstd - [lz4](https://gitee.com/openharmony/third_party_lz4/repository/archive/master.zip):下载解压后并改名为lz4 - [bzip2](https://gitee.com/openharmony/third_party_bzip2/repository/archive/master.zip):下载解压后并改名为bzip2 - - [xz适配文件](https://gitee.com/openharmony-sig/tpc_c_cplusplus/blob/master/xz/docs/rom_integrate.md): 参照文档下载适配代码,将整个xz文件夹拷贝到/entry/src/main/cpp/third_party
+ - [xz适配文件](../../xz/docs/rom_integrate.md): 参照文档下载适配代码,将整个xz文件夹拷贝到/entry/src/main/cpp/third_party
[xz源码](https://tukaani.org/xz/xz-5.2.6.tar.gz):下载解压后改名为libxz,并将该源码目录拷贝到xz文件夹中 - 所有依赖库都拷贝到/entry/src/main/cpp/third_party下. + 所有依赖库都拷贝到/entry/src/main/cpp/third_party下. ## 应用中使用三方库 diff --git a/minizip-ng/docs/pic/ets_results.png b/thirdparty/minizip-ng/docs/pic/ets_results.png similarity index 100% rename from minizip-ng/docs/pic/ets_results.png rename to thirdparty/minizip-ng/docs/pic/ets_results.png diff --git a/minizip-ng/docs/pic/install.png b/thirdparty/minizip-ng/docs/pic/install.png similarity index 100% rename from minizip-ng/docs/pic/install.png rename to thirdparty/minizip-ng/docs/pic/install.png diff --git a/minizip-ng/docs/pic/results.png b/thirdparty/minizip-ng/docs/pic/results.png similarity index 100% rename from minizip-ng/docs/pic/results.png rename to thirdparty/minizip-ng/docs/pic/results.png diff --git a/minizip-ng/docs/rom_integrate.md b/thirdparty/minizip-ng/docs/rom_integrate.md similarity index 97% rename from minizip-ng/docs/rom_integrate.md rename to thirdparty/minizip-ng/docs/rom_integrate.md index 9a95619a2e2b0190b65a2756b7e7448a49d02f1e..f0e856d6341001a68d1097630a2d88129413abfe 100644 --- a/minizip-ng/docs/rom_integrate.md +++ b/thirdparty/minizip-ng/docs/rom_integrate.md @@ -11,7 +11,7 @@ ``` - 仓库代码目录结构说明 ``` - tpc_c_cplusplus/minizip-ng + tpc_c_cplusplus/thirdparty/minizip-ng |-- docs # 存放三方库相关文档的文件夹 |-- BUILD.gn # 构建脚本,支持rom包集成 |-- bundle.json # 三方库组件定义文件 @@ -20,7 +20,7 @@ ``` - 将本仓库文件夹拷贝到third_party下 ``` - cp ~/tpc_c_cplusplus/minizipi-ng ~/openharmony/third_party/ -rf + cp ~/tpc_c_cplusplus/thirdparty/minizipi-ng ~/openharmony/third_party/ -rf ``` ## 准备三方库源码 - 将源码下载到minizip-ng目录并将其解压出来。 @@ -98,7 +98,7 @@ hb build --target-cpu arm64 # 编译64位系统使用:arm64, 编译32位 ``` - 运行测试程序 程序安装完后,由于测试用例较多,我们准备了1个测试文件 test.c,测试了该库常用的zip文件压缩和解压缩功能,并和期望结果做对比,内容一致,如图: - ![results](pic/results.png) +  ![results](pic/results.png) ## 参考资料 - [润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld) - [OpenHarmony三方库地址](https://gitee.com/openharmony-tpc) diff --git a/modbus/BUILD.gn b/thirdparty/modbus/BUILD.gn similarity index 100% rename from modbus/BUILD.gn rename to thirdparty/modbus/BUILD.gn diff --git a/modbus/README.OpenSource b/thirdparty/modbus/README.OpenSource similarity index 100% rename from modbus/README.OpenSource rename to thirdparty/modbus/README.OpenSource diff --git a/modbus/README_zh.md b/thirdparty/modbus/README_zh.md similarity index 100% rename from modbus/README_zh.md rename to thirdparty/modbus/README_zh.md diff --git a/modbus/adapted/src/config.h b/thirdparty/modbus/adapted/src/config.h similarity index 100% rename from modbus/adapted/src/config.h rename to thirdparty/modbus/adapted/src/config.h diff --git a/modbus/adapted/src/modbus-version.h b/thirdparty/modbus/adapted/src/modbus-version.h similarity index 100% rename from modbus/adapted/src/modbus-version.h rename to thirdparty/modbus/adapted/src/modbus-version.h diff --git a/modbus/adapted/tests/unit-test.h b/thirdparty/modbus/adapted/tests/unit-test.h similarity index 100% rename from modbus/adapted/tests/unit-test.h rename to thirdparty/modbus/adapted/tests/unit-test.h diff --git a/modbus/bundle.json b/thirdparty/modbus/bundle.json similarity index 100% rename from modbus/bundle.json rename to thirdparty/modbus/bundle.json diff --git a/modbus/docs/pic/running_result.png b/thirdparty/modbus/docs/pic/running_result.png similarity index 100% rename from modbus/docs/pic/running_result.png rename to thirdparty/modbus/docs/pic/running_result.png diff --git a/modbus/docs/rom_integrate.md b/thirdparty/modbus/docs/rom_integrate.md similarity index 94% rename from modbus/docs/rom_integrate.md rename to thirdparty/modbus/docs/rom_integrate.md index 2997177bfe4f60b0a2c46ae84320458fc5a3925e..437bdd419c17d9b6e47547961a51c6c4814a9b58 100755 --- a/modbus/docs/rom_integrate.md +++ b/thirdparty/modbus/docs/rom_integrate.md @@ -20,7 +20,7 @@ - 仓库代码目录结构说明 ```shell - cd ~/tpc_c_cplusplus/modbus/ # 进入到仓库代码库目录 + cd ~/tpc_c_cplusplus/thirdparty/modbus/ # 进入到仓库代码库目录 ``` ```shell @@ -36,7 +36,7 @@ - 将本仓库文件夹拷贝到OpenHarmony源码的third_party目录下 ```shell - cp -arf ~/tpc_c_cplusplus/modbus ~/OpenHarmony/third_party + cp -arf ~/tpc_c_cplusplus/thirdparty/modbus ~/OpenHarmony/third_party ``` ### 准备三方库源码 diff --git a/mqtt/BUILD.gn b/thirdparty/mqtt/BUILD.gn similarity index 100% rename from mqtt/BUILD.gn rename to thirdparty/mqtt/BUILD.gn diff --git a/mqtt/README.OpenSource b/thirdparty/mqtt/README.OpenSource similarity index 100% rename from mqtt/README.OpenSource rename to thirdparty/mqtt/README.OpenSource diff --git a/mqtt/README_zh.md b/thirdparty/mqtt/README_zh.md similarity index 100% rename from mqtt/README_zh.md rename to thirdparty/mqtt/README_zh.md diff --git a/mqtt/adapted/src/VersionInfo.h b/thirdparty/mqtt/adapted/src/VersionInfo.h similarity index 100% rename from mqtt/adapted/src/VersionInfo.h rename to thirdparty/mqtt/adapted/src/VersionInfo.h diff --git a/mqtt/bundle.json b/thirdparty/mqtt/bundle.json similarity index 100% rename from mqtt/bundle.json rename to thirdparty/mqtt/bundle.json diff --git a/mqtt/docs/pic/running_result.png b/thirdparty/mqtt/docs/pic/running_result.png similarity index 100% rename from mqtt/docs/pic/running_result.png rename to thirdparty/mqtt/docs/pic/running_result.png diff --git a/mqtt/docs/rom_integrate.md b/thirdparty/mqtt/docs/rom_integrate.md similarity index 94% rename from mqtt/docs/rom_integrate.md rename to thirdparty/mqtt/docs/rom_integrate.md index 96ddae6ea652e0e6cb4d6e80c2aa4b44d71f2c10..04699590f57931ffb0d5c50f0aee7faead443cf2 100755 --- a/mqtt/docs/rom_integrate.md +++ b/thirdparty/mqtt/docs/rom_integrate.md @@ -20,7 +20,7 @@ - 仓库代码目录结构说明 ```shell - cd ~/tpc_c_cplusplus/mqtt/ # 进入到仓库代码库目录 + cd ~/tpc_c_cplusplus/thirdparty/mqtt # 进入到仓库代码库目录 ``` ```shell @@ -36,7 +36,7 @@ - 将本仓库文件夹拷贝到OpenHarmony源码的third_party目录下 ```shell - cp -arf ~/tpc_c_cplusplus/mqtt ~/OpenHarmony/third_party + cp -arf ~/tpc_c_cplusplus/thirdparty/mqtt ~/OpenHarmony/third_party ``` ### 准备三方库源码 diff --git a/openjpeg/BUILD.gn b/thirdparty/openjpeg/BUILD.gn similarity index 100% rename from openjpeg/BUILD.gn rename to thirdparty/openjpeg/BUILD.gn diff --git a/openjpeg/README.OpenSource b/thirdparty/openjpeg/README.OpenSource similarity index 91% rename from openjpeg/README.OpenSource rename to thirdparty/openjpeg/README.OpenSource index 30935aae8c1942c8a5a5de2696d0f25468b7e28d..89f7df619f54ca9ad1849f10aa6155529b37b2a4 100755 --- a/openjpeg/README.OpenSource +++ b/thirdparty/openjpeg/README.OpenSource @@ -1,7 +1,7 @@ [ { "Name": "openJPEG", - "License": 2-clauses BSD license, + "License": "2-clauses BSD license", "License File": "LICENSE.TXT", "Version Number": "v2.5.0", "Owner": "huangminzhong2@huawei.com", diff --git a/openjpeg/README_zh.md b/thirdparty/openjpeg/README_zh.md similarity index 100% rename from openjpeg/README_zh.md rename to thirdparty/openjpeg/README_zh.md diff --git a/openjpeg/adapter/include/opj_apps_config.h b/thirdparty/openjpeg/adapter/include/opj_apps_config.h similarity index 100% rename from openjpeg/adapter/include/opj_apps_config.h rename to thirdparty/openjpeg/adapter/include/opj_apps_config.h diff --git a/openjpeg/adapter/include/opj_config.h b/thirdparty/openjpeg/adapter/include/opj_config.h similarity index 100% rename from openjpeg/adapter/include/opj_config.h rename to thirdparty/openjpeg/adapter/include/opj_config.h diff --git a/openjpeg/adapter/include/opj_config_private.h b/thirdparty/openjpeg/adapter/include/opj_config_private.h similarity index 100% rename from openjpeg/adapter/include/opj_config_private.h rename to thirdparty/openjpeg/adapter/include/opj_config_private.h diff --git a/openjpeg/adapter/include/tiff/tif_config.h b/thirdparty/openjpeg/adapter/include/tiff/tif_config.h similarity index 100% rename from openjpeg/adapter/include/tiff/tif_config.h rename to thirdparty/openjpeg/adapter/include/tiff/tif_config.h diff --git a/openjpeg/adapter/include/tiff/tiffconf.h b/thirdparty/openjpeg/adapter/include/tiff/tiffconf.h similarity index 100% rename from openjpeg/adapter/include/tiff/tiffconf.h rename to thirdparty/openjpeg/adapter/include/tiff/tiffconf.h diff --git a/openjpeg/adapter/script/test_open_jpeg.sh b/thirdparty/openjpeg/adapter/script/test_open_jpeg.sh similarity index 100% rename from openjpeg/adapter/script/test_open_jpeg.sh rename to thirdparty/openjpeg/adapter/script/test_open_jpeg.sh diff --git a/openjpeg/bundle.json b/thirdparty/openjpeg/bundle.json similarity index 100% rename from openjpeg/bundle.json rename to thirdparty/openjpeg/bundle.json diff --git a/openjpeg/docs/media/running_result.png b/thirdparty/openjpeg/docs/media/running_result.png similarity index 100% rename from openjpeg/docs/media/running_result.png rename to thirdparty/openjpeg/docs/media/running_result.png diff --git a/openjpeg/docs/rom_integrate.md b/thirdparty/openjpeg/docs/rom_integrate.md similarity index 94% rename from openjpeg/docs/rom_integrate.md rename to thirdparty/openjpeg/docs/rom_integrate.md index 23fad823d5d5636be1e983d0a3262f0fa8624aac..88efefe0f93061a148871cc288e774e3b9e19dd2 100755 --- a/openjpeg/docs/rom_integrate.md +++ b/thirdparty/openjpeg/docs/rom_integrate.md @@ -20,7 +20,7 @@ - 仓库代码目录结构说明 ```shell - cd ~/tpc_c_cplusplus/openjpeg/ # 进入到仓库代码库目录 + cd ~/tpc_c_cplusplus/thirdparty/openjpeg # 进入到仓库代码库目录 ``` ```shell @@ -36,7 +36,7 @@ - 将本仓库文件夹拷贝到OpenHarmony源码的third_party目录下 ```shell - cp -arf ~/tpc_c_cplusplus/openjpeg ~/OpenHarmony/third_party + cp -arf ~/tpc_c_cplusplus/thirdparty/openjpeg ~/OpenHarmony/third_party ``` ### 准备三方库源码 diff --git a/rapidjson/BUILD.gn b/thirdparty/rapidjson/BUILD.gn similarity index 100% rename from rapidjson/BUILD.gn rename to thirdparty/rapidjson/BUILD.gn diff --git a/rapidjson/README.OpenSource b/thirdparty/rapidjson/README.OpenSource similarity index 100% rename from rapidjson/README.OpenSource rename to thirdparty/rapidjson/README.OpenSource diff --git a/rapidjson/README_zh.md b/thirdparty/rapidjson/README_zh.md similarity index 100% rename from rapidjson/README_zh.md rename to thirdparty/rapidjson/README_zh.md diff --git a/rapidjson/bundle.json b/thirdparty/rapidjson/bundle.json similarity index 100% rename from rapidjson/bundle.json rename to thirdparty/rapidjson/bundle.json diff --git a/rapidjson/docs/pic/result.png b/thirdparty/rapidjson/docs/pic/result.png similarity index 100% rename from rapidjson/docs/pic/result.png rename to thirdparty/rapidjson/docs/pic/result.png diff --git a/rapidjson/docs/rom_integrate.md b/thirdparty/rapidjson/docs/rom_integrate.md similarity index 95% rename from rapidjson/docs/rom_integrate.md rename to thirdparty/rapidjson/docs/rom_integrate.md index b8fbfba91b22f2316c452bc86f94a27cf9f6b88e..1fc3dba58dd418a5b45e93f611421c77605671ac 100644 --- a/rapidjson/docs/rom_integrate.md +++ b/thirdparty/rapidjson/docs/rom_integrate.md @@ -11,7 +11,7 @@ ``` - 三方库目录结构 ``` - tpc_c_cplusplus/rapidjson #三方库rapidjson的目录结构如下 + tpc_c_cplusplus/thirdparty/rapidjson #三方库rapidjson的目录结构如下 ├── adapted #存放三方库适配需要的代码文件 ├── docs #存放三方库相关文档的文件夹 ├── BUILD.gn #构建脚本,支持rom包集成 @@ -21,13 +21,13 @@ ``` - 将三方库拷贝到OpenHarmony源码的third_party目录下 ``` - cp ~/tpc_c_cplusplus/rapidjson ~/openharmony/third_party -rf + cp ~/tpc_c_cplusplus/thirdparty/rapidjson ~/openharmony/third_party -rf ``` ### 准备三方库源码 ``` cd ~/openharmony/third_party/rapidjson #进入三方库目录 git clone https://github.com/Tencent/rapidjson.git #下载三方库源码 -git git submodule update --init #更新依赖的三方库代码 +git submodule update --init #更新依赖的三方库代码 ``` ## 系统Rom中引入三方库 准备完三方库代码后,我们需要将三方库加入到编译构建体系中。标准系统编译构建可以参考文档[标准系统编译构建指导](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Beta1/zh-cn/device-dev/subsystems/subsys-build-standard-large.md) diff --git a/thirdparty_template/BUILD.gn b/thirdparty/thirdparty_template/BUILD.gn similarity index 100% rename from thirdparty_template/BUILD.gn rename to thirdparty/thirdparty_template/BUILD.gn diff --git a/thirdparty_template/CMakeLists.txt b/thirdparty/thirdparty_template/CMakeLists.txt similarity index 100% rename from thirdparty_template/CMakeLists.txt rename to thirdparty/thirdparty_template/CMakeLists.txt diff --git a/thirdparty/thirdparty_template/HPKBUILD b/thirdparty/thirdparty_template/HPKBUILD new file mode 100755 index 0000000000000000000000000000000000000000..27f52b9dacbf90972812c6081c932d067b159860 --- /dev/null +++ b/thirdparty/thirdparty_template/HPKBUILD @@ -0,0 +1,63 @@ +# This is an example HPKBUILD file. Use this as a start to creating your own, +# and remove these comments. +# NOTE: Please fill out the license field for your package! If it is unknown, +# then please put 'unknown'. + +# Contributor: Your Name +# Maintainer: Your Name + +pkgname=NAME # 库名 +pkgver=VERSION # 库版本 +pkgrel=0 # 发布号 +pkgdesc="" # 库描述 +url="" # 官网链接 +archs=("armeabi-v7a" "arm64-v8a") # cpu 架构 +license=() +depends=() # 依赖库的目录名 必须保证被依赖的库的archs是当前库的archs的超集 +makedepends=() # 构建库时的依赖工具 +source="https://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz" # 库源码下载链接 + +downloadpackage=true # 是否自动下载压缩包,如若不写默认 true, 一些特殊情况,代码需要代码只能 git clone (项目中依赖 submoudle ) +autounpack=true # 是否自动解压,如若不写默认 true, 如果为 false 则需要用户在 prepare 函数中自行解压 +buildtools= # 编译方法, 暂时支持cmake, configure, make等, 是什么就填写什么. 如若不写默认为cmake. + +builddir= # 源码压缩包解压后目录名 编译目录名 +packageName=$builddir.tar.gz # 压缩包名 + +# 为编译设置环境,如设置环境变量,创建编译目录等 +prepare() { + cd $builddir + cd ${OLDPWD} +} + +# ${OHOS_SDK} oh sdk安装路径 +# $ARCH 编译的架构是 archs 的遍历 +# $LYCIUM_ROOT/usr/$pkgname-$ARCH-install 安装到顶层目录的usr/$pkgname-$ARCH-install +# 执行编译构建的命令 +build() { + # 如果是cmake构建 $*=-DCMAKE_FIND_ROOT_PATH="..." -DCMAKE_TOOLCHAIN_FILE="..." -DCMAKE_INSTALL_PREFIX="..." 依赖库的搜索路径,toolchain file 路径,安装路径 + cd $builddir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake $* -DOHOS_ARCH=$ARCH -B$ARCH-build -S./ -L + make -j4 -C $ARCH-build + # 对最关键一步的退出码进行判断 + ret=$? + cd $OLDPWD + return $ret +} + +# 打包安装 +package() { + cd $builddir + make -C $ARCH-build install + cd $OLDPWD +} + +# 进行测试的准备和说明 +check() { + echo "The test must be on an OpenHarmony device!" +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/$builddir #${PWD}/$packageName +} diff --git a/thirdparty_template/README.OpenSource b/thirdparty/thirdparty_template/README.OpenSource similarity index 100% rename from thirdparty_template/README.OpenSource rename to thirdparty/thirdparty_template/README.OpenSource diff --git a/thirdparty/thirdparty_template/README_zh.md b/thirdparty/thirdparty_template/README_zh.md new file mode 100755 index 0000000000000000000000000000000000000000..61a4618ecaedf0b42a4fc10daa1833a0072e5967 --- /dev/null +++ b/thirdparty/thirdparty_template/README_zh.md @@ -0,0 +1,33 @@ +## 目录结构 + +``` +tpc_c_cplusplus/thirdparty +├── README_zh.md #仓库主页 +├── common #仓库通用说明文档的文件夹 +├── thirdparty_template #三方库模板文件夹 +│ ├──README_zh.md #三方库简介 +│ ├──README.OpenSource #说明三方库源码的下载地址,版本,license等信息 +│ ├──ohos.build #三方库组件定义文件 +│ ├──CMakeLists.txt #构建脚本,支持hap包集成 +│ ├──HPKBUILD #交叉构建脚本,使用原库自带脚本编译,支持hap包集成 +│ ├──SHA512SUM #压缩包校验文件,和HPKBUILD一起使用 +│ ├──BUILD.gn #构建脚本,支持rom包集成 +│ ├──adapted #该目录存放三方库适配需要的代码文件 +│ │ ├──config.h #例如配置文件 +│ │ ├──... #其他适配文件 +│ ├──docs #存放三方库相关文档的文件夹 +│ │ ├──rom_integrate.md #rom集成说明文档 +│ │ ├──hap_integrate.md #hap集成说明文档 +│ │ ├── ... #其他说明文档 +├── thirdparty1 #三方库文件夹,内容和thirdparty_template模板的格式一样 +├── thirdparty2 #三方库文件夹,内容和thirdparty_template模板的格式一样 +...... +``` + + + +## 如何贡献 + +- [遵守仓库目录结构](#本仓库目录) +- [遵守OpenHarmony编码贡献规范](https://gitee.com/openharmony-sig/knowledge_demo_smart_home/blob/master/dev/docs/contribute/README.md) +- [三方库模板目录](thirdparty_template) diff --git a/thirdparty/thirdparty_template/SHA512SUM b/thirdparty/thirdparty_template/SHA512SUM new file mode 100755 index 0000000000000000000000000000000000000000..16934b8ade854efc82ab0f345c775c159d85aa68 --- /dev/null +++ b/thirdparty/thirdparty_template/SHA512SUM @@ -0,0 +1 @@ +*************************************************************************************** xxx.tar.gz \ No newline at end of file diff --git a/thirdparty_template/adapted/config.h b/thirdparty/thirdparty_template/adapted/config.h similarity index 100% rename from thirdparty_template/adapted/config.h rename to thirdparty/thirdparty_template/adapted/config.h diff --git a/thirdparty/thirdparty_template/bundle.json b/thirdparty/thirdparty_template/bundle.json new file mode 100755 index 0000000000000000000000000000000000000000..b10c45b9e522fd6fb74e81102ef68b72f8834720 --- /dev/null +++ b/thirdparty/thirdparty_template/bundle.json @@ -0,0 +1,30 @@ +{ + "name": "", + "description": "", + "version": "", + "license": "", + "publishAs": "", + "segment": { + "destPath": "" + }, + "dirs": {}, + "scripts": {}, + "component": { + "name": "", + "subsystem": "thirdparty", + "syscap": [], + "features": [], + "adapted_system_type": [], + "rom": "", + "ram": "", + "deps": { + "components": [], + "third_party": [] + }, + "build": { + "sub_component": [], + "inner_kits": [], + "test": [] + } + } +} diff --git a/thirdparty_template/docs/hap_integrate.md b/thirdparty/thirdparty_template/docs/hap_integrate.md similarity index 100% rename from thirdparty_template/docs/hap_integrate.md rename to thirdparty/thirdparty_template/docs/hap_integrate.md diff --git a/thirdparty_template/docs/rom_integrate.md b/thirdparty/thirdparty_template/docs/rom_integrate.md similarity index 100% rename from thirdparty_template/docs/rom_integrate.md rename to thirdparty/thirdparty_template/docs/rom_integrate.md diff --git a/tinyxml2/BUILD.gn b/thirdparty/tinyxml2/BUILD.gn similarity index 100% rename from tinyxml2/BUILD.gn rename to thirdparty/tinyxml2/BUILD.gn diff --git a/tinyxml2/CMakeLists.txt b/thirdparty/tinyxml2/CMakeLists.txt similarity index 100% rename from tinyxml2/CMakeLists.txt rename to thirdparty/tinyxml2/CMakeLists.txt diff --git a/tinyxml2/README.OpenSource b/thirdparty/tinyxml2/README.OpenSource similarity index 100% rename from tinyxml2/README.OpenSource rename to thirdparty/tinyxml2/README.OpenSource diff --git a/tinyxml2/README_zh.md b/thirdparty/tinyxml2/README_zh.md similarity index 100% rename from tinyxml2/README_zh.md rename to thirdparty/tinyxml2/README_zh.md diff --git a/tinyxml2/bundle.json b/thirdparty/tinyxml2/bundle.json similarity index 100% rename from tinyxml2/bundle.json rename to thirdparty/tinyxml2/bundle.json diff --git a/tinyxml2/docs/hap_integrate.md b/thirdparty/tinyxml2/docs/hap_integrate.md similarity index 97% rename from tinyxml2/docs/hap_integrate.md rename to thirdparty/tinyxml2/docs/hap_integrate.md index 68e834ccede08fa8113229834057e28f81d3fab5..fe8f0bf38c89df5f82d2630afd9175562c248e56 100644 --- a/tinyxml2/docs/hap_integrate.md +++ b/thirdparty/tinyxml2/docs/hap_integrate.md @@ -14,7 +14,7 @@ 通过[C/C++三方库TCP仓](https://gitee.com/openharmony-sig/tpc_c_cplusplus)下载本三方库代码并将其解压。 - 仓库代码库目录结构说明 ``` - tpc_c_cplusplus/tinyxml2 #三方库tinyxml2 的目录结构如下 + tpc_c_cplusplus/thirdparty/tinyxml2 #三方库tinyxml2 的目录结构如下 ├── docs #存放三方库相关文档的文件夹 ├── BUILD.gn # 构建脚本,支持rom包集成 ├── CmakeLists.txt #构建脚本,支持hap包集成 diff --git a/tinyxml2/docs/pic/hap.jpeg b/thirdparty/tinyxml2/docs/pic/hap.jpeg similarity index 100% rename from tinyxml2/docs/pic/hap.jpeg rename to thirdparty/tinyxml2/docs/pic/hap.jpeg diff --git a/tinyxml2/docs/pic/install.png b/thirdparty/tinyxml2/docs/pic/install.png similarity index 100% rename from tinyxml2/docs/pic/install.png rename to thirdparty/tinyxml2/docs/pic/install.png diff --git a/tinyxml2/docs/pic/result.png b/thirdparty/tinyxml2/docs/pic/result.png similarity index 100% rename from tinyxml2/docs/pic/result.png rename to thirdparty/tinyxml2/docs/pic/result.png diff --git a/tinyxml2/docs/rom_integrate.md b/thirdparty/tinyxml2/docs/rom_integrate.md similarity index 97% rename from tinyxml2/docs/rom_integrate.md rename to thirdparty/tinyxml2/docs/rom_integrate.md index 28c307923c36c2616311275e5f050a8d00d48e5b..163135e1b7eab9a08f77c34bf3a76023dbbeeff0 100644 --- a/tinyxml2/docs/rom_integrate.md +++ b/thirdparty/tinyxml2/docs/rom_integrate.md @@ -11,7 +11,7 @@ ``` - 三方库目录结构 ``` - tpc_c_cplusplus/tinyxml2 #三方库tinyxml2的目录结构如下 + tpc_c_cplusplus/thirdparty/tinyxml2 #三方库tinyxml2的目录结构如下 ├── adapted #存放三方库适配需要的代码文件 ├── docs #存放三方库相关文档的文件夹 ├── BUILD.gn #构建脚本,支持rom包集成 @@ -21,7 +21,7 @@ ``` - 将三方库拷贝到OpenHarmony源码的third_party目录下 ``` - cp ~/tpc_c_cplusplus/tinyxml2 ~/openharmony/third_party -rf + cp ~/tpc_c_cplusplus/thirdparty/tinyxml2 ~/openharmony/third_party -rf ``` ### 准备三方库源码 ``` diff --git a/thirdparty/tinyxpath/HPKBUILD b/thirdparty/tinyxpath/HPKBUILD new file mode 100755 index 0000000000000000000000000000000000000000..a8dc1fe534a560df075592b669661e7f6b094391 --- /dev/null +++ b/thirdparty/tinyxpath/HPKBUILD @@ -0,0 +1,54 @@ +# Contributor: huangminzhong +# Maintainer: huangminzhong +pkgname=tinyxpath +pkgver=1.3.1 +pkgrel=0 +pkgdesc="" +url="" +archs=("armeabi-v7a" "arm64-v8a") +license=("LGPL-2.1" "GPL-2.0") +depends=() +makedepends=() +install= +source="https://sourceforge.net/projects/tinyxpath/files/TinyXPath%20%28Linux%20-%20tar.gz%29/TinyXPath%201.3.1/tinyxpath_1_3_1.tgz" +downloadpackage=true +autounpack=false +buildDir=$pkgname-$pkgver +packageName=tinyxpath_1_3_1.tgz # 压缩包名 +decompFlag=true + +prepare() { + if [ $decompFlag == true ];then + mkdir -p $buildDir + tar xvf $packageName -C $buildDir > /dev/null + decompFlag=false + cd $buildDir + patch -p1 < `pwd`/../tinyxpath_oh_pkg.patch + cd ${OLDPWD} + fi + mkdir -p $buildDir/$ARCH-build +} + +build() { + cd $buildDir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake $* -DOHOS_ARCH=$ARCH -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/$ARCH-build + make install >> build.log 2>&1 + cd $OLDPWD +} + +check() { + echo "The test must be on an OpenHarmony device!" +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/$buildDir #${PWD}/$packageName +} diff --git a/thirdparty/tinyxpath/README.OpenSource b/thirdparty/tinyxpath/README.OpenSource new file mode 100755 index 0000000000000000000000000000000000000000..1b25a9b2281a102c4fec15be4b2570695d004546 --- /dev/null +++ b/thirdparty/tinyxpath/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "tinyxpath", + "License": "zlib/libpng License", + "License File": "notes.txt", + "Version Number": "1.3.1",: + "Owner": "huangminzhong2@huawei.com", + "Upstream URL": "https://sourceforge.net/projects/tinyxpath/files/TinyXPath%20%28Linux%20-%20tar.gz%29/TinyXPath%201.3.1/tinyxpath_1_3_1.tgz", + "Description": "Small footprint C++ library to extract an XPath 1.0 expression from an XML tree" + } +] diff --git a/thirdparty/tinyxpath/README_zh.md b/thirdparty/tinyxpath/README_zh.md new file mode 100755 index 0000000000000000000000000000000000000000..12b8174a7bdedb38afffb912c7e03e7fca769d3b --- /dev/null +++ b/thirdparty/tinyxpath/README_zh.md @@ -0,0 +1,12 @@ +# tinyxpath三方库说明 +## 功能简介 +tinyxpath用于从 XML 树中提取 XPath 1.0 表达式。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Release +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:1.3.1 +- 当前适配的功能:支持xpath语法解析 +- [zlib/libpng License](https://sourceforge.net/projects/tinyxpath/) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/tinyxpath/SHA512SUM b/thirdparty/tinyxpath/SHA512SUM new file mode 100755 index 0000000000000000000000000000000000000000..e6993f170799e2256c24b71e4a73c2e105213f92 --- /dev/null +++ b/thirdparty/tinyxpath/SHA512SUM @@ -0,0 +1,2 @@ +56fab69d20ab28bd9330ce7917397d501f53bda06c19277a70b09c9b69ff4171f0d196af526a3991409afa1eb08d83dd2d9039118c6efb83764868bef1c9fbd9 tinyxpath_1_3_1.tgz +f9eb2247aa2bc1f5c2064e3e368a2bba8de8b56d960f7705efc2c0196b7097a9337df15943ea2de70895e4cf06208681a80019b93fe0c26ce469d1534517e28d tinyxpath_oh_pkg.patch diff --git a/thirdparty/tinyxpath/docs/hap_integrate.md b/thirdparty/tinyxpath/docs/hap_integrate.md new file mode 100755 index 0000000000000000000000000000000000000000..a2a7a288c9de6665dde1d459cb377c285a44c428 --- /dev/null +++ b/thirdparty/tinyxpath/docs/hap_integrate.md @@ -0,0 +1,67 @@ +# tinyxpath集成到应用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/tinyxpath #三方库tinyxpath的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将tinyxpath拷贝至tools/main目录下 + ``` + cd tpc_c_cplusplus + cp thirdparty/tinyxpath tools/main -rf + ``` +- 在tools目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + ``` + cd tools + ./build.sh tinyxpath + ``` +- 三方库头文件及生成的库 + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + ``` + tinyxpath-arm64-v8a-install tinyxpath-armeabi-v7a-install + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + ![thirdparty_install_dir](pic/tinyxpath_install_dir.png) +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ``` + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/tinyxpath-${OHOS_ARCH}-install/lib/libtinyxpath.a) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/tinyxpath-${OHOS_ARCH}-install/include) + ``` + ![tinyxpath_usage](pic/tinyxpath_usage.png) +## 测试三方库 +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +进入到构建目录执行ctest运行测试用例(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) + + ![tinyxpath_test](pic/tinyxpath_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/tinyxpath/docs/pic/tinyxpath_install_dir.png b/thirdparty/tinyxpath/docs/pic/tinyxpath_install_dir.png new file mode 100755 index 0000000000000000000000000000000000000000..ccf3eb8adaaf3fa591c069aba9369e6d0607cf88 Binary files /dev/null and b/thirdparty/tinyxpath/docs/pic/tinyxpath_install_dir.png differ diff --git a/thirdparty/tinyxpath/docs/pic/tinyxpath_test.png b/thirdparty/tinyxpath/docs/pic/tinyxpath_test.png new file mode 100755 index 0000000000000000000000000000000000000000..6fd3a03d2fbe5e91163e504cee2f572df95b552b Binary files /dev/null and b/thirdparty/tinyxpath/docs/pic/tinyxpath_test.png differ diff --git a/thirdparty/tinyxpath/docs/pic/tinyxpath_usage.png b/thirdparty/tinyxpath/docs/pic/tinyxpath_usage.png new file mode 100755 index 0000000000000000000000000000000000000000..676e188a6d5f14109bbb7c907d28ba345c904cfe Binary files /dev/null and b/thirdparty/tinyxpath/docs/pic/tinyxpath_usage.png differ diff --git a/thirdparty/tinyxpath/tinyxpath_oh_pkg.patch b/thirdparty/tinyxpath/tinyxpath_oh_pkg.patch new file mode 100755 index 0000000000000000000000000000000000000000..78665f093b6ca57ee5144c674e2e613ea022f4a9 --- /dev/null +++ b/thirdparty/tinyxpath/tinyxpath_oh_pkg.patch @@ -0,0 +1,129 @@ +diff -uprN tinyxpath/cmake/PackageConfig.cmake.in tinyxpath-1.3.1/cmake/PackageConfig.cmake.in +--- tinyxpath/cmake/PackageConfig.cmake.in 1969-12-31 16:00:00.000000000 -0800 ++++ tinyxpath-1.3.1/cmake/PackageConfig.cmake.in 2023-02-20 23:38:20.888215070 -0800 +@@ -0,0 +1,11 @@ ++@PACKAGE_INIT@ ++ ++#set(@PROJECT_NAME@_INCLUDE_DIRS @CMAKE_INSTALL_PREFIX@/@TARGET_INSTALL_INCLUDEDIR@/@TARGET_NAME@) ++#set(@PROJECT_NAME@_LIBRARIES @TARGET_NAME@) ++set(@PROJECT_NAME@_INCLUDE_DIRS ${PACKAGE_PREFIX_DIR}/include) ++set(@PROJECT_NAME@_LIBRARIES ${PACKAGE_PREFIX_DIR}/lib/lib@TARGET_NAME@.a) ++ ++include(CMakeFindDependencyMacro) ++ ++include(${CMAKE_CURRENT_LIST_DIR}/@TARGET_NAME@Targets.cmake) ++check_required_components(@TARGET_NAME@) +diff -uprN tinyxpath/CMakeLists.txt tinyxpath-1.3.1/CMakeLists.txt +--- tinyxpath/CMakeLists.txt 1969-12-31 16:00:00.000000000 -0800 ++++ tinyxpath-1.3.1/CMakeLists.txt 2023-03-13 19:30:44.305558572 -0700 +@@ -0,0 +1,109 @@ ++cmake_minimum_required (VERSION 3.12) ++ ++project(TINYXPATH VERSION 1.3.0) ++enable_language(CXX C ASM) ++enable_testing() ++option(BUILD_SAMPLE "Build sample" OFF) ++set(BUILD_SHARED_LIBS FALSE CACHE BOOL "If TRUE, tinyxpath is built as a shared library, otherwise as a static library") ++ ++set(TARGET_NAME tinyxpath) ++set(TARGET_SAMPLE_NAME tinyxpath_test) ++ ++set(TARGET_INSTALL_INCLUDEDIR include) ++set(TARGET_INSTALL_BINDIR bin) ++set(TARGET_INSTALL_LIBDIR lib) ++ ++set(TARGET_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR}) ++set(TARGET_SRC ${TARGET_SRC_PATH}/tinystr.cpp ++ ${TARGET_SRC_PATH}/tinyxml.cpp ++ ${TARGET_SRC_PATH}/tinyxmlerror.cpp ++ ${TARGET_SRC_PATH}/tinyxmlparser.cpp ++ ${TARGET_SRC_PATH}/action_store.cpp ++ ${TARGET_SRC_PATH}/lex_util.cpp ++ ${TARGET_SRC_PATH}/node_set.cpp ++ ${TARGET_SRC_PATH}/tokenlist.cpp ++ ${TARGET_SRC_PATH}/xml_util.cpp ++ ${TARGET_SRC_PATH}/xpath_expression.cpp ++ ${TARGET_SRC_PATH}/xpath_processor.cpp ++ ${TARGET_SRC_PATH}/xpath_stack.cpp ++ ${TARGET_SRC_PATH}/xpath_stream.cpp ++ ${TARGET_SRC_PATH}/xpath_syntax.cpp ++ ${TARGET_SRC_PATH}/xpath_static.cpp) ++if(BUILD_SAMPLE) ++ set(TARGET_SAMPLE_SRC ${TARGET_SRC_PATH}/htmlutil.cpp ${TARGET_SRC_PATH}/main.cpp) ++endif() ++ ++set(TARGET_INCLUDE ${TARGET_SRC_PATH}) ++ ++add_library(${TARGET_NAME} ${TARGET_SRC}) ++target_include_directories(${TARGET_NAME} PRIVATE ${TARGET_INCLUDE}) ++ ++if(BUILD_SHARED_LIBS) ++ SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} ++ SOVERSION ${PROJECT_VERSION_MAJOR}) ++endif() ++ ++if(BUILD_SAMPLE) ++ add_executable(${TARGET_SAMPLE_NAME} ${TARGET_SAMPLE_SRC}) ++ target_include_directories(${TARGET_SAMPLE_NAME} PRIVATE ${TARGET_INCLUDE}) ++ target_link_libraries(${TARGET_SAMPLE_NAME} PUBLIC ${TARGET_NAME}) ++endif() ++ ++install(TARGETS ${TARGET_NAME} ++ EXPORT ${TARGET_NAME} ++ PUBLIC_HEADER DESTINATION ${TARGET_INSTALL_INCLUDEDIR} ++ PRIVATE_HEADER DESTINATION ${TARGET_INSTALL_INCLUDEDIR} ++ RUNTIME DESTINATION ${TARGET_INSTALL_BINDIR} ++ LIBRARY DESTINATION ${TARGET_INSTALL_LIBDIR} ++ ARCHIVE DESTINATION ${TARGET_INSTALL_LIBDIR}) ++ ++install(FILES ${TARGET_SRC_PATH}/xpath_processor.h ++ ${TARGET_SRC_PATH}/action_store.h ++ ${TARGET_SRC_PATH}/byte_stream.h ++ ${TARGET_SRC_PATH}/lex_token.h ++ ${TARGET_SRC_PATH}/lex_util.h ++ ${TARGET_SRC_PATH}/node_set.h ++ ${TARGET_SRC_PATH}/tinystr.h ++ ${TARGET_SRC_PATH}/tinyxml.h ++ ${TARGET_SRC_PATH}/tinyxpath_conf.h ++ ${TARGET_SRC_PATH}/tokenlist.h ++ ${TARGET_SRC_PATH}/xml_util.h ++ ${TARGET_SRC_PATH}/xpath_expression.h ++ ${TARGET_SRC_PATH}/xpath_processor.h ++ ${TARGET_SRC_PATH}/xpath_stack.h ++ ${TARGET_SRC_PATH}/xpath_static.h ++ ${TARGET_SRC_PATH}/xpath_stream.h ++ ${TARGET_SRC_PATH}/xpath_syntax.h ++ DESTINATION ${TARGET_INSTALL_INCLUDEDIR}/${TARGET_NAME}) ++ ++install( ++ EXPORT ${TARGET_NAME} ++ FILE ${TARGET_NAME}Targets.cmake ++ DESTINATION ${TARGET_INSTALL_LIBDIR}/cmake/${TARGET_NAME} ++) ++ ++include(CMakePackageConfigHelpers) ++ ++write_basic_package_version_file( ++ ${TARGET_NAME}ConfigVersion.cmake ++ VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} ++ COMPATIBILITY SameMajorVersion ++) ++ ++configure_package_config_file( ++ cmake/PackageConfig.cmake.in ${TARGET_NAME}Config.cmake ++ INSTALL_DESTINATION ${TARGET_INSTALL_LIBDIR}/cmake/${TARGET_NAME} ++) ++ ++install(FILES ++ ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}Config.cmake ++ ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}ConfigVersion.cmake ++ DESTINATION ++ ${TARGET_INSTALL_LIBDIR}/cmake/${TARGET_NAME} ++) ++ ++if (BUILD_SAMPLE) ++ add_test(NAME test ++ WORKING_DIRECTORY ${TARGET_SRC_PATH} ++ COMMAND ${TARGET_SAMPLE_NAME}) ++endif() +\ No newline at end of file diff --git a/unrar/CMakeLists.txt b/thirdparty/unrar/CMakeLists.txt similarity index 100% rename from unrar/CMakeLists.txt rename to thirdparty/unrar/CMakeLists.txt diff --git a/unrar/README.OpenSource b/thirdparty/unrar/README.OpenSource similarity index 100% rename from unrar/README.OpenSource rename to thirdparty/unrar/README.OpenSource diff --git a/unrar/README_zh.md b/thirdparty/unrar/README_zh.md similarity index 100% rename from unrar/README_zh.md rename to thirdparty/unrar/README_zh.md diff --git a/unrar/docs/hap_integrate.md b/thirdparty/unrar/docs/hap_integrate.md similarity index 97% rename from unrar/docs/hap_integrate.md rename to thirdparty/unrar/docs/hap_integrate.md index 495681c5daa94d98a38e08314d30d820feafe8cd..82f3fc89432647c51a514966721e94406fd4d8b4 100644 --- a/unrar/docs/hap_integrate.md +++ b/thirdparty/unrar/docs/hap_integrate.md @@ -7,7 +7,7 @@ - 下载本仓库,并解压 - 三方库目录结构 ``` - tpc_c_cplusplus/unrar #三方库unrar的目录结构如下 + tpc_c_cplusplus/thirdparty/unrar #三方库unrar的目录结构如下 ├── docs #存放三方库相关文档的文件夹 ├── CmakeLists.txt #构建脚本,支持hap包集成 ├── package.json #三方库组件定义文件 diff --git a/unrar/docs/pic/content.png b/thirdparty/unrar/docs/pic/content.png similarity index 100% rename from unrar/docs/pic/content.png rename to thirdparty/unrar/docs/pic/content.png diff --git a/unrar/docs/pic/unrar1.png b/thirdparty/unrar/docs/pic/unrar1.png similarity index 100% rename from unrar/docs/pic/unrar1.png rename to thirdparty/unrar/docs/pic/unrar1.png diff --git a/unrar/package.json b/thirdparty/unrar/package.json similarity index 100% rename from unrar/package.json rename to thirdparty/unrar/package.json diff --git a/xerces-c/BUILD.gn b/thirdparty/xerces-c/BUILD.gn similarity index 100% rename from xerces-c/BUILD.gn rename to thirdparty/xerces-c/BUILD.gn diff --git a/xerces-c/CMakeLists.txt b/thirdparty/xerces-c/CMakeLists.txt similarity index 100% rename from xerces-c/CMakeLists.txt rename to thirdparty/xerces-c/CMakeLists.txt diff --git a/xerces-c/README.OpenSource b/thirdparty/xerces-c/README.OpenSource similarity index 100% rename from xerces-c/README.OpenSource rename to thirdparty/xerces-c/README.OpenSource diff --git a/xerces-c/README_zh.md b/thirdparty/xerces-c/README_zh.md similarity index 100% rename from xerces-c/README_zh.md rename to thirdparty/xerces-c/README_zh.md diff --git a/xerces-c/adapted/config.h b/thirdparty/xerces-c/adapted/config.h similarity index 100% rename from xerces-c/adapted/config.h rename to thirdparty/xerces-c/adapted/config.h diff --git a/xerces-c/adapted/xercesc/util/XercesVersion.hpp b/thirdparty/xerces-c/adapted/xercesc/util/XercesVersion.hpp similarity index 100% rename from xerces-c/adapted/xercesc/util/XercesVersion.hpp rename to thirdparty/xerces-c/adapted/xercesc/util/XercesVersion.hpp diff --git a/xerces-c/adapted/xercesc/util/Xerces_autoconf_config.hpp b/thirdparty/xerces-c/adapted/xercesc/util/Xerces_autoconf_config.hpp similarity index 100% rename from xerces-c/adapted/xercesc/util/Xerces_autoconf_config.hpp rename to thirdparty/xerces-c/adapted/xercesc/util/Xerces_autoconf_config.hpp diff --git a/xerces-c/bundle.json b/thirdparty/xerces-c/bundle.json similarity index 100% rename from xerces-c/bundle.json rename to thirdparty/xerces-c/bundle.json diff --git a/xerces-c/docs/hap_integrate.md b/thirdparty/xerces-c/docs/hap_integrate.md similarity index 96% rename from xerces-c/docs/hap_integrate.md rename to thirdparty/xerces-c/docs/hap_integrate.md index 4f75c3ca24fe15e88e41114181cf7347aa96a8ba..a96939eebee877e865aee253993fd0131ff7f297 100755 --- a/xerces-c/docs/hap_integrate.md +++ b/thirdparty/xerces-c/docs/hap_integrate.md @@ -7,7 +7,7 @@ - 下载本仓库,并解压 - 三方库目录结构 ``` - tpc_c_cplusplus/xerces-c #三方库xerces-c的目录结构如下 + tpc_c_cplusplus/thirdparty/xerces-c #三方库xerces-c的目录结构如下 ├── adapted #存放三方库适配需要的代码文件 ├── docs #存放三方库相关文档的文件夹 ├── CmakeLists.txt #构建脚本,支持hap包集成 diff --git a/xerces-c/docs/pic/content.png b/thirdparty/xerces-c/docs/pic/content.png similarity index 100% rename from xerces-c/docs/pic/content.png rename to thirdparty/xerces-c/docs/pic/content.png diff --git a/xerces-c/docs/pic/hap_xerces_test.png b/thirdparty/xerces-c/docs/pic/hap_xerces_test.png similarity index 100% rename from xerces-c/docs/pic/hap_xerces_test.png rename to thirdparty/xerces-c/docs/pic/hap_xerces_test.png diff --git a/xerces-c/docs/pic/result.png b/thirdparty/xerces-c/docs/pic/result.png similarity index 100% rename from xerces-c/docs/pic/result.png rename to thirdparty/xerces-c/docs/pic/result.png diff --git a/xerces-c/docs/rom_integrate.md b/thirdparty/xerces-c/docs/rom_integrate.md similarity index 95% rename from xerces-c/docs/rom_integrate.md rename to thirdparty/xerces-c/docs/rom_integrate.md index da79bbb5f35a2d9efcbf9b741ea22d16d797deff..27ca028956f75ae5d0d874a289020647d7a6449c 100755 --- a/xerces-c/docs/rom_integrate.md +++ b/thirdparty/xerces-c/docs/rom_integrate.md @@ -11,7 +11,7 @@ ``` - 三方库目录结构 ``` - tpc_c_cplusplus/xerces-c #三方库xerces-c的目录结构如下 + tpc_c_cplusplus/thirdparty/xerces-c #三方库xerces-c的目录结构如下 ├── adapted #存放三方库适配需要的代码文件 ├── docs #存放三方库相关文档的文件夹 ├── BUILD.gn #构建脚本,支持rom包集成 @@ -21,7 +21,7 @@ ``` - 将三方库拷贝到OpenHarmony源码的third_party目录下 ``` - cp ~/tpc_c_cplusplus/xerces-c ~/openharmony/third_party -rf + cp ~/tpc_c_cplusplus/thirdparty/xerces-c ~/openharmony/third_party -rf ``` ### 准备三方库源码 ``` diff --git a/xz/BUILD.gn b/thirdparty/xz/BUILD.gn similarity index 100% rename from xz/BUILD.gn rename to thirdparty/xz/BUILD.gn diff --git a/xz/README.OpenSource b/thirdparty/xz/README.OpenSource similarity index 100% rename from xz/README.OpenSource rename to thirdparty/xz/README.OpenSource diff --git a/xz/README_zh.md b/thirdparty/xz/README_zh.md similarity index 100% rename from xz/README_zh.md rename to thirdparty/xz/README_zh.md diff --git a/xz/adapted/config.h b/thirdparty/xz/adapted/config.h similarity index 100% rename from xz/adapted/config.h rename to thirdparty/xz/adapted/config.h diff --git a/xz/adapted/test_file.sh b/thirdparty/xz/adapted/test_file.sh similarity index 100% rename from xz/adapted/test_file.sh rename to thirdparty/xz/adapted/test_file.sh diff --git a/xz/bundle.json b/thirdparty/xz/bundle.json similarity index 100% rename from xz/bundle.json rename to thirdparty/xz/bundle.json diff --git a/xz/docs/pic/test_result.jpg b/thirdparty/xz/docs/pic/test_result.jpg similarity index 100% rename from xz/docs/pic/test_result.jpg rename to thirdparty/xz/docs/pic/test_result.jpg diff --git a/xz/docs/rom_integrate.md b/thirdparty/xz/docs/rom_integrate.md similarity index 94% rename from xz/docs/rom_integrate.md rename to thirdparty/xz/docs/rom_integrate.md index a4730fddbbc65e5e4b32ebdb1b17f70a971ee238..92d0ddf98f0fd20edac63cdd2c3787adafa32d34 100644 --- a/xz/docs/rom_integrate.md +++ b/thirdparty/xz/docs/rom_integrate.md @@ -20,7 +20,7 @@ - 三方库目录结构 ```shell - cd tpc_c_cplusplus/xz # 进入到仓库代码库目录 + cd tpc_c_cplusplus/thirdparty/xz # 进入到仓库代码库目录 ``` ```shell @@ -36,7 +36,7 @@ - 将本仓库xz文件夹拷贝到third_party下 ```shell - cp ~/tpc_c_cplusplus/xz ~/openharmony/third_party/ -arf + cp ~/tpc_c_cplusplus/thirdparty/xz ~/openharmony/third_party/ -arf ``` ## 准备三方库源码 diff --git a/zstd/BUILD.gn b/thirdparty/zstd/BUILD.gn similarity index 100% rename from zstd/BUILD.gn rename to thirdparty/zstd/BUILD.gn diff --git a/zstd/README.OpenSource b/thirdparty/zstd/README.OpenSource similarity index 100% rename from zstd/README.OpenSource rename to thirdparty/zstd/README.OpenSource diff --git a/zstd/README_zh.md b/thirdparty/zstd/README_zh.md similarity index 100% rename from zstd/README_zh.md rename to thirdparty/zstd/README_zh.md diff --git a/zstd/bundle.json b/thirdparty/zstd/bundle.json similarity index 100% rename from zstd/bundle.json rename to thirdparty/zstd/bundle.json diff --git a/zstd/docs/pic/results.png b/thirdparty/zstd/docs/pic/results.png similarity index 100% rename from zstd/docs/pic/results.png rename to thirdparty/zstd/docs/pic/results.png diff --git a/zstd/docs/rom_integrate.md b/thirdparty/zstd/docs/rom_integrate.md similarity index 98% rename from zstd/docs/rom_integrate.md rename to thirdparty/zstd/docs/rom_integrate.md index e5b28e03d5aa8080b2af6c3631aac3d5c7604cd2..21f1a861d428dc0293c0579395365e27f03b3286 100644 --- a/zstd/docs/rom_integrate.md +++ b/thirdparty/zstd/docs/rom_integrate.md @@ -11,7 +11,7 @@ ``` - 三方库目录结构 ``` - tpc_c_cplusplus/zstd + tpc_c_cplusplus/thirdparty/zstd |-- docs # 存放三方库相关文档的文件夹 |-- BUILD.gn # 构建脚本,支持rom包集成 |-- bundle.json # 三方库组件定义文件 @@ -20,7 +20,7 @@ ``` - 将本仓库文件夹拷贝到third_party下 ``` - cp ~/tpc_c_cplusplus/zstd ~/openharmony/third_party/ -rf + cp ~/tpc_c_cplusplus/thirdparty/zstd ~/openharmony/third_party/ -rf ``` ## 准备三方库源码 - 将源码下载到zstd目录并将其解压出来。 diff --git a/thirdparty_template/README_zh.md b/thirdparty_template/README_zh.md deleted file mode 100755 index 1c4bcf566c5816e0b15563a0ad570f478e10ea7e..0000000000000000000000000000000000000000 --- a/thirdparty_template/README_zh.md +++ /dev/null @@ -1,21 +0,0 @@ -# xxx 三方库说明 -## 功能简介 -这个是xxx, 主要功能是xxx,简单的一句话介绍 -## 使用约束 - -- IDE版本: - -- ROM版本: - -- API版本: - -- 三方库版本: - -- 当前适配的功能:完成了xxx功能的适配 - -- [License:xxx]()(链接指向源三方库中的license) - -## 集成方式 - -+ [系统Rom包集成](docs/rom_integrate.md) -+ [应用Hap包集成](docs/hap_integrate.md) diff --git a/thirdparty_template/ohos.build b/thirdparty_template/ohos.build deleted file mode 100755 index e955101a737592e237388a8aca36ad2c299d18b2..0000000000000000000000000000000000000000 --- a/thirdparty_template/ohos.build +++ /dev/null @@ -1,9 +0,0 @@ -{ - "subsystem": "thirdparty", - "parts":{ - "xxx": { - "module_list": [ - ] - } - } -} \ No newline at end of file diff --git a/tools/Buildtools/README.md b/tools/Buildtools/README.md new file mode 100755 index 0000000000000000000000000000000000000000..11dbcc1f8870b63c20755a629cc1be6ab268e742 --- /dev/null +++ b/tools/Buildtools/README.md @@ -0,0 +1,25 @@ +## 下载ohos sdk +[参考OHOS_SDK-Usage](../doc/ohos_use_sdk/OHOS_SDK-Usage.md) + +## 配置环境变量 +```shell + # 此处是我的ohos sdk解压目录, 使用者需自行配置自己的目录 + export OHOS_SDK=/home/ohos/tools/OH_SDK/ohos-sdk/linux +``` + +## 拷贝编译工具 +``` + # 校验压缩包 + sha512sum -c SHA512SUM + #输出 toolchain.tar.gz: OK + # 解压拷贝编译工具 + tar -zxvf toolchain.tar.gz + cp toolchain/* ${OHOS_SDK}/native/llvm/bin +``` + +## 设置ohos编译宏 +由于 ohos_sdk 没有为OpenHarmony提供系统识别的宏,因此我们需要在 ${OHOS_SDK}/native/build/cmake/ohos.toolchain.cmake 文件末尾,添加 +``` + add_definitions(-DOHOS_NDK) +``` +用于系统识别 \ No newline at end of file diff --git a/tools/Buildtools/SHA512SUM b/tools/Buildtools/SHA512SUM new file mode 100755 index 0000000000000000000000000000000000000000..08d6dc6b692f5f0eb63e45ee9fb9c32ed7de9cac --- /dev/null +++ b/tools/Buildtools/SHA512SUM @@ -0,0 +1 @@ +392ced3d95dec1be7354eb4d530df2bb3a1798da327b133592646ea6040841f1645a4690309ce72a3d0d28da083eaf53557c6345905b715083d0d9062445d4b7 toolchain.tar.gz \ No newline at end of file diff --git a/tools/Buildtools/toolchain.tar.gz b/tools/Buildtools/toolchain.tar.gz new file mode 100755 index 0000000000000000000000000000000000000000..e533e7906b07a3ba9eb61dc6ff1ce65333b1d703 Binary files /dev/null and b/tools/Buildtools/toolchain.tar.gz differ diff --git a/tools/README.md b/tools/README.md new file mode 100755 index 0000000000000000000000000000000000000000..463618a1fe6d7469d385ffb1c103323798e99b17 --- /dev/null +++ b/tools/README.md @@ -0,0 +1,48 @@ +# HPKBUILD build script! + +协助开发者, 在 OpenHarmony 系统上快速编译、验证以及长期维护 c/c++ 库. + +## 使用 + +执行脚本build.sh,自动编译main目录下的所有开源库,并打包安装到 usr\/\$pkgname-$ARCH-install 目录 +```shell + ./build.sh # 默认编译 main 目录下的多有库 +``` +```shell + ./build.sh aaa bbb ccc ... # 编译 main 目录下指定的 aaa bbb ccc ...库 当 aaa 库存在依赖时,必须保证入参中包含依赖,否则 aaa 库不会编译 +``` +## 原则 + +**移植过程,不可以改源码(即不patchc/cpp文件,不patch构建脚本)。如移植必须patch,patch必须评审,给出充分理由。(不接受业务patch)** + +## 如何贡献 + +### 编译环境准备 + +请阅读 [Buildtools README](./Buildtools/README.md) + +### HPKBUILD 编写说明 + +请阅读 [template README](./template/README.md) + +### CI环境准备 + +请阅读 [CItools README](https://gitee.com/han_jin_fei/lycium-citools) + +### 测试通过即可提交PR,附带测试成功的截屏 + +## 介绍 + +Buildtools: 存放编译环境准备说明 + +main: 被移植构建的库信息存放的目录 + +script: 项目依赖的脚本 + +template: main 目录中库的构建模板 + +build.sh: 顶层构建脚本 + +## TODO +支持同一个库,不同版本的编译 + 1.库的依赖也可添加依赖的版本,实际版本大于等于依赖时,才可以编译 diff --git a/tools/build.sh b/tools/build.sh new file mode 100755 index 0000000000000000000000000000000000000000..073347705c80cac5846e9fdaef4cb62d82905abc --- /dev/null +++ b/tools/build.sh @@ -0,0 +1,202 @@ +#!/bin/bash + +jobFlag=true +checkbuildenv(){ + if [ -z ${OHOS_SDK} ] + then + echo "OHOS_SDK 未设置,请先下载安装ohos SDK,并设置OHOS_SDK环境变量。" + exit 1 + fi + echo "OHOS_SDK="${OHOS_SDK} + which cmake >/dev/null 2>&1 + if [ $? -ne 0 ] + then + echo "cmake 命令未安装,请先安装jq命令" + exit 1 + fi + echo "cmake 命令已安装" + which make >/dev/null 2>&1 + if [ $? -ne 0 ] + then + echo "make 命令未安装,请先安装jq命令" + exit 1 + fi + echo "make 命令已安装" + which autoreconf >/dev/null 2>&1 + if [ $? -ne 0 ] + then + echo "autoreconf 命令未安装,请先安装jq命令" + exit 1 + fi + echo "autoreconf 命令已安装" + which patch >/dev/null 2>&1 + if [ $? -ne 0 ] + then + echo "patch 命令未安装,请先安装jq命令" + exit 1 + fi + echo "patch 命令已安装" + if [ ! -d `pwd`/usr ] + then + echo "创建 `pwd`/usr 目录" + mkdir -p `pwd`/usr + fi + +} + +hpkPaths=() +donelist=() +donelibs=() +readdonelibs() { + if [ -f $1 ] + then + count=0 + while read line + do + doneflags=false + libinfos=(${line//,/ }) + libname=${libinfos[0]} + for lib in ${donelibs[@]} + do + if [ $lib == $libname ] + then + doneflags=true + fi + done + if ! $doneflags + then + donelibs[$count]=$libname + count=$((count+1)) + fi + + done < $1 + fi + donelist=(${donelibs[@]}) +} + +makelibsdir(){ + jobs=($*) + for job in ${jobs[@]} + do + doneflags=false + for donelib in ${donelibs[@]} + do + if [ $donelib == $job ] + then + doneflags=true + fi + done + if $doneflags + then + continue + fi + tmppath=`pwd`/main/$job + if [ -d $tmppath ] + then + hpkPaths[${#hpkPaths[@]}]=$tmppath + fi + done +} + +# 找到main目录下的所有目录 +# 参数1 为项目根路径 +findmainhpkdir(){ + # hpkPaths=`find $1 -maxdepth 1 -type d` + # # echo $hpkPaths + # # remove root dir + # hpkPaths=(${hpkPaths[*]/$1}) + + tmplibs=() + for file in $(ls $1) + do + if [ -d $1/$file ] + then + tmplibs[${#tmplibs[@]}]=$file + fi + done + makelibsdir ${tmplibs[@]} +} + +# 进入每一个目录 将script 目录下的脚本都链接过去 +prepareshell(){ + for hpkdir in ${hpkPaths[@]} + do + cd $hpkdir + ln -fs `pwd`/../../script/build_hpk.sh build_hpk.sh + ln -fs `pwd`/../../script/envset.sh envset.sh + cd ${OLDPWD} + done +} + +# 恢复脚本 +cleanhpkdir(){ + for hpkdir in ${hpkPaths[@]} + do + cd $hpkdir + rm build_hpk.sh envset.sh + cd ${OLDPWD} + done +} + +# 编译库本身 +nextroundlist=() +notdonelist=() +buildhpk(){ + nextroundlist=(${hpkPaths[*]}) + + while $jobFlag + do + lastroundlen=${#nextroundlist[*]} + notdonelist=(${nextroundlist[*]}) + nextroundlist=() + len=${#notdonelist[*]} + for ((i=0; i < $len; i=i+1)) + do + cd ${notdonelist[$i]} + bash ${PWD}/build_hpk.sh "${donelist[*]}" # > blackhole.log 2>&1 #入参已经完成的list + res=$? + if [ $res -eq 0 ] + then + donelist[${#donelist[@]}]=${notdonelist[$i]##*/} + elif [ $res -eq 101 ] + then + nextroundlist[${#nextroundlist[@]}]=${notdonelist[$i]} + else + echo "${notdonelist[$i]} build ERROR" + fi + cd ${OLDPWD} + done + if [ ${#nextroundlist[*]} -eq 0 ] + then + echo "ALL JOBS DONE!!!" + break + fi + if [ $lastroundlen -eq ${#nextroundlist[*]} ] + then + echo "Please check the dependencies of these items:" + echo " "${nextroundlist[*]} + jobFlag=false + fi + done +} + +main(){ + checkbuildenv + + readdonelibs "`pwd`/usr/hpk_build.csv" + + if [ $# -ne 0 ] + then + makelibsdir $* + else + findmainhpkdir ${PWD}/main + # exit 2 + fi + + prepareshell + buildhpk + + cleanhpkdir +} + +main $* diff --git a/tools/doc/cmake_specification.md b/tools/doc/cmake_specification.md new file mode 100755 index 0000000000000000000000000000000000000000..079e138fa2d03f88c0f180ac7b0076e63ef0795c --- /dev/null +++ b/tools/doc/cmake_specification.md @@ -0,0 +1,74 @@ +CMAKE 规范 + +1. CMakeLists.txt 只能作为cmake的文件名 + +2. add_subdirectory()只能添加当前目录子目录,不能添加当前目录的父目录,兄目录,孙目录 + +3. 顶层CMakeLists.txt所在的目录必须包含本工程所有的源码,不能访问该目录以外的源码 + +4. cmake脚本必须以 .cmake 结尾 # ***.cmake 为cmake脚本 cjsonconfigure.cmake + +5. cmake脚本中不可以调用CMakeLists.txt # include(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt) + +6. 不可以再cmake脚本中调用add_subdirectory(),隐藏了代码的物理结构 + +7. 同一个代码库中相同部署关系的不同模块,使用同一个CMake工程 + +8. 支持通过find_package()机制访问发布件 + +9. cmake命令小写,属性大写 + +10. 自定义变量名禁止 CMAKE 开头 + +11. 明确写出target依赖,不要使用通配符 + +12. 不使用过时以及未公开的cmake命令 cmake_minimum_required(VERSION 3.4.1) + +13. 路径变量采用完整路径,不要相对路径 + + set(XXX ${CMAKE_CURRENT_SOURCE_DIR }/x.cpp) + + CMAKE_SOURCE_DIR 表示代码根路径,即顶层CMakeLists.txt所在路径 + + CMAKE_CURRENT_SOURCE_DIR 当前CMakeLists.txt所在路径 + + CMAKE_BINARY_DIR 目标文件根目录,cmake的执行目录 + + CMAKE_CURRENT_BINARY_DIR 当前目标文件路径 + + CMAKE_CURRENT_LIST_DIR 当前脚本文件路径 + +14. 优先使用target_*** 命令 + + target_compile_definitions + + target_compile_features **在CMAKE_C_COMPILE_FEATURES,CMAKE_CUDA_COMPILE_FEATURES或CMAKE_CXX_COMPILE_FEATURES内** + + target_compile_options + + target_include_directories + + target_link_directories + + target_link_libraries + + target_link_options + + target_sources + +15. target_link_libraries() 显示声明库的依赖关系和PRIVATE/PUBLIC/INTERFACE属性 + + PRIVATE: + + PUBLIC: + + INTERFACE: + +16. add_libray 函数使用 + + add_libray(targetName [STATIC | SHARED | MODULE]) + + add_libray(targetName INTERFACE) + + add_libray(targetName IMPORTED) + diff --git a/tools/doc/ohos_use_sdk/OHOS_SDK-Usage--depend-libs.md b/tools/doc/ohos_use_sdk/OHOS_SDK-Usage--depend-libs.md new file mode 100755 index 0000000000000000000000000000000000000000..486c64807f7c86255e6cb5d005536083090c51e1 --- /dev/null +++ b/tools/doc/ohos_use_sdk/OHOS_SDK-Usage--depend-libs.md @@ -0,0 +1,272 @@ +# OpenHarmony Linux 环境 SDK 使用说明(进阶--依赖库的解决方法) + +​ 我们在移植三方库的时候,很多库是有依赖的。面对这种情况我们应该如何处理。下面以libzip为例讲解下如何为ohos编译带依赖的库。 + +## 编译libzip + +### 源码准备 + +下载最新版本的 libzip 和 xz (libzip 是可以依赖 xz 项目中的 liblzma.so 的) + +```shell +#解压源码 +ohos@ubuntu20:~/openHarmony/ohos_libzip$ ls +libzip-1.9.2.tar.gz xz-5.4.1.tar.gz +ohos@ubuntu20:~/openHarmony/ohos_libzip$ +ohos@ubuntu20:~/openHarmony/ohos_libzip$ tar -zxf xz-5.4.1.tar.gz +ohos@ubuntu20:~/openHarmony/ohos_libzip$ tar -zxf libzip-1.9.2.tar.gz +ohos@ubuntu20:~/openHarmony/ohos_libzip$ ls +libzip-1.9.2 libzip-1.9.2.tar.gz xz-5.4.1 xz-5.4.1.tar.gz +ohos@ubuntu20:~/openHarmony/ohos_libzip$ +``` + +### 编译libzip + +``` +ohos@ubuntu20:~/openHarmony/ohos_libzip$ +ohos@ubuntu20:~/openHarmony/ohos_libzip$ export OHOS_SDK=/home/ohos/tools/OH_SDK/ohos-sdk/linux +ohos@ubuntu20:~/openHarmony/ohos_libzip$ cd libzip-1.9.2/ +ohos@ubuntu20:~/openHarmony/ohos_libzip/libzip-1.9.2$ ls +android AUTHORS cmake-config.h.in examples libzip-config.cmake.in man regress THANKS +API-CHANGES.md cmake CMakeLists.txt INSTALL.md libzip.pc.in NEWS.md SECURITY.md TODO.md +appveyor.yml cmake-compat cmake-zipconf.h.in lib LICENSE README.md src +ohos@ubuntu20:~/openHarmony/ohos_libzip/libzip-1.9.2$ mkdir ohos64build +ohos@ubuntu20:~/openHarmony/ohos_libzip/libzip-1.9.2$ cd ohos64build/ +ohos@ubuntu20:~/openHarmony/ohos_libzip/libzip-1.9.2/ohos64build$ ${OHOS_SDK}/native/build-tools/cmake/bin/cmake -DCMAKE_TOOLCHAIN_FILE=${OHOS_SDK}/native/build/cmake/ohos.toolchain.cmake .. -L +-- The C compiler identification is Clang 12.0.1 +-- Check for working C compiler: /home/ohos/tools/OH_NDK/ohos-sdk/linux/native/llvm/bin/clang +-- Check for working C compiler: /home/ohos/tools/OH_NDK/ohos-sdk/linux/native/llvm/bin/clang -- works +-- Detecting C compiler ABI info +-- Detecting C compiler ABI info - done +-- Detecting C compile features +-- Detecting C compile features - done +-- Looking for include file CommonCrypto/CommonCrypto.h +-- Looking for include file CommonCrypto/CommonCrypto.h - not found +-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") +-- Could NOT find Nettle (missing: Nettle_LIBRARY Nettle_INCLUDE_DIR) (Required is at least version "3.0") +-- Could NOT find GnuTLS (missing: GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR) +-- Could NOT find MbedTLS (missing: MbedTLS_LIBRARY MbedTLS_INCLUDE_DIR) (Required is at least version "1.0") +# 删除大量日志 +-- Check if the system is big endian - little endian +-- Found ZLIB: /home/ohos/tools/OH_NDK/ohos-sdk/linux/native/sysroot/usr/lib/aarch64-linux-ohos/libz.so (found suitable version "1.2.12", minimum required is "1.1.2") +-- Could NOT find BZip2 (missing: BZIP2_LIBRARIES BZIP2_INCLUDE_DIR) +CMake Warning at CMakeLists.txt:186 (message): + -- bzip2 library not found; bzip2 support disabled + +# 可以发现此时是无法找到 liblzma 的,这样虽然没有报错,但是编译出来的libzip是不支持 lzma 算法的。为了使我们编译出来的libzip支持lamz算法,我们希望这里能找到liblzma.so +-- Could NOT find LibLZMA (missing: LIBLZMA_LIBRARY LIBLZMA_INCLUDE_DIR LIBLZMA_HAS_AUTO_DECODER LIBLZMA_HAS_EASY_ENCODER LIBLZMA_HAS_LZMA_PRESET) (Required is at least version "5.2") +CMake Warning at CMakeLists.txt:195 (message): + -- lzma library not found; lzma/xz support disabled + + +-- Could NOT find Zstd (missing: Zstd_LIBRARY Zstd_INCLUDE_DIR) (Required is at least version "1.3.6") +CMake Warning at CMakeLists.txt:204 (message): + -- zstd library not found; zstandard support disabled + + +CMake Warning at CMakeLists.txt:226 (message): + -- neither Common Crypto, GnuTLS, mbed TLS, OpenSSL, nor Windows + Cryptography found; AES support disabled + + +-- Looking for getopt +-- Looking for getopt - found +-- Found Perl: /usr/local/bin/perl (found version "5.34.1") +-- Configuring done +-- Generating done +-- Build files have been written to: /home/ohos/openHarmony/ohos_libzip/libzip-1.9.2/ohos64build +-- Cache values +BUILD_DOC:BOOL=ON +BUILD_EXAMPLES:BOOL=ON +BUILD_REGRESS:BOOL=ON +BUILD_SHARED_LIBS:BOOL=ON +BUILD_TOOLS:BOOL=ON +CMAKE_ASM_FLAGS:STRING= +CMAKE_ASM_FLAGS_DEBUG:STRING= +CMAKE_ASM_FLAGS_RELEASE:STRING= +CMAKE_BUILD_TYPE:STRING= +CMAKE_CXX_FLAGS:STRING= +CMAKE_CXX_FLAGS_DEBUG:STRING= +CMAKE_CXX_FLAGS_RELEASE:STRING= +CMAKE_INSTALL_PREFIX:PATH=/usr/local +CMAKE_TOOLCHAIN_FILE:FILEPATH=/home/ohos/tools/OH_SDK/ohos-sdk/linux/native/build/cmake/ohos.toolchain.cmake +DOCUMENTATION_FORMAT:STRING=mdoc +ENABLE_BZIP2:BOOL=ON +ENABLE_COMMONCRYPTO:BOOL=ON +ENABLE_GNUTLS:BOOL=ON +ENABLE_LZMA:BOOL=ON +ENABLE_MBEDTLS:BOOL=ON +ENABLE_OPENSSL:BOOL=ON +ENABLE_WINDOWS_CRYPTO:BOOL=ON +ENABLE_ZSTD:BOOL=ON +LIBZIP_DO_INSTALL:BOOL=ON +MDOCTOOL:FILEPATH=/usr/bin/groff +SHARED_LIB_VERSIONNING:BOOL=ON +ohos@ubuntu20:~/openHarmony/ohos_libzip/libzip-1.9.2/ohos64build$ +``` + +### 解决依赖无法找到的问题 + +#### 先编译安装 xz + +``` +ohos@ubuntu20:~/openHarmony/ohos_libzip$ cd xz-5.4.1/ +ohos@ubuntu20:~/openHarmony/ohos_libzip/xz-5.4.1$ mkdir ohos64build +ohos@ubuntu20:~/openHarmony/ohos_libzip/xz-5.4.1$ cd ohos64build/ +ohos@ubuntu20:~/openHarmony/ohos_libzip/xz-5.4.1/ohos64build$ ${OHOS_SDK}/native/build-tools/cmake/bin/cmake -DCMAKE_TOOLCHAIN_FILE=${OHOS_SDK}/native/build/cmake/ohos.toolchain.cmake .. -L -DCMAKE_INSTALL_PREFIX=`pwd`/../../usr/ -DBUILD_SHARED_LIBS=ON + # 指定安装目录为~/openHarmony/ohos_libzip/usr +-- The C compiler identification is Clang 12.0.1 +-- Check for working C compiler: /home/ohos/tools/OH_SDK/ohos-sdk/linux/native/llvm/bin/clang +-- Check for working C compiler: /home/ohos/tools/OH_SDK/ohos-sdk/linux/native/llvm/bin/clang -- works +-- Detecting C compiler ABI info +-- Detecting C compiler ABI info - done +-- Detecting C compile features +# 删除大量 cmake 日志 +CMAKE_CXX_FLAGS_RELEASE:STRING= +CMAKE_INSTALL_PREFIX:PATH=/home/ohos/openHarmony/ohos_libzip/usr +CMAKE_TOOLCHAIN_FILE:FILEPATH=/home/ohos/tools/OH_SDK/ohos-sdk/linux/native/build/cmake/ohos.toolchain.cmake +CREATE_LZMA_SYMLINKS:BOOL=ON +CREATE_XZ_SYMLINKS:BOOL=ON +TUKLIB_FAST_UNALIGNED_ACCESS:BOOL=ON +TUKLIB_USE_UNSAFE_TYPE_PUNNING:BOOL=OFF +liblzma_INSTALL_CMAKEDIR:STRING=lib/cmake/liblzma +ohos@ubuntu20:~/openHarmony/ohos_libzip/xz-5.4.1/ohos64build$ +ohos@ubuntu20:~/openHarmony/ohos_libzip/xz-5.4.1/ohos64build$ make -j4 +Scanning dependencies of target lzcat.1 +Scanning dependencies of target xzcat.1 +Scanning dependencies of target unlzma.1 +Scanning dependencies of target liblzma +[ 0%] Built target lzcat.1 +[ 0%] Built target xzcat.1 +#删除大量 make 日志 +[100%] Built target lzma +Scanning dependencies of target unlzma +[100%] Built target unlzma +ohos@ubuntu20:~/openHarmony/ohos_libzip/xz-5.4.1/ohos64build$ make install +[ 65%] Built target liblzma +[ 66%] Built target test_vli +#删除大量 make install 日志 +-- Installing: /home/ohos/openHarmony/ohos_libzip/usr/share/man/man1/lzcat.1 +ohos@ubuntu20:~/openHarmony/ohos_libzip/xz-5.4.1/ohos64build$ +#检查编译好的 liblzma 库 +ohos@ubuntu20:~/openHarmony/ohos_libzip/xz-5.4.1/ohos64build$ ls ../../usr/ +bin include lib share +ohos@ubuntu20:~/openHarmony/ohos_libzip/xz-5.4.1/ohos64build$ cd ../../usr/lib/ +ohos@ubuntu20:~/openHarmony/ohos_libzip/usr/lib$ file * +cmake: directory +liblzma.a: current ar archive +liblzma.so: symbolic link to liblzma.so.5 +liblzma.so.5: symbolic link to liblzma.so.5.4.1 +liblzma.so.5.4.1: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=709b7d1f2a5caf197f168982bf374638b8479a3e, with debug_info, not stripped +ohos@ubuntu20:~/openHarmony/ohos_libzip/usr/lib$ +``` + +#### 再次编译 libzip + +``` + +ohos@ubuntu20:~/openHarmony/ohos_libzip/usr/lib$ cd ../../libzip-1.9.2/ohos64build/ +ohos@ubuntu20:~/openHarmony/ohos_libzip/libzip-1.9.2/ohos64build$ ls +CMakeCache.txt cmake_install.cmake config.h examples libzip-config.cmake libzip.pc Makefile regress zipconf.h +CMakeFiles compile_commands.json CTestTestfile.cmake lib libzip-config-version.cmake libzip-targets.cmake man src +ohos@ubuntu20:~/openHarmony/ohos_libzip/libzip-1.9.2/ohos64build$ rm * -rf +ohos@ubuntu20:~/openHarmony/ohos_libzip/libzip-1.9.2/ohos64build$ ${OHOS_SDK}/native/build-tools/cmake/bin/cmake -DCMAKE_TOOLCHAIN_FILE=${OHOS_SDK}/native/build/cmake/ohos.toolchain.cmake .. -L -DCMAKE_INSTALL_PREFIX=`pwd`/../../usr/ -DCMAKE_FIND_ROOT_PATH=`pwd`/../../usr +#-DCMAKE_INSTALL_PREFIX= 指定了libzip编译好后的安装目录 +#-DCMAKE_FIND_ROOT_PATH= 指定了cmake find package 的路径,如果有多个需要用";"隔开 +-- The C compiler identification is Clang 12.0.1 +-- Check for working C compiler: /home/ohos/tools/OH_SDK/ohos-sdk/linux/native/llvm/bin/clang +-- Check for working C compiler: /home/ohos/tools/OH_SDK/ohos-sdk/linux/native/llvm/bin/clang -- works +# 删除大量 cmake 日志 +-- Check if the system is big endian - little endian +-- Found ZLIB: /home/ohos/tools/OH_SDK/ohos-sdk/linux/native/sysroot/usr/lib/aarch64-linux-ohos/libz.so (found suitable version "1.2.12", minimum required is "1.1.2") +-- Could NOT find BZip2 (missing: BZIP2_LIBRARIES BZIP2_INCLUDE_DIR) +CMake Warning at CMakeLists.txt:186 (message): + -- bzip2 library not found; bzip2 support disabled +CHECK_STARTLooking for lzma_auto_decoder in /home/ohos/openHarmony/ohos_libzip/libzip-1.9.2/ohos64build/../../usr/lib/liblzma.so +CHECK_PASSfound +CHECK_STARTLooking for lzma_easy_encoder in /home/ohos/openHarmony/ohos_libzip/libzip-1.9.2/ohos64build/../../usr/lib/liblzma.so +CHECK_PASSfound +CHECK_STARTLooking for lzma_lzma_preset in /home/ohos/openHarmony/ohos_libzip/libzip-1.9.2/ohos64build/../../usr/lib/liblzma.so +CHECK_PASSfound +# 日志显示找到了 liblzma 并满足版本要求 +-- Found LibLZMA: /home/ohos/openHarmony/ohos_libzip/libzip-1.9.2/ohos64build/../../usr/lib/liblzma.so (found suitable version "5.4.1", minimum required is "5.2") +-- Could NOT find Zstd (missing: Zstd_LIBRARY Zstd_INCLUDE_DIR) (Required is at least version "1.3.6") +CMake Warning at CMakeLists.txt:204 (message): + -- zstd library not found; zstandard support disabled + + +CMake Warning at CMakeLists.txt:226 (message): + -- neither Common Crypto, GnuTLS, mbed TLS, OpenSSL, nor Windows + Cryptography found; AES support disabled + + +-- Looking for getopt +-- Looking for getopt - found +-- Found Perl: /usr/local/bin/perl (found version "5.34.1") +# 删除大量 cmake 日志 +MDOCTOOL:FILEPATH=/usr/bin/groff +SHARED_LIB_VERSIONNING:BOOL=ON +ohos@ubuntu20:~/openHarmony/ohos_libzip/libzip-1.9.2/ohos64build$ +ohos@ubuntu20:~/openHarmony/ohos_libzip/libzip-1.9.2/ohos64build$ make -j && make install +Scanning dependencies of target nonrandomopen +Scanning dependencies of target man +Scanning dependencies of target liboverride +Scanning dependencies of target testinput +Scanning dependencies of target zip +[ 1%] Preparing ZIP_SOURCE_GET_ARGS.3 +# 删除大量的 make && make install 日志 +-- Installing: /home/ohos/openHarmony/ohos_libzip/usr/bin/zipcmp +-- Set runtime path of "/home/ohos/openHarmony/ohos_libzip/usr/bin/zipcmp" to "/home/ohos/openHarmony/ohos_libzip/usr/lib" +-- Installing: /home/ohos/openHarmony/ohos_libzip/usr/bin/zipmerge +-- Set runtime path of "/home/ohos/openHarmony/ohos_libzip/usr/bin/zipmerge" to "/home/ohos/openHarmony/ohos_libzip/usr/lib" +-- Installing: /home/ohos/openHarmony/ohos_libzip/usr/bin/ziptool +-- Set runtime path of "/home/ohos/openHarmony/ohos_libzip/usr/bin/ziptool" to "/home/ohos/openHarmony/ohos_libzip/usr/lib" +ohos@ubuntu20:~/openHarmony/ohos_libzip/libzip-1.9.2/ohos64build$ +# 检查编译出的libzip +ohos@ubuntu20:~/openHarmony/ohos_libzip/libzip-1.9.2/ohos64build$ cd ../../usr/ +ohos@ubuntu20:~/openHarmony/ohos_libzip/usr$ ls +bin include lib share +ohos@ubuntu20:~/openHarmony/ohos_libzip/usr$ ls bin/ +lzcat lzma unlzma unxz xz xzcat xzdec zipcmp zipmerge ziptool +ohos@ubuntu20:~/openHarmony/ohos_libzip/usr$ ls lib/ +cmake liblzma.a liblzma.so liblzma.so.5 liblzma.so.5.4.1 libzip.so libzip.so.5 libzip.so.5.5 pkgconfig +ohos@ubuntu20:~/openHarmony/ohos_libzip/usr$ file lib/libzip.so.5.5 +lib/libzip.so.5.5: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=0a2918c4f372d034a02297310869a18d9dd2ae1a, with debug_info, not stripped +ohos@ubuntu20:~/openHarmony/ohos_libzip/usr$ readelf -d lib/libzip.so.5.5 + +Dynamic section at offset 0x1fff8 contains 28 entries: + Tag Type Name/Value + 0x000000000000001d (RUNPATH) Library runpath: [/home/ohos/openHarmony/ohos_libzip/usr/lib] + 0x0000000000000001 (NEEDED) Shared library: [liblzma.so.5] # 可以看到 liblzma.so.5 是 NEEDED + 0x0000000000000001 (NEEDED) Shared library: [libz.so] + 0x0000000000000001 (NEEDED) Shared library: [libc.so] + 0x000000000000000e (SONAME) Library soname: [libzip.so.5] + 0x000000000000001e (FLAGS) BIND_NOW + 0x000000006ffffffb (FLAGS_1) Flags: NOW + 0x0000000000000007 (RELA) 0x28a0 + 0x0000000000000008 (RELASZ) 3120 (bytes) + 0x0000000000000009 (RELAENT) 24 (bytes) + 0x000000006ffffff9 (RELACOUNT) 123 + 0x0000000000000017 (JMPREL) 0x34d0 + 0x0000000000000002 (PLTRELSZ) 2760 (bytes) + 0x0000000000000003 (PLTGOT) 0x22220 + 0x0000000000000014 (PLTREL) RELA + 0x0000000000000006 (SYMTAB) 0x2a8 + 0x000000000000000b (SYMENT) 24 (bytes) + 0x0000000000000005 (STRTAB) 0x1ca8 + 0x000000000000000a (STRSZ) 3060 (bytes) + 0x000000006ffffef5 (GNU_HASH) 0x13a0 + 0x0000000000000004 (HASH) 0x16f8 + 0x0000000000000019 (INIT_ARRAY) 0x21c90 + 0x000000000000001b (INIT_ARRAYSZ) 8 (bytes) + 0x000000000000001a (FINI_ARRAY) 0x21c98 + 0x000000000000001c (FINI_ARRAYSZ) 16 (bytes) + 0x000000000000000c (INIT) 0x2051c + 0x000000000000000d (FINI) 0x2052c + 0x0000000000000000 (NULL) 0x0 +ohos@ubuntu20:~/openHarmony/ohos_libzip/usr$ +``` + +完成。 + +大家可以自己试试 zstd openssl 等库的依赖实现。 \ No newline at end of file diff --git a/tools/doc/ohos_use_sdk/OHOS_SDK-Usage.md b/tools/doc/ohos_use_sdk/OHOS_SDK-Usage.md new file mode 100755 index 0000000000000000000000000000000000000000..11d7f14429f930c01bb1f71ab32f1ef8ed468afa --- /dev/null +++ b/tools/doc/ohos_use_sdk/OHOS_SDK-Usage.md @@ -0,0 +1,369 @@ +Linux 环境下 使用 OpenHarmony SDK 编译,OpenHarmony standard 系统北向应用 c/c++ 库 + +## OpenHarmony Linux 环境 SDK 使用说明 + +### 下载SDK + +​ 从 openHarmony SDK [官方发布渠道](https://gitee.com/openharmony-sig/oh-inner-release-management/blob/master/Release-Testing-Version.md)(13b8b5812ce3b3b135743baa6629ed84bd380d8c)下载SDK + +![](./ohos_sdk下载.png) + +​ 可以同时下载对应的系统镜像(这里提供的是 32bit OHOS 镜像下载),后面依次为 Windows/Linux 环境下的 SDK,SDK 分为两个版本 full 版本和 public 版本。这两个版本的 SDK 中关于 c/c++ 编译的部分是相同的,因此我们下载那个都一样( full 版本的 SDK 在 ets 层提供了更多的 API )。再后面是 mac 环境的OHOS SDK 。根据自己环境自行下载对应版本的 SDK 。 + +### 解压SDK + +```shell + tar -zxvf version-Master_Version-OpenHarmony_3.2.10.3-20230105_163913-ohos-sdk-full.tar.gz +``` + +进入解压得到 ohos_sdk 目录,可以看到 Linux 和 windows 两个平台的 SDK 目录,我们进入 linux。 + +``` +ohos@ubuntu20:~/tools/OH_SDK$ cd ohos-sdk +ohos@ubuntu20:~/tools/OH_SDK/ohos-sdk$ ls +linux windows +ohos@ubuntu20:~/tools/OH_SDK/ohos-sdk$ cd linux/ +ohos@ubuntu20:~/tools/OH_SDK/ohos-sdk/linux$ ls +ets-linux-x64-4.0.1.2-Canary1.zip native-linux-x64-4.0.1.2-Canary1.zip toolchains-linux-x64-4.0.1.2-Canary1.zip +js-linux-x64-4.0.1.2-Canary1.zip previewer-linux-x64-4.0.1.2-Canary1.zip +``` + +解压 Linux 环境下的 OHOS SDK 工具包,得到对应的工具目录。由于我们是 c/c++ 库的编译,我们只关注 native 目录。 + +```shell +ohos@ubuntu20:~/tools/OH_SDK/ohos-sdk/linux$ for i in *.zip;do unzip ${i};done +ohos@ubuntu20:~/tools/OH_SDK/ohos-sdk/linux$ ls +ets native toolchains +ets-linux-x64-4.0.1.2-Canary1.zip native-linux-x64-4.0.1.2-Canary1.zip toolchains-linux-x64-4.0.1.2-Canary1.zip +js previewer +js-linux-x64-4.0.1.2-Canary1.zip previewer-linux-x64-4.0.1.2-Canary1.zip +``` + +### native 目录介绍 + +```sh +ohos@ubuntu20:~/tools/OH_SDK/ohos-sdk/linux$ cd native/ +ohos@ubuntu20:~/tools/OH_SDK/ohos-sdk/linux/native$ ls +build docs nativeapi_syscap_config.json NOTICE.txt sysroot +build-tools llvm ndk_system_capability.json oh-uni-package.json +``` + +build 目录存放的是 构建时 cmake 依赖的配置文件 + +build-tools 目录存放的是 构建工具包含 cmake 和 ninja,我们后面采用 make 进行构建。 + +docs 目录存放 使用说明 + +llvm 目录存放 clang 编译器 + +sysroot 目录为编译器的 sysroot 目录,存放 SDK 内部的已经包含的库和对应的头文件 + +oh-uni-package.json 为 SDK 信息描述,如版本 + +NOTICE.txt 为注意事项,内容多为 SDK 的详细描述 + +ndk_system_capability.json 记录 SDK 提供的能力 + +nativeapi_syscap_config.json 记录 SDK 提供的能力对应的头文件 + +**build和build-tools目录提供构建时的 cmake,ninja,以及 toolchain 依赖。llvm 提供编译工具链。sysroot 提供 usr 系统资源** + +## OHOS SDK 使用 +本片介绍基本用法, 涉及到库有依赖的情况请[移步](./OHOS_SDK-Usage--depend-libs.md). +### 编译cmake构建的库 + +​ SDK 采用 cmake 作为默认的编译脚本工具和 deveco 开发工具是一致的。并且 cmake 也是现如今 c/c++ 开发最流行的编译构建脚本。以下我使用 cjson 作为实例演示一下 OHOS SDK 构建 cmake 项目的步骤。 + +​ 首先下载/clone cJSON 源码,我这里下载的 v1.7.15 版本 + +```shell +ohos@ubuntu20:~/openHarmony$ git clone https://github.com/DaveGamble/cJSON.git -b v1.7.15 +Cloning into 'cJSON'... +remote: Enumerating objects: 4545, done. +remote: Total 4545 (delta 0), reused 0 (delta 0), pack-reused 4545 +Receiving objects: 100% (4545/4545), 2.45 MiB | 1.65 MiB/s, done. +Resolving deltas: 100% (3026/3026), done. +Note: switching to 'd348621ca93571343a56862df7de4ff3bc9b5667'. + +You are in 'detached HEAD' state. You can look around, make experimental +changes and commit them, and you can discard any commits you make in this +state without impacting any branches by switching back to a branch. + +If you want to create a new branch to retain commits you create, you may +do so (now or later) by using -c with the switch command. Example: + + git switch -c + +Or undo this operation with: + + git switch - + +Turn off this advice by setting config variable advice.detachedHead to false + +ohos@ubuntu20:~/openHarmony$ +``` + +​ 进入 cJson 目录,创建 ohos64build 目录(存放构建文件)。执行 cmake,生成 makefile + +``` +ohos@ubuntu20:~/openHarmony/cJSON/ohos64build$ /home/ohos/tools/OH_SDK/ohos-sdk/linux/native/build-tools/cmake/bin/cmake -DCMAKE_TOOLCHAIN_FILE=/home/ohos/tools/OH_SDK/ohos-sdk/linux/native/build/cmake/ohos.toolchain.cmake .. -L + # 如果需要编译静态库则需要设置 cmake 变量 -DBUILD_SHARED_LIBS=OFF + # 可以通过-DCMAKE_INSTALL_PREFIX=xxx 设置库的安装目录 + # 编译 arm32 -DOHOS_ARCH=armeabi-v7a +-- The C compiler identification is Clang 12.0.1 +-- Check for working C compiler: /home/ohos/tools/OH_SDK/ohos-sdk/linux/native/llvm/bin/clang # 采用sdk内的编译器 +-- Check for working C compiler: /home/ohos/tools/OH_SDK/ohos-sdk/linux/native/llvm/bin/clang -- works +# 删除大量 cmake 日志 +ENABLE_PUBLIC_SYMBOLS:BOOL=ON +ENABLE_SAFE_STACK:BOOL=OFF +ENABLE_SANITIZERS:BOOL=OFF +ENABLE_TARGET_EXPORT:BOOL=ON +ENABLE_VALGRIND:BOOL=OFF +ohos@ubuntu20:~/openHarmony/cJSON/ohos64build$ +``` + +​ 注意这里执行的 cmake 是 SDK 内的 cmake ,不是你自己系统上原有的 cmake 。包括 toolchain file 也是 SDK 内的。执行 make 即可编译出 cjson 库 + +``` +ohos@ubuntu20:~/openHarmony/cJSON/ohos64build$ make +Scanning dependencies of target cjson +[ 2%] Building C object CMakeFiles/cjson.dir/cJSON.c.o +clang: warning: argument unused during compilation: '--gcc-toolchain=/home/ohos/tools/OH_SDK/ohos-sdk/linux/native/llvm' [-Wunused-command-line-argument] +# 删除大量 make 日志 +[100%] Linking C executable fuzz_main +[100%] Built target fuzz_main +ohos@ubuntu20:~/openHarmony/cJSON/ohos64build$ +``` + +​ 使用 file 命令,查看编译出的 elf 文件的属性。可以看到动态库和可执行程序都是 ARM aarch64 架构的。ohos cmake toolchainfile 在不设置 cpu 架构时默认为 aarch64 . 如果你需要编译 arm32 的需要在cmake时加上参数 -DOHOS_ARCH=armeabi-v7a + +```sh +ohos@ubuntu20:~/openHarmony/cJSON/ohos64build$ ls +cJSONConfig.cmake cJSON_test CMakeFiles CTestTestfile.cmake libcjson.pc libcjson.so.1 Makefile +cJSONConfigVersion.cmake CMakeCache.txt cmake_install.cmake fuzzing libcjson.so libcjson.so.1.7.15 tests +ohos@ubuntu20:~/openHarmony/cJSON/ohos64build$ file libcjson.so.1.7.15 cJSON_test +libcjson.so.1.7.15: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=98d32cd8235a77985fec1419150fe2c97c8c8c38, with debug_info, not stripped +cJSON_test: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-aarch64.so.1, BuildID[sha1]=20770aaad711d8286819f193e8d10034cdb3cedc, with debug_info, not stripped +ohos@ubuntu20:~/openHarmony/cJSON/ohos64build$ +``` + +### 编译非 cmake 构建的库 + +​ 开源社区存在着大量的非 cmake 构建的库,如何使用 OpenHarmony 的 SDK 编译它们呢? + +#### 方法1:我们可以使用 cmake 构建脚本重写开源库的构建过程 + +​ 这种方法需要分析源库的构建脚本或者分析源库的编译构建日志,我这里推荐简单点的分析构建日志(可以不必去学习 configure 的语法)。很多库为了性能一般会对代码进行处理器级的优化(SIMD: SSE,AVX; NEON),因此编译构建日志最好采用交叉编译工具链的日志,不要盲目的根据 x86_64 的构建日志进行翻译(cmake)。如果使用此方法请参考 oh 三方库 [cmake 编写指导](https://gitee.com/huangminzhong/cmake_study)及[编写规范](../cmake_specification.md)。 + +#### 方法2:使用项目原生的构建工具例如 configure、makefile + +​ 如何使用原生的构建工具?首先我们需要知道构建脚本并不是直接调用 gcc 或者 clang 编译工具链的。而是优先调用 CC 环境变量以达到调用 c 编译器的目的,对应的 CXX 环境变量对应 c++ 编译器...。等等一系列的编译工具都有自己对应的环境变量。通过设置这些环境变量,让构建工具使用 ohos SDK 的编译工具链。 + +​ 设置 ohos 64bit 库编译工具链环境变量 + +``` +#aarch64-linux-ohos +export OHOS_SDK=/home/ohos/tools/OH_SDK/ohos-sdk/linux # 此处是我的ohos_sdk解压目录,请替换为你自己的解压目录 +export AS=${OHOS_SDK}/native/llvm/bin/llvm-as +export CC="${OHOS_SDK}/native/llvm/bin/clang --target=aarch64-linux-ohos" +export CXX="${OHOS_SDK}/native/llvm/bin/clang++ --target=aarch64-linux-ohos" +export LD=${OHOS_SDK}/native/llvm/bin/ld.lld +export STRIP=${OHOS_SDK}/native/llvm/bin/llvm-strip +export RANLIB=${OHOS_SDK}/native/llvm/bin/llvm-ranlib +export OBJDUMP=${OHOS_SDK}/native/llvm/bin/llvm-objdump +export OBJCOPY=${OHOS_SDK}/native/llvm/bin/llvm-objcopy +export NM=${OHOS_SDK}/native/llvm/bin/llvm-nm +export AR=${OHOS_SDK}/native/llvm/bin/llvm-ar +export CFLAGS="-fPIC -D__MUSL__=1" +export CXXFLAGS="-fPIC -D__MUSL__=1" +``` + +​ 设置 ohos 32bit 库编译工具链环境变量 + +``` +linux-arm +export OHOS_SDK=/home/ohos/tools/OH_SDK/ohos-sdk/linux # 此处是我的ohos_sdk解压目录,请替换为你自己的解压目录 +export AS=${OHOS_SDK}/native/llvm/bin/llvm-as +export CC="${OHOS_SDK}/native/llvm/bin/clang --target=arm-linux-ohos" +export CXX="${OHOS_SDK}/native/llvm/bin/clang++ --target=arm-linux-ohos" +export LD=${OHOS_SDK}/native/llvm/bin/ld.lld +export STRIP=${OHOS_SDK}/native/llvm/bin/llvm-strip +export RANLIB=${OHOS_SDK}/native/llvm/bin/llvm-ranlib +export OBJDUMP=${OHOS_SDK}/native/llvm/bin/llvm-objdump +export OBJCOPY=${OHOS_SDK}/native/llvm/bin/llvm-objcopy +export NM=${OHOS_SDK}/native/llvm/bin/llvm-nm +export AR=${OHOS_SDK}/native/llvm/bin/llvm-ar +export CFLAGS="-fPIC -march=armv7a -D__MUSL__=1" +export CXXFLAGS="-fPIC -march=armv7a -D__MUSL__=1" +``` + + 使用unset 命令可以撤销环境变量 + +``` + unset OHOS_SDK AS CC CXX LD STRIP RANLIB OBJDUMP OBJCOPY NM AR CFLAGS CXXFLAGS +``` + + 设置好编译工具链之后,只要按照标准的 configure 用法即可. + +### 实例操作 + +​ 下面以 openssl 为例,使用 ohos 的 SDK 编译 openharmony 系统下的 openssl 库( openssl 官方仓使用 configure 编译)。 + +​ 首先下载/clone openssl 官方源码,我是用的版本为 OpenSSL_1_1_1t + +``` +ohos@ubuntu20:~/openHarmony$ git clone https://github.com/openssl/openssl.git -b OpenSSL_1_1_1t +Cloning into 'openssl'... +remote: Enumerating objects: 446051, done. +remote: Counting objects: 100% (342/342), done. +remote: Compressing objects: 100% (183/183), done. +remote: Total 446051 (delta 207), reused 259 (delta 159), pack-reused 445709 +Receiving objects: 100% (446051/446051), 272.13 MiB | 1.53 MiB/s, done. +Resolving deltas: 100% (316557/316557), done. +Note: switching to '830bf8e1e4749ad65c51b6a1d0d769ae689404ba'. + +You are in 'detached HEAD' state. You can look around, make experimental +changes and commit them, and you can discard any commits you make in this +state without impacting any branches by switching back to a branch. + +If you want to create a new branch to retain commits you create, you may +do so (now or later) by using -c with the switch command. Example: + + git switch -c + +Or undo this operation with: + + git switch - + +Turn off this advice by setting config variable advice.detachedHead to false +``` + +​ 设置需要的编译工具链环境变量,这里设置的时 ohos64bit 库的编译工具链,如果需要编译 ohos32bit 库请设置为 32bit 编译工具链 + +``` +ohos@ubuntu20:~/openHarmony/openssl$ export OHOS_SDK=/home/ohos/tools/OH_SDK/ohos-sdk/linux #这里根据自己的SDK解压目录设置 +ohos@ubuntu20:~/openHarmony/openssl$ export AS=${OHOS_SDK}/native/llvm/bin/llvm-as +ohos@ubuntu20:~/openHarmony/openssl$ export CC="${OHOS_SDK}/native/llvm/bin/clang --target=aarch64-linux-ohos" +ohos@ubuntu20:~/openHarmony/openssl$ export CXX="${OHOS_SDK}/native/llvm/bin/clang++ --target=aarch64-linux-ohos" +ohos@ubuntu20:~/openHarmony/openssl$ export LD=${OHOS_SDK}/native/llvm/bin/lld +ohos@ubuntu20:~/openHarmony/openssl$ export STRIP=${OHOS_SDK}/native/llvm/bin/llvm-strip +ohos@ubuntu20:~/openHarmony/openssl$ export RANLIB=${OHOS_SDK}/native/llvm/bin/llvm-ranlib +ohos@ubuntu20:~/openHarmony/openssl$ export OBJDUMP=${OHOS_SDK}/native/llvm/bin/llvm-objdump +ohos@ubuntu20:~/openHarmony/openssl$ export OBJCOPY=${OHOS_SDK}/native/llvm/bin/llvm-objcopy +ohos@ubuntu20:~/openHarmony/openssl$ export NM=${OHOS_SDK}/native/llvm/bin/llvm-nm +ohos@ubuntu20:~/openHarmony/openssl$ export AR=${OHOS_SDK}/native/llvm/bin/llvm-ar +ohos@ubuntu20:~/openHarmony/openssl$ export CFLAGS="-fPIC -D__MUSL__=1" +ohos@ubuntu20:~/openHarmony/openssl$ export CXXFLAGS="-fPIC -D__MUSL__=1" +``` + +​ 执行 Configure 构建脚本 + +``` +ohos@ubuntu20:~/openHarmony/openssl$ ./Configure linux-aarch64 --prefix=/home/ohos/openHarmony/openssl_instrall + # 在需要选择系统的时候由于configure不识别ohos,因此我们需要使用Linux aarch64等价系统和cpu架构 为了方便打包,需要指定安装目录 +Configuring OpenSSL version 1.1.1t (0x1010114fL) for linux-aarch64 +Using os-specific seed configuration +Creating configdata.pm +Creating Makefile + +********************************************************************** +*** *** +*** OpenSSL has been successfully configured *** +*** *** +*** If you encounter a problem while building, please open an *** +*** issue on GitHub *** +*** and include the output from the following command: *** +*** *** +*** perl configdata.pm --dump *** +*** *** +*** (If you are new to OpenSSL, you might want to consult the *** +*** 'Troubleshooting' section in the INSTALL file first) *** +*** *** +********************************************************************** +ohos@ubuntu20:~/openHarmony/openssl$ make +/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \ + "-oMakefile" include/crypto/bn_conf.h.in > include/crypto/bn_conf.h +/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \ + "-oMakefile" include/crypto/dso_conf.h.in > include/crypto/dso_conf.h +/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \ + "-oMakefile" include/openssl/opensslconf.h.in > include/openssl/opensslconf.h +make depend && make _all +make[1]: Entering directory '/home/ohos/openHarmony/openssl' +make[1]: Leaving directory '/home/ohos/openHarmony/openssl' +make[1]: Entering directory '/home/ohos/openHarmony/openssl' +/home/ohos/tools/OH_SDK/ohos-sdk/linux/native/llvm/bin/clang -I. -Iinclude -fPIC -pthread -Wa,--noexecstack -Qunused-arguments -fPIC --target=aarch64-linux-ohos -D__MUSL__=1 -DOPENSSL_USE_NODELETE -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DVPAES_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/home/ohos/openHarmony/openssl_install/ssl\"" -DENGINESDIR="\"/home/ohos/openHarmony/openssl_install/lib/engines-1.1\"" -DNDEBUG -MMD -MF apps/app_rand.d.tmp -MT apps/app_rand.o -c -o apps/app_rand.o apps/app_rand.c +# 删除大量 make 日志 +${LDCMD:-/home/ohos/tools/OH_SDK/ohos-sdk/linux/native/llvm/bin/clang} -pthread -Wa,--noexecstack -Qunused-arguments -fPIC --target=aarch64-linux-ohos -D__MUSL__=1 -L. \ + -o test/x509aux test/x509aux.o \ + test/libtestutil.a -lcrypto -ldl -pthread +/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \ + "-oMakefile" apps/CA.pl.in > "apps/CA.pl" +chmod a+x apps/CA.pl +/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \ + "-oMakefile" apps/tsget.in > "apps/tsget.pl" +chmod a+x apps/tsget.pl +/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \ + "-oMakefile" tools/c_rehash.in > "tools/c_rehash" +chmod a+x tools/c_rehash +/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \ + "-oMakefile" util/shlib_wrap.sh.in > "util/shlib_wrap.sh" +chmod a+x util/shlib_wrap.sh +make[1]: Leaving directory '/home/ohos/openHarmony/openssl' +ohos@ubuntu20:~/openHarmony/openssl$ make install +make depend && make _build_libs +make[1]: Entering directory '/home/ohos/openHarmony/openssl' +make[1]: Leaving directory '/home/ohos/openHarmony/openssl' +make[1]: Entering directory '/home/ohos/openHarmony/openssl' +make[1]: Nothing to be done for '_build_libs'. +make[1]: Leaving directory '/home/ohos/openHarmony/openssl' +created directory `/home/ohos/openHarmony/openssl_install/lib' +*** Installing runtime libraries +install libcrypto.so.1.1 -> /home/ohos/openHarmony/openssl_install/lib/libcrypto.so.1.1 +install libssl.so.1.1 -> /home/ohos/openHarmony/openssl_install/lib/libssl.so.1.1 +*** Installing development files +created directory `/home/ohos/openHarmony/openssl_install/include' +created directory `/home/ohos/openHarmony/openssl_install/include/openssl' +install ./include/openssl/aes.h -> /home/ohos/openHarmony/openssl_install/include/openssl/aes.h +install ./include/openssl/asn1.h -> /home/ohos/openHarmony/openssl_install/include/openssl/asn1.h +install ./include/openssl/asn1_mac.h -> /home/ohos/openHarmony/openssl_install/include/openssl/asn1_mac.h +# 删除大量 install 日志 +/home/ohos/openHarmony/openssl_install/share/doc/openssl/html/man7/X25519.html +/home/ohos/openHarmony/openssl_install/share/doc/openssl/html/man7/X448.html -> /home/ohos/openHarmony/openssl_install/share/doc/openssl/html/man7/X25519.html +/home/ohos/openHarmony/openssl_install/share/doc/openssl/html/man7/x509.html +ohos@ubuntu20:~/openHarmony/openssl$ +``` + +​ 安装完成后查看安装目录,可以看到可执行程序,动态库,静态库,头文件均已安装到指定目录 + +``` +ohos@ubuntu20:~/openHarmony/openssl$ cd ../openssl_install/ +ohos@ubuntu20:~/openHarmony/openssl_install$ ls +bin include lib share ssl +ohos@ubuntu20:~/openHarmony/openssl_install$ ls bin/ +c_rehash openssl +ohos@ubuntu20:~/openHarmony/openssl_install$ ls lib/ +engines-1.1 libcrypto.a libcrypto.so libcrypto.so.1.1 libssl.a libssl.so libssl.so.1.1 pkgconfig +ohos@ubuntu20:~/openHarmony/openssl_install$ ls include/ +openssl +ohos@ubuntu20:~/openHarmony/openssl_install$ ls include/openssl/ +aes.h bnerr.h comp.h dh.h engine.h md2.h opensslconf.h rand_drbg.h seed.h store.h x509.h +asn1err.h bn.h conf_api.h dsaerr.h e_os2.h md4.h opensslv.h randerr.h sha.h symhacks.h x509v3err.h +asn1.h buffererr.h conferr.h dsa.h err.h md5.h ossl_typ.h rand.h srp.h tls1.h x509v3.h +asn1_mac.h buffer.h conf.h dtls1.h evperr.h mdc2.h pem2.h rc2.h srtp.h tserr.h x509_vfy.h +asn1t.h camellia.h cryptoerr.h ebcdic.h evp.h modes.h pemerr.h rc4.h ssl2.h ts.h +asyncerr.h cast.h crypto.h ecdh.h hmac.h objectserr.h pem.h rc5.h ssl3.h txt_db.h +async.h cmac.h cterr.h ecdsa.h idea.h objects.h pkcs12err.h ripemd.h sslerr.h uierr.h +bioerr.h cmserr.h ct.h ecerr.h kdferr.h obj_mac.h pkcs12.h rsaerr.h ssl.h ui.h +bio.h cms.h des.h ec.h kdf.h ocsperr.h pkcs7err.h rsa.h stack.h whrlpool.h +blowfish.h comperr.h dherr.h engineerr.h lhash.h ocsp.h pkcs7.h safestack.h storeerr.h x509err.h +ohos@ubuntu20:~/openHarmony/openssl_install$ file lib/* +lib/engines-1.1: directory +lib/libcrypto.a: current ar archive +lib/libcrypto.so: symbolic link to libcrypto.so.1.1 +lib/libcrypto.so.1.1: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, with debug_info, not stripped +lib/libssl.a: current ar archive +lib/libssl.so: symbolic link to libssl.so.1.1 +lib/libssl.so.1.1: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, with debug_info, not stripped +lib/pkgconfig: directory + +``` diff --git "a/tools/doc/ohos_use_sdk/ohos_sdk\344\270\213\350\275\275.png" "b/tools/doc/ohos_use_sdk/ohos_sdk\344\270\213\350\275\275.png" new file mode 100755 index 0000000000000000000000000000000000000000..dae8a157f1b38d7aaa1672cc743c1579a214e276 Binary files /dev/null and "b/tools/doc/ohos_use_sdk/ohos_sdk\344\270\213\350\275\275.png" differ diff --git a/tools/script/build_hpk.sh b/tools/script/build_hpk.sh new file mode 100755 index 0000000000000000000000000000000000000000..79f5fb22952de2b093a2fa4a9cff8e380e0c6e69 --- /dev/null +++ b/tools/script/build_hpk.sh @@ -0,0 +1,175 @@ +#!/bin/bash +# 退出码检查 +sure() +{ + eval $* + err=$? + if [ "$err" != "0" ] + then + echo "ERROR during : $*" + echo "ERROR during : $* $err" > last_error + exit 1 + fi +} + +# 加载库信息 +source ${PWD}/HPKBUILD + +# 下载库压缩包 +# 参数1 链接地址 +# 参数2 压缩包名 +download() { + if [ -s ${PWD}/$2 ] + then + echo ${PWD}/$2",存在" + else + curl -f -L -- "$1" > ${PWD}/$2 + fi +} + +# 库的完整性校验 +checksum() { + sha512sum -c ${PWD}/$1 + ret=$? + if [ $ret -ne 0 ] + then + echo ${PWD}/$1" ERROR!" + echo "请检查$pkgname SHA512SUM 文件, 并重新下载src压缩包." + exit $ret + fi +} + +# 解压库 +# 参数1 压缩包名 +unpack(){ + if [ -f ${PWD}/$1 ] + then + if [[ "$1" == *.tar.gz ]] + then + echo ${PWD}/$1 + tar -zxvf ${PWD}/$1 > /dev/null + elif [[ "$1" == *.tgz ]] + then + echo ${PWD}/$1 + tar -zxvf ${PWD}/$1 > /dev/null + + elif [[ "$1" == *.tar.xz ]] + then + echo ${PWD}/$1 + tar -xvJf ${PWD}/$1 > /dev/null + elif [[ "$1" == *.tar.bz2 ]] + then + echo ${PWD}/$1 + tar -xvjf ${PWD}/$1 > /dev/null + elif [[ "$1" == *.zip ]] + then + echo ${PWD}/$1 + unzip ${PWD}/$1 > /dev/null + else + echo "ERROR Package Format!" + exit 2 + fi + else + echo "ERROR Package Not Found!" + exit 2 + fi +} + +builddepends() { + donelist=($*) + # 如果有依赖没有编译完,则跳过编译后续再次编译 + deplen=${#depends[*]} + count=0 + for depend in ${depends[@]} + do + for donelib in ${donelist[@]} + do + if [ $depend == $donelib ] + then + count=$((count+1)) + fi + done + done + if [ $count -ne $deplen ] + then + return 101 + fi + return 0 +} + +recordbuildlibs() { + echo $2,$3,$1>> `pwd`/../../usr/hpk_build.csv +} + +dependpath= +cmakedependpath() { + dependpath="-DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${OHOS_SDK}/native/build/cmake/ohos.toolchain.cmake -DCMAKE_INSTALL_PREFIX=`pwd`/../../usr/$pkgname-$1-install " + if [ ${#depends[@]} -ne 0 ] + then + tmppath="\"" + for depend in ${depends[@]} + do + tmppath=$tmppath"`pwd`/../../usr/$depend-$1-install;" + done + tmppath=$tmppath"\"" + dependpath=$dependpath"-DCMAKE_FIND_ROOT_PATH="$tmppath + fi +} +configuredependpath() { + dependpath="--prefix=`pwd`/../../usr/$pkgname-$1-install" +} + +builpackage() { + donelist=($*) + builddepends "${donelist[*]}" + if [ $? -eq 101 ] + then + echo $pkgname" not ready. wait "${depends[*]} + exit 101 + fi + echo "Build $pkgname $pkgver strat!" + if [ ! $downloadpackage ] || [ $downloadpackage != false ] + then + sure download $source $packageName + sure checksum SHA512SUM + fi + if [ ! $autounpack ] || [ $autounpack != false ] + then + sure unpack $packageName + fi + for arch in ${archs[@]} + do + echo "Compileing OpenHarmony $arch $pkgname $pkgver libs..." + ARCH=$arch + sure prepare + if [ ! $buildtools ] || [ $buildtools == "cmake" ] + then + sure cmakedependpath $ARCH + elif [ $buildtools == "configure" ] + then + sure configuredependpath $ARCH + else + echo "buildtools $buildtools, 需要用户自己传入编译参数(安装路径)" + fi + sure build $dependpath + sure package + sure check + sure recordbuildlibs $ARCH $pkgname $pkgver + done + echo "Build $pkgname $pkgver end!" +} + +cleanhpk(){ + sure cleanbuild +} + +main() { + # 根目录 + LYCIUM_ROOT=`pwd`/../.. + # 清理上次的环境 + sure cleanhpk + # 编译 PKG + sure builpackage $* +} + +main $* \ No newline at end of file diff --git a/tools/script/envset.sh b/tools/script/envset.sh new file mode 100755 index 0000000000000000000000000000000000000000..485746e02a6e06a1c56ee5674e654af05dd40203 --- /dev/null +++ b/tools/script/envset.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +setarm32ENV(){ + export AS=${OHOS_SDK}/native/llvm/bin/llvm-as + export CC=${OHOS_SDK}/native/llvm/bin/arm-linux-ohos-clang + export CXX=${OHOS_SDK}/native/llvm/bin/arm-linux-ohos-clang++ + export LD=${OHOS_SDK}/native/llvm/bin/ld.lld + export STRIP=${OHOS_SDK}/native/llvm/bin/llvm-strip + export RANLIB=${OHOS_SDK}/native/llvm/bin/llvm-ranlib + export OBJDUMP=${OHOS_SDK}/native/llvm/bin/llvm-objdump + export OBJCOPY=${OHOS_SDK}/native/llvm/bin/llvm-objcopy + export NM=${OHOS_SDK}/native/llvm/bin/llvm-nm + export AR=${OHOS_SDK}/native/llvm/bin/llvm-ar + export CFLAGS="-fPIC -march=armv7a -D__MUSL__=1" + export CXXFLAGS="-fPIC -march=armv7a -D__MUSL__=1" + export LDFLAGS="" +} + +unsetarm32ENV(){ + unset AS CC CXX LD STRIP RANLIB OBJDUMP OBJCOPY NM AR CFLAGS CXXFLAGS LDFLAGS +} + +setarm64ENV(){ + export AS=${OHOS_SDK}/native/llvm/bin/llvm-as + export CC=${OHOS_SDK}/native/llvm/bin/aarch64-linux-ohos-clang + export CXX=${OHOS_SDK}/native/llvm/bin/aarch64-linux-ohos-clang++ + export LD=${OHOS_SDK}/native/llvm/bin/ld.lld + export STRIP=${OHOS_SDK}/native/llvm/bin/llvm-strip + export RANLIB=${OHOS_SDK}/native/llvm/bin/llvm-ranlib + export OBJDUMP=${OHOS_SDK}/native/llvm/bin/llvm-objdump + export OBJCOPY=${OHOS_SDK}/native/llvm/bin/llvm-objcopy + export NM=${OHOS_SDK}/native/llvm/bin/llvm-nm + export AR=${OHOS_SDK}/native/llvm/bin/llvm-ar + export CFLAGS="-fPIC -D__MUSL__=1" + export CXXFLAGS="-fPIC -D__MUSL__=1" + export LDFLAGS="" +} + +unsetarm64ENV(){ + unset AS CC CXX LD STRIP RANLIB OBJDUMP OBJCOPY NM AR CFLAGS CXXFLAGS LDFLAGS +} diff --git a/tools/template/HPKBUILD b/tools/template/HPKBUILD new file mode 100755 index 0000000000000000000000000000000000000000..27f52b9dacbf90972812c6081c932d067b159860 --- /dev/null +++ b/tools/template/HPKBUILD @@ -0,0 +1,63 @@ +# This is an example HPKBUILD file. Use this as a start to creating your own, +# and remove these comments. +# NOTE: Please fill out the license field for your package! If it is unknown, +# then please put 'unknown'. + +# Contributor: Your Name +# Maintainer: Your Name + +pkgname=NAME # 库名 +pkgver=VERSION # 库版本 +pkgrel=0 # 发布号 +pkgdesc="" # 库描述 +url="" # 官网链接 +archs=("armeabi-v7a" "arm64-v8a") # cpu 架构 +license=() +depends=() # 依赖库的目录名 必须保证被依赖的库的archs是当前库的archs的超集 +makedepends=() # 构建库时的依赖工具 +source="https://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz" # 库源码下载链接 + +downloadpackage=true # 是否自动下载压缩包,如若不写默认 true, 一些特殊情况,代码需要代码只能 git clone (项目中依赖 submoudle ) +autounpack=true # 是否自动解压,如若不写默认 true, 如果为 false 则需要用户在 prepare 函数中自行解压 +buildtools= # 编译方法, 暂时支持cmake, configure, make等, 是什么就填写什么. 如若不写默认为cmake. + +builddir= # 源码压缩包解压后目录名 编译目录名 +packageName=$builddir.tar.gz # 压缩包名 + +# 为编译设置环境,如设置环境变量,创建编译目录等 +prepare() { + cd $builddir + cd ${OLDPWD} +} + +# ${OHOS_SDK} oh sdk安装路径 +# $ARCH 编译的架构是 archs 的遍历 +# $LYCIUM_ROOT/usr/$pkgname-$ARCH-install 安装到顶层目录的usr/$pkgname-$ARCH-install +# 执行编译构建的命令 +build() { + # 如果是cmake构建 $*=-DCMAKE_FIND_ROOT_PATH="..." -DCMAKE_TOOLCHAIN_FILE="..." -DCMAKE_INSTALL_PREFIX="..." 依赖库的搜索路径,toolchain file 路径,安装路径 + cd $builddir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake $* -DOHOS_ARCH=$ARCH -B$ARCH-build -S./ -L + make -j4 -C $ARCH-build + # 对最关键一步的退出码进行判断 + ret=$? + cd $OLDPWD + return $ret +} + +# 打包安装 +package() { + cd $builddir + make -C $ARCH-build install + cd $OLDPWD +} + +# 进行测试的准备和说明 +check() { + echo "The test must be on an OpenHarmony device!" +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/$builddir #${PWD}/$packageName +} diff --git a/tools/template/README.md b/tools/template/README.md new file mode 100755 index 0000000000000000000000000000000000000000..e8fff40d4e65cd0f0b710d4bdae94a3c6f6e94a3 --- /dev/null +++ b/tools/template/README.md @@ -0,0 +1,5 @@ +## HPKBUILD 文件的格式 +请阅读HPKBUILD 文件. + +## SHA512SUM的格式 +SHA512SUM 记录库的压缩包的 sha512sum 值, 以及库对应的 patch 文件的sha512值. \ No newline at end of file diff --git a/tools/template/SHA512SUM b/tools/template/SHA512SUM new file mode 100755 index 0000000000000000000000000000000000000000..16934b8ade854efc82ab0f345c775c159d85aa68 --- /dev/null +++ b/tools/template/SHA512SUM @@ -0,0 +1 @@ +*************************************************************************************** xxx.tar.gz \ No newline at end of file