sourcecode-acquire.md 13.3 KB
Newer Older
S
shawn_he 已提交
1
# Obtaining Source Code
W
wenjun 已提交
2 3


S
shawn_he 已提交
4
## About OpenHarmony
W
wenjun 已提交
5

S
shawn_he 已提交
6
OpenHarmony is an open source project launched by the OpenAtom Foundation. The purpose of this project is to build an open, distributed operating system (OS) framework for smart IoT devices in the full-scenario, full-connectivity, and full-intelligence era. 
W
wenjun 已提交
7 8 9



S
shawn_he 已提交
10
The open source code repositories are available at [https://openharmony.gitee.com](https://openharmony.gitee.com).
D
duangavin123 已提交
11 12


S
shawn_he 已提交
13
## Overview of Source Code Acquisition
D
duangavin123 已提交
14

S
shawn_he 已提交
15
This document describes how to acquire OpenHarmony source code and provides its directory structure. The OpenHarmony source code is open to you as [HPM parts](../hpm-part/hpm-part-about.md), which can be obtained in any of the following ways:
D
duangavin123 已提交
16

S
shawn_he 已提交
17
- **Method 1**: Acquire the source code from the Gitee code repository. You can use the **repo** or **git** tool to download the latest code from the code repository.
D
duangavin123 已提交
18

S
shawn_he 已提交
19
- **Method 2**: Acquire the source code from [DevEco Marketplace](https://repo.harmonyos.com/#/en/home). Visit [DevEco Marketplace](https://repo.harmonyos.com/#/en/home), search for your desired open source distribution, and download the component list (or customize components and download the component list). Then use the **hpm-cli** tool to download and install the components and compilation toolchain on your local PC.
D
duangavin123 已提交
20

S
shawn_he 已提交
21
- **Method 3**: Download the compressed file of a distribution from a mirror site. This method provides a fast download speed, so you can also use this method for obtaining the source code of an earlier version.
D
duangavin123 已提交
22

S
shawn_he 已提交
23
- **Method 4**: Acquire the source code from the GitHub image repository. You can use the **repo** or **git** tool to download the latest code from the code repository.
D
duangavin123 已提交
24 25


S
shawn_he 已提交
26
## Method 1: Acquiring Source Code from the Gitee Code Repository
D
duangavin123 已提交
27 28


S
shawn_he 已提交
29
### When to Use
D
duangavin123 已提交
30

S
shawn_he 已提交
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
- You want to establish a baseline based on stable OpenHarmony releases and distribute the baseline to your customers.

- You have interconnected your software with OpenHarmony and need official certification from OpenHarmony.

- You want to contribute code to the OpenHarmony community after obtaining official OpenHarmony certification for chips, modules, and applications.

- You need to rectify OpenHarmony issues.

- You want to learn OpenHarmony source code.


### Prerequisites

1. Register your account with Gitee.

2. Register an SSH public key for access to Gitee.

3. Install the [Git client](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading), and configure basic user information.
  
   ```shell
   git config --global user.name "yourname"
   git config --global user.email "your-email-address"
   git config --global credential.helper store
   ```

4. Install the **repo** tool:
D
duangavin123 已提交
57

S
shawn_he 已提交
58 59
   In this example, **~/bin** is used as an example installation directory. You can change the directory as needed.
  
S
shawn_he 已提交
60
   ```shell
S
shawn_he 已提交
61 62 63 64 65 66 67 68
   mkdir ~/bin
   curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o ~/bin/repo 
   chmod a+x ~/bin/repo
   pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
   ```

5. Add the path of the **repo** tool to environment variables.

S
shawn_he 已提交
69
   ```shell
S
shawn_he 已提交
70 71 72 73
   vim ~/.bashrc               # Edit environment variables.
   export PATH=~/bin:$PATH     # Add the path of the **repo** tool to the end of environment variables.
   source ~/.bashrc            # Apply environment variables.
   ```
D
duangavin123 已提交
74

W
wenjun 已提交
75

S
shawn_he 已提交
76
### How to Use
D
duangavin123 已提交
77 78


S
shawn_he 已提交
79
> **NOTE**<br>
S
shawn_he 已提交
80
>
S
shawn_he 已提交
81
> Download the release code, which is more stable, if you want to develop commercial functionalities. Download the master code if you want to get quick access to the latest features for your development.
82

S
shawn_he 已提交
83
- **Obtaining OpenHarmony release code**
84

S
shawn_he 已提交
85
  For details about how to obtain the source code of an OpenHarmony release, see the [Release Notes](../../release-notes/Readme.md).
D
duangavin123 已提交
86

S
shawn_he 已提交
87 88 89 90 91 92 93 94 95
- **Obtaining OpenHarmony master code**
  
  Method 1 (recommended): Use the **repo** tool to download the source code over SSH. (You must have registered an SSH public key for access to Gitee.)
  
  ```shell
  repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify
  repo sync -c
  repo forall -c 'git lfs pull'
  ```
D
duangavin123 已提交
96

S
shawn_he 已提交
97
  Method 2: Use the **repo** tool to download the source code over HTTPS.
D
duangavin123 已提交
98

S
shawn_he 已提交
99 100 101 102 103 104
  
  ```shell
  repo init -u https://gitee.com/openharmony/manifest.git -b master --no-repo-verify
  repo sync -c
  repo forall -c 'git lfs pull'
  ```
D
duangavin123 已提交
105 106


S
shawn_he 已提交
107
## Method 2: Acquiring Source Code from DevEco Marketplace
D
duangavin123 已提交
108 109


S
shawn_he 已提交
110
### When to Use
D
duangavin123 已提交
111

S
shawn_he 已提交
112
If OpenHarmony is new to you, sample solutions are helpful to your development. You can obtain an open source distribution from [DevEco Marketplace](https://repo.harmonyos.com/#/en/home), or customize a distribution by adding or deleting components of an open source distribution. Then use the **hpm-cli** tool to download and install the components and compilation toolchain on your local PC.
D
duangavin123 已提交
113 114


S
shawn_he 已提交
115
### Prerequisites
D
duangavin123 已提交
116

S
shawn_he 已提交
117
You must install **Node.js** and HPM on your local PC. The installation procedure is as follows:
D
duangavin123 已提交
118

S
shawn_he 已提交
119
1. Install **Node.js**.
D
duangavin123 已提交
120

S
shawn_he 已提交
121
   Download **Node.js** from its official website, and install it on your local PC.
D
duangavin123 已提交
122

S
shawn_he 已提交
123
   The [Node.js](https://nodejs.org/) version must be 12.x (including npm 6.14.4) or later. An LTS version is recommended.
D
duangavin123 已提交
124

S
shawn_he 已提交
125
2. Install the **hpm-cli** tool using **npm** delivered with **Node.js**.
D
duangavin123 已提交
126

S
shawn_he 已提交
127 128 129 130 131
   Open the CMD window, and run the following command:
     
   ```shell
   npm install -g @ohos/hpm-cli
   ```
D
duangavin123 已提交
132

S
shawn_he 已提交
133 134 135 136 137
3. Run the following command to check whether the installation is successful. If the HPM version is displayed, the installation is successful.
  
   ```shell
   hpm -V or hpm --version
   ```
D
duangavin123 已提交
138

S
shawn_he 已提交
139 140 141 142 143
4. Upgrade the HPM version as needed.
  
   ```shell
   npm update -g @ohos/hpm-cli
   ```
D
duangavin123 已提交
144 145


S
shawn_he 已提交
146
### How to Use
D
duangavin123 已提交
147

S
shawn_he 已提交
148 149 150 151 152
1. Search for distributions.
   1. Access [DevEco Marketplace](https://repo.harmonyos.com/#/en/home), and click **Device**. Then go to the **Open Source Distribution** page.
   2. Enter a keyword, for example, **camera**, in the search box. All matched distributions are displayed.
   3. Specify filter criteria, such as the OS, board, and kernel, to further filter the distributions.
   4. Find your desired distribution, and click it to view details.
D
duangavin123 已提交
153

S
shawn_he 已提交
154
         **Figure 1** HPM page
D
duangavin123 已提交
155

S
shawn_he 已提交
156
         ![](figures/hpm-page.png "hpm-page")
D
duangavin123 已提交
157

S
shawn_he 已提交
158 159 160 161
2. Learn more about the distribution.
   1. Read carefully the information about the distribution to learn its application scenarios, features, components, usage, and customization methods.
   2. Click **Download** if you want to download the distribution to your local PC.
   3. Click **Device component tailoring** if you want to add or delete components of the distribution.
D
duangavin123 已提交
162

S
shawn_he 已提交
163
         **Figure 2** Example distribution
D
duangavin123 已提交
164

S
shawn_he 已提交
165
         ![](figures/example-distribution.png "example-distribution")
D
duangavin123 已提交
166

S
shawn_he 已提交
167 168 169 170 171 172 173
3. Customize components.
   1. Access the **Device Component Tailoring** page.
   2. Add or delete components.
      - In the **Customizable Components** pane, click the plus sign. In the displayed dialog box, add required components.
      - In the **Customizable Components** pane, click the minus sign next to a component to delete it.
   3. Enter the basic information about your project, including the name, version, and description, on the right pane.
   4. Click **Download**. The system generates the OpenHarmony code structure file (for example, **my_cust_dist.zip**) and saves it to your local PC.
D
duangavin123 已提交
174

S
shawn_he 已提交
175
         **Figure 3** Customizing components
D
duangavin123 已提交
176

S
shawn_he 已提交
177
         ![](figures/customizing-components.png "customizing-components")
D
duangavin123 已提交
178

S
shawn_he 已提交
179 180 181 182
4. Install components.
   1. Decompress the downloaded code structure file using CMD on Windows (or shell in Linux).
   2. In the generated directory, run the **hpm install** command to download and install components. If the **Install successful** message is displayed, the command has been executed successfully.
   3. The downloaded components will be stored in the **ohos_bundles** folder under the project directory. (The source code of some components will be copied to a specified directory after the components are installed.)
D
duangavin123 已提交
183 184


S
shawn_he 已提交
185
## Method 3: Acquiring Source Code from a Mirror Site
W
wenjun 已提交
186

N
NEEN 已提交
187
To ensure the download performance, you are advised to download the source code or the corresponding solution from the image library of the respective site listed in the table below.
W
wenjun 已提交
188

S
shawn_he 已提交
189
The table below provides only the sites for downloading the latest OpenHarmony LTS code. For details about how to obtain the source code of earlier versions, see the [Release Notes](../../release-notes/Readme.md).
N
NEEN 已提交
190

S
shawn_he 已提交
191
  **Table 1** Sites for acquiring source code
W
wenjun 已提交
192

S
shawn_he 已提交
193 194 195 196 197 198 199 200 201 202
| **LTS Code**| **Version**| **Site**| **SHA-256 Checksum**| **Software Package Size**|
| -------- | -------- | -------- | -------- | -------- |
| Full code base (for mini, small, and standard systems)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/code-v3.0-LTS.tar.gz) | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/code-v3.0-LTS.tar.gz.sha256)| 7.0 GB |
| Standard system solution (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/standard.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/standard.tar.gz.sha256)| 973.7 MB |
| Hi3861 solution (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_pegasus.tar.gz.sha256)| 16.5 MB |
| Hi3518 solution (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_aries.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_aries.tar.gz.sha256)| 158.1 MB |
| Hi3516 solution-LiteOS (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus.tar.gz) | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus.tar.gz)| 248.9 MB |
| Hi3516 solution-Linux (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz.sha256) | 418.1 MB |
| RELEASE-NOTES | 3.0 | [Download](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.0-LTS/en/release-notes/OpenHarmony-v3.0-LTS.md)| - | - |
| **Source Code of the Latest Release**| **Version**| **Site**| **SHA-256 Checksum**| **Software Package Size**|
S
shawn_he 已提交
203
| Full code beta (for mini, small, and standard systems)| 3.2 Release    | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release/code-v3.2-Release.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release/code-v3.2-Release.tar.gz.sha256)| 21.8 GB |
S
shawn_he 已提交
204
| Hi3861 solution (binary)       | 3.2 Release| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release/hispark_pegasus.tar.gz.sha256)| 22.9 MB |
S
shawn_he 已提交
205 206
| Hi3516 solution-LiteOS (binary)| 3.2 Release| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Release/hispark_taurus_LiteOS.tar.gz) | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Release/hispark_taurus_LiteOS.tar.gz.sha256) | 294.3 MB |
| Hi3516 solution-Linux (binary) | 3.2 Release| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Release/hispark_taurus_Linux.tar.gz) | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Release/hispark_taurus_Linux.tar.gz.sha256) | 174.3 MB |
S
shawn_he 已提交
207 208
| RK3568 standard system solution (binary)       | 3.2 Release| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release//dayu200_standard_arm32.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release//dayu200_standard_arm32.tar.gz.sha256)| 3.9 GB |
| RELEASE-NOTES | 3.2 Release| [Download](../../release-notes/OpenHarmony-v3.2-release.md)| - | - |
S
shawn_he 已提交
209
| **Compiler Toolchain**| **Version**| **Site**| **SHA-256 Checksum**| Software Package Size|
S
shawn_he 已提交
210
| Compiler toolchain| - | [Download](https://repo.huaweicloud.com/openharmony/os/2.0/tool_chain/)| - | - |
W
wenjun 已提交
211

S
shawn_he 已提交
212

S
shawn_he 已提交
213 214 215
## Method 4: Acquiring Source Code from the GitHub Image Repository

> **NOTE**<br>
S
shawn_he 已提交
216 217
> The image repository is synchronized at 23:00 (UTC +8:00) every day.

S
shawn_he 已提交
218 219

Method 1 (recommended): Use the **repo** tool to download the source code over SSH. (You must have registered an SSH public key for access to GitHub. For details, see [Adding a new SSH key to your GitHub account](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account).)
S
shawn_he 已提交
220

S
shawn_he 已提交
221
```shell
D
duangavin123 已提交
222 223 224 225
repo init -u git@github.com:openharmony/manifest.git -b master --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
```
S
shawn_he 已提交
226

S
shawn_he 已提交
227
Method 2: Use the **repo** tool to download the source code over HTTPS.
S
shawn_he 已提交
228

S
shawn_he 已提交
229

S
shawn_he 已提交
230
```shell
D
duangavin123 已提交
231 232 233 234
repo init -u https://github.com/openharmony/manifest.git -b master --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
```
S
shawn_he 已提交
235

S
shawn_he 已提交
236 237

## Source Code Directories
W
wenjun 已提交
238 239 240

The following table describes the OpenHarmony source code directories.

S
shawn_he 已提交
241
  **Table 2** Source code directories
W
wenjun 已提交
242

S
shawn_he 已提交
243
| **Directory**| **Description**|
S
shawn_he 已提交
244 245 246
| -------- | -------- |
| applications | Application samples, for example, **camera**.|
| base | Basic software service subsystem set and hardware service subsystem set.|
S
shawn_he 已提交
247
| build | Component-based compilation, building, and configuration scripts.|
S
shawn_he 已提交
248 249 250 251 252 253 254
| docs | Reference documents.|
| domains | Enhanced software service subsystem set.|
| drivers | Driver subsystem.|
| foundation | Basic system capability subsystem set.|
| kernel | Kernel subsystem.|
| prebuilts | Compiler and tool chain subsystem.|
| test | Test subsystem.|
S
shawn_he 已提交
255
| third_party | Open source third-party software.|
S
shawn_he 已提交
256 257 258
| utils | Commonly used development utilities.|
| vendor | Vendor-provided software.|
| build.py | Build script file.|