diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-package-environment.md b/zh-cn/device-dev/quick-start/quickstart-lite-package-environment.md
index c79a3ade616dd8de0935d8b02c7769d24a1fe823..a9740e0ab29ff67b8ce43ba765a3e67d4338da70 100644
--- a/zh-cn/device-dev/quick-start/quickstart-lite-package-environment.md
+++ b/zh-cn/device-dev/quick-start/quickstart-lite-package-environment.md
@@ -3,30 +3,57 @@
使用安装包方式搭建Ubuntu编译环境步骤如下:
-1. 安装必要的库和工具:编译所需的必要工具和库(如打包、镜像制作等)
-2. 安装hb:OpenHarmony编译构建命令行工具
-3. 安装LLVM\(仅OpenHarmony\_v1.x分支/标签需要\)
+1. 安装必要的库和工具:编译所需的必要工具和库(如打包、镜像制作等)。
+2. 执行prebuilts。
+3. 安装hb:OpenHarmony编译构建命令行工具。
+4. 安装LLVM\(仅OpenHarmony\_v1.x分支/标签需要\)。
想要详细了解OpenHarmony编译构建模块功能的开发者可参考[编译构建使用指南](../subsystems/subsys-build-mini-lite.md)。
## 安装必要的库和工具
-使用如下apt-get命令安装编译所需的必要的库和工具:
-
+1. 使用如下apt-get命令安装后续操作所需的库和工具:
+
+ ```
+ sudo apt-get update && sudo apt-get install binutils binutils-dev git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib gcc-arm-linux-gnueabi libc6-dev-i386 libc6-dev-amd64 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby genext2fs device-tree-compiler make libffi-dev e2fsprogs pkg-config perl openssl libssl-dev libelf-dev libdwarf-dev u-boot-tools mtd-utils cpio doxygen liblz4-tool openjdk-8-jre gcc g++ texinfo dosfstools mtools default-jre default-jdk libncurses5 apt-utils wget scons python3.8-distutils tar rsync git-core libxml2-dev lib32z-dev grsync xxd libglib2.0-dev libpixman-1-dev kmod jfsutils reiserfsprogs xfsprogs squashfs-tools pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5-dev libncursesw5 libstdc++6 gcc-arm-none-eabi vim ssh locales
+ ```
+
+ >  **说明:**
+ > 以上安装命令适用于Ubuntu18.04,其他版本请根据安装包名称采用对应的安装命令。其中:
+ >
+ > - Python要求安装Python 3.8及以上版本,此处以Python 3.8为例。
+ >
+ > - java要求java8及以上版本,此处以java8为例。
+
+2. 将python 3.8设置为默认python版本。
+ 查看python 3.8的位置:
+
+
+ ```
+ which python3.8
+ ```
+
+ 将python和python3切换为python3.8:
+
+ ```
+ sudo update-alternatives --install /usr/bin/python python {python3.8 路径} 1 #{python3.8 路径}为上一步查看的python3.8的位置
+ sudo update-alternatives --install /usr/bin/python3 python3 {python3.8 路径} 1 #{python3.8 路径}为上一步查看的python3.8的位置
+ ```
+
+## 执行prebuilts
+
+在源码根目录下执行prebuilts脚本,安装编译器及二进制工具。
+
+```
+bash build/prebuilts_download.sh
```
-sudo apt-get install build-essential gcc g++ make libffi-dev e2fsprogs pkg-config flex bison perl bc openssl libssl-dev libelf-dev libc6-dev-amd64 binutils binutils-dev libdwarf-dev u-boot-tools mtd-utils gcc-arm-linux-gnueabi cpio device-tree-compiler libncurses5 libncurses5-dev libncursesw5 openjdk-8-jre default-jre default-jdk python3.8 python3-pip
-```
-> **说明:**
->以上安装命令适用于Ubuntu18.04,其他版本请根据安装包名称采用对应的安装命令。其中:
->- Python要求安装Python 3.8及以上版本,此处以Python 3.8为例。
->- java要求java8及以上版本,此处以java8为例。
## 安装hb
-1. 运行如下命令安装hb
+1. 运行如下命令安装hb并更新至最新版本
```
- python3 -m pip install --user ohos-build
+ pip3 install --user build/lite
```
2. 设置环境变量
diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-application-framework.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-application-framework.md
index 59780d7a7ce22fa96a79c1e8d258bfbb9681a598..b2d1d02add26b72b653c9ba31094aa9597705b14 100644
--- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-application-framework.md
+++ b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-application-framework.md
@@ -1,121 +1,159 @@
-# 新建应用程序
-
-下方将通过修改源码的方式展示如何编写简单程序,输出“Hello OHOS!”。请在[获取源码](quickstart-lite-sourcecode-acquire.md)章节下载的源码目录中进行下述操作。
-
-1. 新建目录及源码。
-
- 新建**applications/sample/camera/apps/src/helloworld.c**目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改OHOS为World)。当前应用程序可支持标准C及C++的代码开发。
-
- ```
- #include
-
- int main(int argc, char **argv)
- {
- printf("\n************************************************\n");
- printf("\n\t\tHello OHOS!\n");
- printf("\n************************************************\n\n");
-
- return 0;
- }
- ```
-
-2. 新建编译组织文件。
-
- 新建**applications/sample/camera/apps/BUILD.gn**文件,内容如下所示:
-
- ```
- import("//build/lite/config/component/lite_component.gni")
- lite_component("hello-OHOS") {
- features = [ ":helloworld" ]
- }
- executable("helloworld") {
- output_name = "helloworld"
- sources = [ "src/helloworld.c" ]
- include_dirs = []
- defines = []
- cflags_c = []
- ldflags = []
- }
- ```
-
-3. 添加新组件。
-
- 修改文件**build/lite/components/applications.json**,添加组件hello\_world\_app的配置,如下所示为applications.json文件片段,"\#\#start\#\#"和"\#\#end\#\#"之间为新增配置("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行):
-
- ```
- {
- "components": [
- {
- "component": "camera_sample_communication",
- "description": "Communication related samples.",
- "optional": "true",
- "dirs": [
- "applications/sample/camera/communication"
- ],
- "targets": [
- "//applications/sample/camera/communication:sample"
- ],
- "rom": "",
- "ram": "",
- "output": [],
- "adapted_kernel": [ "liteos_a" ],
- "features": [],
- "deps": {
- "components": [],
- "third_party": []
- }
- },
- ##start##
- {
- "component": "hello_world_app",
- "description": "Communication related samples.",
- "optional": "true",
- "dirs": [
- "applications/sample/camera/apps"
- ],
- "targets": [
- "//applications/sample/camera/apps:hello-OHOS"
- ],
- "rom": "",
- "ram": "",
- "output": [],
- "adapted_kernel": [ "liteos_a" ],
- "features": [],
- "deps": {
- "components": [],
- "third_party": []
- }
- },
- ##end##
- {
- "component": "camera_sample_app",
- "description": "Camera related samples.",
- "optional": "true",
- "dirs": [
- "applications/sample/camera/launcher",
- "applications/sample/camera/cameraApp",
- "applications/sample/camera/setting",
- "applications/sample/camera/gallery",
- "applications/sample/camera/media"
- ],
- ```
-
-4. 修改单板配置文件。
-
- 修改文件**vendor/hisilicon/hispark\_taurus/config.json**,新增hello\_world\_app组件的条目,如下所示代码片段为applications子系统配置,"\#\#start\#\#"和"\#\#end\#\#"之间为新增条目("\#\#start\#\#"和"\#\#end\#\#"仅用来标识位置,添加完配置后删除这两行):
-
- ```
- {
- "subsystem": "applications",
- "components": [
- { "component": "camera_sample_app", "features":[] },
- { "component": "camera_sample_ai", "features":[] },
- ##start##
- { "component": "hello_world_app", "features":[] },
- ##end##
- { "component": "camera_screensaver_app", "features":[] }
- ]
- },
- ```
+# 编写“Hello World”程序
+下方将展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。
+
+
+## 示例目录
+
+示例完整目录如下:
+
+
+
+```
+applications/sample/hello
+│── BUILD.gn
+│── include
+│ └── helloworld.h
+│── src
+│ └── helloworld.c
+├── bundle.json
+│
+│── test
+│ └── moduletest
+│ └── unittest
+│
+productdefine/common
+└── products
+ └── Hi3516DV300.json
+```
+
+
+## 开发步骤
+
+请在源码目录中通过以下步骤创建“Hello World”应用程序:
+
+
+1. 创建目录,编写业务代码。
+ 新建applications/sample/hello/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改World为OH)。其中helloworld.h包含字符串打印函数HelloPrint的声明。当前应用程序可支持标准C及C++的代码开发。
+
+
+ ```
+ #include
+ #include "helloworld.h"
+
+ int main(int argc, char **argv)
+ {
+ HelloPrint();
+ return 0;
+ }
+
+ void HelloPrint()
+ {
+ printf("\n\n");
+ printf("\n\t\tHello World!\n");
+ printf("\n\n");
+ }
+ ```
+
+ 再添加头文件applications/sample/hello/include/helloworld.h,代码如下所示。
+
+
+ ```
+ #ifndef HELLOWORLD_H
+ #define HELLOWORLD_H
+ #ifdef __cplusplus
+ #if __cplusplus
+ extern "C" {
+ #endif
+ #endif
+
+ void HelloPrint();
+
+ #ifdef __cplusplus
+ #if __cplusplus
+ }
+ #endif
+ #endif
+ #endif // HELLOWORLD_H
+ ```
+
+2. 新建编译组织文件。
+ 1. 新建applications/sample/hello/BUILD.gn文件,内容如下所示:
+
+ ```
+ import("//build/ohos.gni") # 导入编译模板
+ ohos_executable("helloworld") { # 可执行模块
+ sources = [ # 模块源码
+ "src/helloworld.c"
+ ]
+ include_dirs = [ # 模块依赖头文件目录
+ "include"
+ ]
+ cflags = []
+ cflags_c = []
+ cflags_cc = []
+ ldflags = []
+ configs = []
+ deps =[] # 部件内部依赖
+
+ part_name = "sample" # 所属部件名称,必选
+ install_enable = true # 是否默认安装(缺省默认不安装),可选
+ }
+ ```
+ 2. 新建applications/sample/bundle.json文件,添加sample部件描述,内容如下所示。
+
+ ```
+ {
+ "name": "@ohos/hello",
+ "description": "Hello world example.",
+ "version": "3.1",
+ "license": "Apache License 2.0",
+ "publishAs": "code-segment",
+ "segment": {
+ "destPath": "applications/sample/hello"
+ },
+ "dirs": {},
+ "scripts": {},
+ "component": {
+ "name": "hello",
+ "subsystem": "applications",
+ "syscap": [],
+ "features": [],
+ "adapted_system_type": [
+ "mini",
+ "small",
+ "standard"
+ ],
+ "rom": "10KB",
+ "ram": "10KB",
+ "deps": {
+ "components": [],
+ "third_party": []
+ },
+ "build": {
+ "sub_component": [
+ "//applications/sample/hello:helloworld"
+ ],
+ "inner_kits": [],
+ "test": [
+ "//applications/sample/hello/test:moduletest",
+ "//applications/sample/hello/test:unittest"
+ ]
+ }
+ }
+ }
+ ```
+
+ bundle.json文件包含两个部分,第一部分说明该子系统的名称,component定义该子系统包含的部件,要添加一个部件,需要把该部件对应的内容添加进component中去。添加的时候需要指明该部件包含的模块sub_component,假如有提供给其它部件的接口,需要在inner_kits中说明,假如有测试用例,需要在test中说明,inner_kits与test没有也可以不添加。
+
+3. 修改产品配置文件。
+ 在productdefine\common\products\Hi3516DV300.json中添加对应的hello部件,直接添加到原有部件后即可。
+
+
+ ```
+ "usb:usb_manager_native":{},
+ "applications:prebuilt_hap":{},
+ "applications:hello":{},
+ "wpa_supplicant-2.9:wpa_supplicant-2.9":{},
+ ```
diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-build.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-build.md
index d4655fadc0f86988fcb18b087d554a683945d4af..aea1737a28bbbdcc87ecd3677c3470b0b18c2b9c 100644
--- a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-build.md
+++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-build.md
@@ -55,16 +55,31 @@ bash build/prebuilts_download.sh
### 安装依赖工具
-请在终端中输入如下命令安装编译相关的依赖工具:
+1. 使用如下apt-get命令安装后续操作所需的库和工具:
-```
-sudo apt-get update && sudo apt-get install binutils git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby libncurses5 libncurses5-dev libncursesw5 openjdk-8-jre default-jre default-jdk
-```
+ ```
+ sudo apt-get update && sudo apt-get install binutils binutils-dev git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib gcc-arm-linux-gnueabi libc6-dev-i386 libc6-dev-amd64 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby genext2fs device-tree-compiler make libffi-dev e2fsprogs pkg-config perl openssl libssl-dev libelf-dev libdwarf-dev u-boot-tools mtd-utils cpio doxygen liblz4-tool openjdk-8-jre gcc g++ texinfo dosfstools mtools default-jre default-jdk libncurses5 apt-utils wget scons python3.8-distutils tar rsync git-core libxml2-dev lib32z-dev grsync xxd libglib2.0-dev libpixman-1-dev kmod jfsutils reiserfsprogs xfsprogs squashfs-tools pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5-dev libncursesw5 libstdc++6 gcc-arm-none-eabi vim ssh locales
+ ```
-> **说明:**
->以上安装命令适用于Ubuntu18.04,其他版本请根据安装包名称采用对应的安装命令。其中:
->- Python要求安装Python 3.8及以上版本,此处以Python 3.8为例。
->- java要求java8及以上版本,此处以java8为例。
+ > **说明:**
+ >以上安装命令适用于Ubuntu18.04,其他版本请根据安装包名称采用对应的安装命令。其中:
+ >- Python要求安装Python 3.8及以上版本,此处以Python 3.8为例。
+ >- java要求java8及以上版本,此处以java8为例。
+
+2. 将python 3.8设置为默认python版本。
+
+ 查看python 3.8的位置:
+
+ ```
+ which python3.8
+ ```
+
+ 将python和python3切换为python3.8:
+
+ ```
+ sudo update-alternatives --install /usr/bin/python python {python3.8 路径} 1 #{python3.8 路径}为上一步查看的python3.8的位置
+ sudo update-alternatives --install /usr/bin/python3 python3 {python3.8 路径} 1 #{python3.8 路径}为上一步查看的python3.8的位置
+ ```
### 执行prebuilts
diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-create.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-create.md
index 1a6786fdd740ca930ac1d38f525acbb594909cfd..9fab1cd171780c18c170118777415572f5d437d2 100644
--- a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-create.md
+++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-create.md
@@ -1,31 +1,34 @@
-# 创建应用程序
+# 编写“Hello World”程序
-下方将通过修改源码的方式展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。
-这里演示在原有applications子系统下,添加hello部件以及该部件下的helloworld模块。
+下方将展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。
+
+## 示例目录
示例完整目录如下。
```
-applications/standard/hello
-├── helloworld
-│ ├── BUILD.gn
-│ ├── include
+applications/sample/hello
+│ │── BUILD.gn
+│ │── include
│ │ └── helloworld.h
-│ └── src
-│ └── helloworld.c
-├── ohos.build
-│
+│ │── src
+│ │ └── helloworld.c
+│ └── bundle.json
+build
+└── subsystem_config.json
productdefine/common
└── products
- └── Hi3516DV300.json
+ └── Hi3568DV300.json
```
-下方为新建应用程序步骤,请在[获取源码](quickstart-standard-sourcecode-acquire.md)章节下载的源码目录中进行下述操作:
+## 开发步骤
+
+请在源码目录中通过以下步骤创建“Hello World”应用程序:
-1. 新建目录及源码。
+1. 创建目录,编写业务代码。
- 新建applications/standard/hello/helloworld/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改World为OHOS)。其中helloworld.h包含字符串打印函数HelloPrint的声明。当前应用程序可支持标准C及C++的代码开发。
+ 新建applications/sample/hello/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改World为OH)。其中helloworld.h包含字符串打印函数HelloPrint的声明。当前应用程序可支持标准C及C++的代码开发。
```
#include
@@ -45,7 +48,7 @@ productdefine/common
}
```
- 再添加头文件applications/standard/hello/helloworld/include/helloworld.h,代码如下所示。
+ 再添加头文件applications/sample/hello/include/helloworld.h,代码如下所示。
```
#ifndef HELLOWORLD_H
@@ -67,13 +70,13 @@ productdefine/common
```
2. 新建编译组织文件。
- 1. 新建applications/standard/hello/helloworld/BUILD.gn文件,内容如下所示:
+ 1. 新建applications/sample/hello/BUILD.gn文件,内容如下所示:
```
import("//build/ohos.gni") # 导入编译模板
ohos_executable("helloworld") { # 可执行模块
sources = [ # 模块源码
- "src/helloworld.c"
+ "src/helloworld.c"
]
include_dirs = [ # 模块依赖头文件目录
"include"
@@ -84,46 +87,69 @@ productdefine/common
ldflags = []
configs = []
deps =[] # 部件内部依赖
-
part_name = "hello" # 所属部件名称,必选
install_enable = true # 是否默认安装(缺省默认不安装),可选
}
```
- 2. 新建applications/standard/hello/ohos.build文件,添加hello部件描述,内容如下所示。
+ 2. 新建applications/sample/hello/bundle.json文件,添加sample部件描述,内容如下所示。
```
{
- "subsystem": "applications", # 子系统名
- "parts": { # 包含部件
- "hello": { # 新建部件名
- "version": "1.0.0", # 版本
- "variants": [ # 变种版本
- "wearable",
- "phone"
- ],
- "module_list": [ # 部件包含模块的gn目标
- "//applications/standard/hello/helloworld:helloworld"
- ],
- "inner_kits": [ # 提供给其他部件的接口
- ],
- "test_list": [ # 测试用例
- ]
+ "name": "@ohos/hello",
+ "description": "Hello world example.",
+ "version": "3.1",
+ "license": "Apache License 2.0",
+ "publishAs": "code-segment",
+ "segment": {
+ "destPath": "applications/sample/hello"
+ },
+ "dirs": {},
+ "scripts": {},
+ "component": {
+ "name": "hello",
+ "subsystem": "sample",
+ "syscap": [],
+ "features": [],
+ "adapted_system_type": [ "mini", "small", "standard" ],
+ "rom": "10KB",
+ "ram": "10KB",
+ "deps": {
+ "components": [],
+ "third_party": []
+ },
+ "build": {
+ "sub_component": [
+ "//applications/sample/hello:helloworld"
+ ],
+ "inner_kits": [],
+ "test": []
+ }
}
- }
}
```
- ohos.build文件包含两个部分,第一部分subsystem说明该子系统的名称,parts定义该子系统包含的部件,要添加一个部件,需要把该部件对应的内容添加进parts中去。添加的时候需要指明该部件包含的模块module\_list,假如有提供给其它部件的接口,需要在inner\_kits中说明,假如有测试用例,需要在test\_list中说明,inner\_kits与test\_list没有也可以不添加。
+ bundle.json文件包含两个部分,第一部分描述该部件所属子系统的信息,第二部分component则定义该部件构建相关配置。添加的时候需要指明该部件包含的模块sub\_component,假如有提供给其它部件的接口,需要在inner\_kits中说明,假如有测试用例,需要在test中说明,inner\_kits与test没有也可以不添加。
+
+3. 修改子系统配置文件。
+
+ 在build/subsystem\_config.json中添加新建的子系统的配置。
+
+ ```
+ "sample": {
+ "path": "applications/sample/hello",
+ "name": "sample"
+ },
+ ```
-3. 修改产品配置文件。
+4. 修改产品配置文件。
- 在productdefine\\common\\products\\Hi3516DV300.json中添加对应的hello部件,直接添加到原有部件后即可。
+ 在productdefine/common/products/Hi3516DV300.json中添加对应的hello部件,直接添加到原有部件后即可。
```
"usb:usb_manager_native":{},
"applications:prebuilt_hap":{},
- "applications:hello":{},
+ "sample:hello":{},
"wpa_supplicant-2.9:wpa_supplicant-2.9":{},
```
diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-create.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-create.md
index 13b2b54d7bb549d10768b1481c8448bb4ac93a75..198a9d5c414aa863271c5597b50cd94285a3a419 100644
--- a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-create.md
+++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-create.md
@@ -1,32 +1,33 @@
-# 创建应用程序
+# 编写“Hello World”程序
-下方将通过修改源码的方式展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。
+下方将展示如何在单板上运行第一个应用程序,其中包括新建应用程序、编译、烧写、运行等步骤,最终输出“Hello World!”。
-这里演示新建examples子系统,添加hello部件以及该部件下的helloworld模块。
+## 示例目录
示例完整目录如下。
```
-applications/standard/hello
-├── helloworld
-│ ├── BUILD.gn
-│ ├── include
+applications/sample/hello
+│ │── BUILD.gn
+│ │── include
│ │ └── helloworld.h
-│ └── src
-│ └── helloworld.c
-├── ohos.build
+│ │── src
+│ │ └── helloworld.c
+│ └── bundle.json
build
-├── subsystem_config.json
+└── subsystem_config.json
productdefine/common
└── products
└── rk3568.json
```
-下方为新建应用程序步骤,请在[获取源码](quickstart-standard-sourcecode-acquire.md)章节下载的源码目录中进行下述操作:
+## 开发步骤
-1. 新建目录及源码。
+请在源码目录中通过以下步骤创建“Hello World”应用程序:
- 新建applications/standard/hello/helloworld/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改World为OHOS)。其中helloworld.h包含字符串打印函数HelloPrint的声明。当前应用程序可支持标准C及C++的代码开发。
+1. 创建目录,编写业务代码。
+
+ 新建applications/sample/hello/src/helloworld.c目录及文件,代码如下所示,用户可以自定义修改打印内容(例如:修改World为OH)。其中helloworld.h包含字符串打印函数HelloPrint的声明。当前应用程序可支持标准C及C++的代码开发。
```
#include
@@ -46,7 +47,7 @@ productdefine/common
}
```
- 再添加头文件applications/standard/hello/helloworld/include/helloworld.h,代码如下所示。
+ 再添加头文件applications/sample/hello/include/helloworld.h,代码如下所示。
```
#ifndef HELLOWORLD_H
@@ -68,7 +69,7 @@ productdefine/common
```
2. 新建编译组织文件。
- 1. 新建applications/standard/hello/helloworld/BUILD.gn文件,内容如下所示:
+ 1. 新建applications/sample/hello/BUILD.gn文件,内容如下所示:
```
import("//build/ohos.gni") # 导入编译模板
@@ -85,44 +86,59 @@ productdefine/common
ldflags = []
configs = []
deps =[] # 部件内部依赖
-
part_name = "hello" # 所属部件名称,必选
install_enable = true # 是否默认安装(缺省默认不安装),可选
}
```
- 2. 新建applications/standard/hello/ohos.build文件,添加hello部件描述,内容如下所示。
+ 2. 新建applications/sample/hello/bundle.json文件,添加sample部件描述,内容如下所示。
```
{
- "subsystem": "examples",
- "parts": {
- "hello": {
- "version": "1.0.0",
- "variants": [
- "wearable",
- "phone"
- ],
- "module_list": [
- "//applications/standard/hello:helloworld"
- ],
- "inner_kits": [],
- "test_list": []
+ "name": "@ohos/hello",
+ "description": "Hello world example.",
+ "version": "3.1",
+ "license": "Apache License 2.0",
+ "publishAs": "code-segment",
+ "segment": {
+ "destPath": "applications/sample/hello"
+ },
+ "dirs": {},
+ "scripts": {},
+ "component": {
+ "name": "hello",
+ "subsystem": "sample",
+ "syscap": [],
+ "features": [],
+ "adapted_system_type": [ "mini", "small", "standard" ],
+ "rom": "10KB",
+ "ram": "10KB",
+ "deps": {
+ "components": [],
+ "third_party": []
+ },
+ "build": {
+ "sub_component": [
+ "//applications/sample/hello:helloworld"
+ ],
+ "inner_kits": [],
+ "test": []
+ }
}
- }
}
```
- ohos.build文件包含两个部分,第一部分subsystem说明该子系统的名称,parts定义该子系统包含的部件,要添加一个部件,需要把该部件对应的内容添加进parts中去。添加的时候需要指明该部件包含的模块module\_list,假如有提供给其它部件的接口,需要在inner\_kits中说明,假如有测试用例,需要在test\_list中说明,inner\_kits与test\_list没有也可以不添加。
+ bundle.json文件包含两个部分,第一部分描述该部件所属子系统的信息,第二部分component则定义该部件构建相关配置。添加的时候需要指明该部件包含的模块sub\_component,假如有提供给其它部件的接口,需要在inner\_kits中说明,假如有测试用例,需要在test中说明,inner\_kits与test没有也可以不添加。
3. 修改子系统配置文件。
- 在build/subsystem_config.json中添加examples子系统配置。
+ 在build/subsystem\_config.json中添加新建的子系统的配置。
+
```
- "examples": {
- "path": "applications/standard/hello",
- "name": "examples"
- },
+ "sample": {
+ "path": "applications/sample/hello",
+ "name": "sample"
+ },
```
4. 修改产品配置文件。
@@ -132,7 +148,7 @@ productdefine/common
```
"usb:usb_manager_native":{},
"applications:prebuilt_hap":{},
- "examples:hello":{},
+ "sample:hello":{},
"wpa_supplicant-2.9:wpa_supplicant-2.9":{},
```