README_zh.md
1# 公共产品形态配置<a name="ZH-CN_TOPIC_0000001079317008"></a>
2
3- [简介](#section11660541593)
4- [配置仓目录结构](#section113275517516)
5- [配置示例](#section178021418115315)
6- [常见问题说明](#section174312714582)
7- [相关仓](#section1371113476307)
8
9## 简介<a name="section11660541593"></a>
10
11一个完整的产品包括芯片组件部分和系统组件部分。芯片组件部分在vendor/{company}/{product}/目录下定义。本仓主要定义与芯片无关的通用系统组件形态配置。
12
13一个完整的系统组件形态主要包括两个部分:
14
15- 部件列表:系统组件支持的部件集合都在productdefine/common/products目录下通过系统组件形态配置文件xxx.json列举,该文件还可以配置部件的feature值。
16- 部件部署的指令集:指令集定义都在productdefine/common/device目录下通过arm64.json类文件来定义,products下的形态配置文件可以通过target_cpu来指定。
17
18## 配置仓目录结构<a name="section113275517516"></a>
19
20```sh
21productdefine/common
22├── inherit # 可继承的部件模版
23│ ├── base.json # 系统组件最小部件集合
24│ ├── headless.json # 无UI系统最小部件集合
25│ ├── rich.json # 全量部件集合
26│ └── chipset_common.json # 芯片组件依赖最小部件集合
27├── device # device配置,配置文件按照device name命名
28│ └── arm64.json
29└── products # 系统组件形态配置文件,配置文件名称与product name保持一致
30 └── system-arm64-default.json
31```
32
33inherit中的模版含义说明:
34
35| 名称 | 含义 | 使用产品 | |
36| ------------------- | ------------------------------------------------------------ | ------------------------------------------------- | ---- |
37| base.json | 标准系统最小的部件集合,可提供分布式SA服务能力,不支持应用安装。 | 当前qemu-arm-linux-min虚拟机平台使用此模版。 | |
38| headless.json | 标准系统无头系统部件集合,支持无界面的FA安装及流转。 | 当前qemu-arm-linux-headless虚拟机平台使用此模版。 | |
39| rich.json | 标准系统全量部件集合,具备全量功能。 | 当前rk3568, hispark_phoenix等开发板使用此模版。 | |
40| chipset_common.json | 标准系统芯片组件部件集合。 | 各标准系统开发板芯片组件都使用此模版。 | |
41
42
43
44## 配置示例<a name="section178021418115315"></a>
45
46**产品配置示例:** system-arm64-default.json
47
48```json
49{
50 "version": "3.0", # 配置文件格式版本
51 "product_name": "system-arm64-default", # 系统组件形态名称
52 "device_company": "ohos", # 系统组件形态厂商
53 "target_cpu": "arm64", # 系统组件形态支持的指令集,读取device/下对应的指令集配置
54 "board": "arm64", # 与target_cpu相同,读取device/下对应的指令集配置
55 "type": "standard", # 系统类型,读取base下对应的系统配置
56 "inherit": [ "" ], # 继承的部件列表配置, 可以继承通用的部件列表
57 "subsystems":[ # 产品的部件列表
58 {
59 "subsystem": "arkui",
60 "components": [{
61 "component": "napi",
62 "features": [
63 "napi_xxxx=xxx",
64 ...
65 ]
66 }
67 ]
68 },
69 ...
70 ]
71}
72```
73
74配置文件中各字段的含义如下:
75
76| 字段 | 含义 |
77| -------------- | ------------------------------------------------------------ |
78| version | 配置文件版本号,当前都填"3.0"。 |
79| product_name | 系统组件形态名称,可以通过此字段值作为build.sh --product-name的参数来完成系统组件的编译。<br/>系统组件的product_name命名采用system-{target_cpu}-{devicetype}格式,devicetype对应系统组件的形态名称,如tablet,pc等,默认为default。 |
80| device_company | 系统组件形态厂商,默认均填"ohos"。 |
81| target_cpu | 系统组件形态支持的指令集,会关联读取device/下对应的指令集配置。 |
82| board | 与target_cpu相同,读取device/下对应的指令集配置。 |
83| type | 轻量系统("mini"),小型系统("small")还是标准系统("standard")。 |
84| inherit | 继承的部件列表配置,可继承的部件配置列表都存在productdefine/common/inherit目录下。 |
85| subsystems | 支持的子系统部件列表。每个子系统由多个components组成;每个component包括component部件名称以及部件的features特性配置列表。<br/>部件的feature配置都是如下的名字对字符串:<br/>"{component_name}_xxx=xxx" |
86
87
88
89**device配置示例:** arm64.json
90
91需要提供一个形态配置中target_cpu同名的配置文件,配置device信息和board信息。
92
93```json
94{
95 "device_name": "arm64", # device名
96 "device_company": "openharmony", # device厂商名
97 "target_os": "ohos", # 在设备上部署的操作系统名
98 "target_cpu": "arm64", # 设备的cpu类型
99 "kernel_version": "",
100 "device_build_path": "" # device对应的子系统路径,系统组件形态不用填写此字段。
101}
102```
103
104device_build_path是device对应子系统路径,编译时会扫描对应目录下的部件配置。
105
106**系统组件部件类表的生成:**
107
1081. 先加载inherit中的部件列表;
1092. 加载subsystems中的部件列表;
1105. 部件配置安装上述顺序加载,后面加载的配置可覆盖前面已加载的同名配置。
111
112## 部件组合的继承关系<a name="section174312714582"></a>
113
114在inherit目录下定义部件模版,系统组件形态可以通过inherit继承该模版中包含的所有部件,减少形态过多时,新增部件的配置工作。
115
116由于每个部件包括部件名称以及feature信息,系统组件形态配置文件继承模版时会把这两个信息都继承下去。编译框架支持了对部件模版的**全量继承**以及**部分继承**能力。下面以sample.json模版为例介绍继承关系:
117
118```json
119[
120 {
121 "component": "A",
122 "features": [ "feature_A=true" ]
123 }, {
124 "component": "B",
125 "features": [ "feature_B=true" ]
126 }
127]
128```
129
130- 全量继承:
131
132 系统组件形态配置文件直接inherit上述模版,则可完全继承模版中的部件以及部件的feature信息。
133
134 ```json
135 {
136 ...
137 "inherit": [ "inherit/sample.json" ],
138 "subsystems": []
139 }
140 ```
141
142- 部分继承:feature重载
143
144 ```json
145 {
146 ...
147 "inherit": [ "inherit/sample.json" ],
148 "subsystems": [{
149 ...
150 "components": [{
151 "component": "A",
152 "features": [ "feature_A=false", "feature_A_pluse=false" ]
153 }]
154 }]
155 }
156 ```
157
158 如上示例,系统组件形态配置文件中的重新定义了部件A的feature,此时会覆盖sample.json模版中部件A的配置。
159
160## 常见问题说明<a name="section174312714582"></a>
161
162**如何给系统组件新加一个部件?**
163
164根据部件的归属的形态,修改productdefine/common/products/目录下的系统组件形态部件列表。如果是通用的部件,可以把部件添加到productdefine/common/inherits/目录下的模版中,这样所有继承该模版的系统组件形态都会生效。
165
166新的部件配置格式示例如下:
167
168```json
169 "subsystems": [{
170 ...
171 "components": [{
172 "component": "name",
173 "features": [ "feature_A=false", "feature_A_pluse=false" ]
174 }]
175 }
176```
177
178**如何查看一个指定产品的最终的部件列表?**
179
180在编译启动后,编译系统会解析配置文件,生成产品的全部的部件列表,输出为:out/preloader/\{产品名\}/parts.json。
181
182## 相关仓<a name="section1371113476307"></a>
183
184productdefine/common
185
186