• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# OpenHarmony Part Design Guide
2
3## About This Document
4
5For easy software design and management, OpenHarmony decouples software from physical components, parts, and modules. A **component** can be independently deployed and reused at the binary level. A **part** can be independently developed, built, and tested. A **module** can be reused at the code level.
6
7OpenHarmony abstracts system capabilities as parts, so you can assemble and configure these parts to customize an OS for different devices.
8
9## Part Definition
10
11A part is the basic unit of system capabilities. Divided based on source code, every part has independent files and directories, and can be instantiated into libraries or executable files on different devices.
12
13## Part Division
14
15Observe the following rules for part classification:
16
17- A part must have an independent code directory for compiling libraries or executable files.
18
19- A part must be able to be independently deployed in the small system or standard system. Optional parts can be tailored without causing system exceptions.
20
21- Functions of a part must be able to be independently tested and verified.
22
23A part always belongs to a specific subsystem. A subsystem is a logical concept and consists of specific parts.
24
25Note the following:
26
27- External APIs provided by a part must be the same regardless of whether the configurable features of the part are configured.
28
29- Dependent third-party open source software libraries and parts that provide basic capabilities are called **dependent parts**, which must be deployed with other parts.
30
31- If a part can be split into smaller functional modules and provide APIs for applications, these modules are called **child parts**, which must be deployed with the parent part. A child part depends on a parent part, but a parent part does not depend on a child part.
32
33## Basic Principles
34
35Comply with the following rules and recommendations during parts design and development:
36
37**Rule 1.1** Parts must be developed individually to ensure decoupling and independence.
38
39**Rule 1.2** Parts must be managed in a decentralized manner. The dependency between parts must be simple, clear, and reasonable.
40
41**Rule 1.3** Reverse dependency and cyclic dependency between parts are prohibited. Lower-layer parts must not depend on upper-layer parts.
42
43**Rule 1.4** It is prohibited that the implementation of a part depends on a specific development board or product form.
44
45**Rule 1.5** APIs provided by a part must be stable and compatible. Changes to released APIs are prohibited.
46
47**Rec 1.1** Parts should support automated build and verification.
48
49## Naming Rules
50
51#### **Part Name**
52
53The name must reflect the key function of a part and must be globally unique in the system. It can contain a maximum of 63 characters and must be in the unix\_like style, where only lowercase letters separated by underscores (\_) are used.
54
55#### **Repository Name**
56
57The part repository is named in the format of <Subsystem\>\_<Part\>. For example, the repository name of the storage service part in the file management subsystem is **filemanagement\_storage\_service**. The repository name can contain a maximum of 100 characters.
58
59> Note:
60>
61> 1. In principle, there is a one-to-one mapping between parts and repositories. In some cases, multiple parts can share a repository, but they must have independent directories.
62>
63> 2. For a third-party open source part, use the original name with the prefix **third\_party**. All third-party open source parts are stored in the **third\_party** directory.
64>
65> 3. The subsystem names in the repository name and path should not contain underscores (\_).
66
67#### **Path**
68
69The part name must be in the format of <Domain\>/<Subsystem\>/<Part\>, for example, **foundation/filemanagement/storage_service**.
70
71#### **Part Directory Structure**
72
73```xml
74├── interfaces          # APIs
75│   ├── kits			# Application APIs (optional)
76│   │    ├── js			# JS APIs (optional)
77│   │    └── native  	# C/C++ APIs (optional)
78│   └── inner_api       # Internal APIs of parts
79├── frameworks          # Implementation of the part without independent processes (optional)
80│   ├── native          # C/C++ API implementation (optional)
81│   └── js              # JS API implementation (optional)
82│        ├── napi       # Native API implementation (optional)
83│        ├── builtin	# Specific to LiteOS-M (optional)
84│        └── plugin     # Specific to ArkUI (optional)
85├── services            # Implementation of parts with independent processes (optional)
86├── test                # Test code (mandatory)
87├── BUILD.gn            # Entry to build (mandatory)
88└── bundle.json         # Part description file (mandatory)
89```
90
91## Adding, Deleting, or Modifying Parts
92
93The addition, deletion, and modification of parts must be reviewed by the architecture SIG and [related domain SIGs](https://gitee.com/openharmony/community/blob/master/sig/sigs_subsystem_list.md). The review process is as follows:
94
951. Prepare the following part attribute review form.
96
97Table 1 Part attribute review form
98
99| Part Attribute | Description |
100| ------------ | ------------------------------------------------------------ |
101| Part name | The name must reflect the key function of a part and must be globally unique in the system. The name can contain a maximum of 63 characters and must be in the unix\_like style, where only lowercase letters separated by underscores (\_) are used. |
102| Subsystem | Subsystem to which the part belongs. |
103| Function description | Brief description of the functions of the part in one or two sentences. |
104| Configurable features | Features that can be configured externally. |
105| Applicable systems | Mini system, small system, standard system, or their combinations. |
106| Source code directory | Root directory of the source code of the part. |
107| ROM          | ROM baseline value of the part. |
108| RAM          | RAM baseline value of the part. |
109| Dependencies | Parts and open source software on which the part depends. |
110
111
1122. Send an email to the architecture SIG (dev@openharmony.io) and the [related domain SIG leaders](https://gitee.com/openharmony/community/blob/master/sig/sigs_subsystem_list.md) for review. Use "Application for Adding/Deleting/Modifying OpenHarmony Parts" as the email subject, and include the filled-in **Table 1 Part Attribute Review Form** in the email body.
113
114> Note:
115>
116> For modified parts, provide a before and after comparison of the part attributes. For deleted parts, provide the plan for stopping part maintenance. Exercise caution when deleting or modifying parts and evaluate the impact on existing versions.
117
1183. After the review is passed, create a part repository and modify the manifest according to [SIG Management Regulations](https://gitee.com/openharmony/community/blob/master/sig/README-EN.md). After the SIG is incubated, incorporate it into the main code library of OpenHarmony.
119