diff --git a/README_zh.md b/README_zh.md index 19029ab5efcf0f8611b473baa81fde3fafc1948a..e13dfd00bf1bb8e62e2861f8647e195963b76f1e 100755 --- a/README_zh.md +++ b/README_zh.md @@ -14,12 +14,12 @@ tpc_c_cplusplus ├── 三方库1 │ ├──gn #gn构建脚本、适配指导的文件夹 │ ├──cmake #cmake构建脚本、适配指导的文件夹 -│ ├──README_zh.md +│ ├──README_zh.md #目录下文件使用的介绍 │ ├──README.OpenSource #文件中包含了三方库源码的下载地址,版本,license等信息 ├── 三方库2 │ ├──gn #gn构建脚本、适配指导的文件夹 │ ├──cmake #cmake构建脚本、适配指导的文件夹 -│ ├──README_zh.md +│ ├──README_zh.md #目录下文件使用的介绍 │ ├──README.OpenSource #文件中包含了三方库源码的下载地址,版本,license等信息 ...... ``` diff --git a/common/gn_build.md b/common/gn_build.md new file mode 100755 index 0000000000000000000000000000000000000000..4778ad1b52682ed8cc14cf47ff1fa8ac816d44b0 --- /dev/null +++ b/common/gn_build.md @@ -0,0 +1,60 @@ +# 三方库引入GN工程 + +## 概述 + +本文介绍如何将三方库引入自己的GN工程 + + + +## 开发流程 + +这里以三方库thirdpartyA、动态库名libA的三方库引入到helloworld工程为例: + +### 目录结构 + +三方库thirdpartyA目录结构如下: + +``` +third_party/thirdpartyA +├── src +├── include +├── BUILD.gn +..... +``` + +helloworld工程目录结构如下: + +``` +third_party/helloworld +├── src +├── include +├── BUILD.gn +..... +``` + +### 引入三方库 + +在helloworld工程构建脚本中引入三方库thirdpartyA: + +``` +import("//build/ohos.gni") # 导入编译模板 +ohos_executable("helloworld") { # 可执行模块 + sources = [ # 模块源码 + "src/helloworld.c" + ] + include_dirs = [ # 模块依赖头文件目录 + "include" , + “//third_party/thirdpartyA/include”, #依赖三方库头文件的目录 + ] + cflags = [] + cflags_c = [] + cflags_cc = [] + ldflags = [] + configs = [] + deps =[] # 部件内部依赖 + deps += [ “//third_party/thirdpartyA:libA” ] #依赖三方库库文件 + part_name = "hello" # 所属部件名称,必选 + install_enable = true # 是否默认安装(缺省默认不安装),可选 +} +``` + diff --git a/common/gn_compile.md b/common/gn_compile.md new file mode 100755 index 0000000000000000000000000000000000000000..228ea60d6cbc644cf3946291fd808c39892b3251 --- /dev/null +++ b/common/gn_compile.md @@ -0,0 +1,125 @@ +# 工程加入OpenHarmony构建体系 + +## 概述 + +本文介绍如何将自己的工程加入OpenHarmony进行编译 + + + +## 开发流程 + +以helloworld工程为例,有如下步骤 + +### 新增工程目录 + +``` +#在源码根目录下创建工程目录 +mkdir ~/openharmony/helloworld + +#在helloworld工程目录下新建源码文件 +touch hello.c + +#编写源文件内容如下 +#include + +void HelloPrint() +{ + printf("\n************************************************\n"); + printf("\n\t\tHello World!\n"); + printf("\n************************************************\n"); +} + +int main(int argc, char **argv) +{ + HelloPrint(); + return 0; +} + + +``` + + + +### 新增工程构建脚本 + +``` +#在helloworld工程目录下新增BUILD.gn脚本,内容如下 + +import("//build/ohos.gni") +ohos_executable("hello") { + sources = [ + "helloworld.c" + ] + include_dirs = [] + deps = [] + part_name = "hello" + install_enable = true +} +``` + + + +### 新增组件定义脚本 + +``` +#在helloworld工程目录下新增ohos.build脚本,内容如下 +{ + "subsystem": "helloworld", + "parts": { + "hello": { + "module_list": [ + "//helloworld:hello" + ] + } + } +} +``` + + + +### 新增产品定义 + +``` +#在vendor目录下新增产品的定义,这里以rk3568为例 +#在openharmony源码根目录下的vendor/hihope/rk3568/config.json,新增如下内容 + { + "subsystem": "helloworld", + "components": [ + { + "component": "hello", + "features": [] + } + ] + } + +``` + + + +### 新增子系统定义 + +``` +#在openharmony源码根目录下的build/subsystem_config.json中新增子系统定义 + + "helloworld": { + "path": "helloworld", + "name": "helloworld" + } +``` + + + +### 编译Openharmony镜像 + +``` +#在OpenHarmony源码根目录 +#选择需要编译的产品 +hb set + +#编译32位镜像 +hb build --target-cpu arm + +#编译64位镜像 +hb build --target-cpu arm64 +``` +