同步操作将从 OpenHarmony/docs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
build/lite # Primary directory for compilation and building
├── components # Component description file
├── hb # hb pip installation package
├── make_rootfs # make script for the file system
├── config # Compilation configuration items
│ ├── component # Definitions of component-related templates, including static libraries, dynamic libraries, extension components, and emulator libraries
│ ├── kernel # Compilation configuration parameters of the kernel
│ └── subsystem # Subsystem template
├── ndk # NDK-related compilation scripts and configuration parameters
└── toolchain # Compilation toolchains, which contain the compiler directories, compilation options, and linking options
Add the component compilation script.
The compilation script language for the component is GN. For details about its basic usage, see the GN Quick Start Guide. In GN, a component is a compilation unit, which can be a static library, a dynamic library, or an executable file.
The following example adds a script to compile the hello_world component (as an executable file).
executable("hello_world") {
include_dirs = [
"include",
]
sources = [
"src/hello_world.c"
]
}
The added script is used to compile hello_world that can run on OpenHarmony.
Add the component description.
The component description is stored in the build/lite/components directory. New components must be added to the JSON file of the corresponding subsystem. A component description must contain the following fields:
For example, to add the hello_world component to the application subsystem, add the hello_world object to the applications.json file.
{
"components": [
{
"component": hello_world",
"description": "Hello world.",
"optional": "true",
"dirs": [
"applications/sample/hello_world"
],
"targets": [
"//applications/sample/hello_world"
]
},
...
]
}
Configure the component for the product.
The product configuration file is stored in the vendor/company/ directory. The file must contain the product name, OpenHarmony version, device vendor, development board name, kernel type, kernel version, and the subsystem and component to configure. The following example adds the hello_world component to the my_product.json configuration file:
{
"product_name": "hello_world_test",
"ohos_version": "OpenHarmony 1.0",
"device_company": "hisilicon",
"board": "hispark_taurus",
"kernel_type": "liteos_a",
"kernel_version": "1.0.0",
"subsystems": [
{
"subsystem": "applications",
"components": [
{ "component": "hello_world", "features":[] }
]
},
...
]
}
Compile the component or product.
Run hb set and select hello_world_test@hisilicon.
To build the hello_world component, run the following command:
hb build hello_world
To build the hello_world_test product, run the following command:
hb build
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。