同步操作将从 OpenHarmony/docs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
Operating system: 64-bit version of Ubuntu 16.04 or later.
Perform the following steps to set up the build environment:
NOTICE:
- Docker is provided for the Ubuntu build environment, which encapsulates related build tools. If you use Docker to prepare the build environment, you do not need to perform the following steps in this section. Instead, refer to Using Docker to Prepare the Build Environment.
- By default, basic software, such as Samba and Vim, is installed in the system. Adaptation on the software is required to support file sharing between the Linux server and the Windows workstation.
- For details about the compilation and building subsystem of OpenHarmony, see the Compilation and Building Overview.
The following table describes the tools and source code required for setting up the general environment for a Linux server and how to obtain these tools and the source code.
Table 1 Source code and development tools and their obtaining methods
NOTICE:
- If you acquire the source code using an HPM component or HPM CLI tool, you do not need to install compilation tools like gn and ninja.
- (Recommended) If you obtain the source code via the mirror site or code repository, install compilation tools such as gn, ninja, and LLVM. When installing these tools, ensure that their environment variable paths are unique.
You need to acquire source code, download it on a Linux server, and decompress it.
Start a Linux server.
Check the Python version (Python 3.7 or later is required).
python3 --version
If Python version is earlier than 3.7, reinstall Python. Do as follows to install Python, for example, Python 3.8.
cat /etc/issue
If the Ubuntu version is 18 or later, run the following command:
sudo apt-get install python3.8
If the Ubuntu version is 16, perform the following steps:
a. Install dependency packages.
sudo apt update && sudo apt install software-properties-common
b. Add the source of deadsnakes PPA and press Enter.
sudo add-apt-repository ppa:deadsnakes/ppa
c. Install Python 3.8.
sudo apt upgrade && sudo apt install python3.8
Set the soft link of python and python3 to python3.8.
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
Install and upgrade the Python package management tool (pip3) using either of the following methods:
Command line:
sudo apt-get install python3-setuptools python3-pip -y
sudo pip3 install --upgrade pip
Installation package:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
Start a Linux server.
Download gn.
Create the gn folder in the root directory.
mkdir ~/gn
Decompress the gn installation package to ~/gn.
tar -xvf gn-linux-x86-1717.tar.gz -C ~/gn
Set an environment variable.
vim ~/.bashrc
Copy the following command to the last line of the .bashrc file, save the file, and exit.
export PATH=~/gn:$PATH
Validate the environment variable.
source ~/.bashrc
Start a Linux server.
Download ninja.
Decompress the ninja installation package to ~/ninja.
tar -xvf ninja.1.9.0.tar -C ~/
Set an environment variable.
vim ~/.bashrc
Copy the following command to the last line of the .bashrc file, save the file, and exit.
export PATH=~/ninja:$PATH
Validate the environment variable.
source ~/.bashrc
Start a Linux server.
Download hc-gen.
Decompress the hc-gen installation package to ~/hc-gen on the Linux server.
tar -xvf hc-gen-0.65-linux.tar -C ~/
Set an environment variable.
vim ~/.bashrc
Copy the following command to the last line of the .bashrc file, save the file, and exit.
export PATH=~/hc-gen:$PATH
Validate the environment variable.
source ~/.bashrc
Start a Linux server.
NOTE: For the OpenHarmony_1.0.1_release, click here to download LLVM.
Decompress the LLVM installation package to ~/llvm.
tar -zxvf llvm.tar.gz -C ~/
NOTE: For the OpenHarmony_1.0.1_release, run the following command to decompress the LLVM installation package:
tar -xvf llvm-linux-9.0.0-36191.tar -C ~/
Set an environment variable.
vim ~/.bashrc
Copy the following command to the last line of the .bashrc file, save the file, and exit.
export PATH=~/llvm/bin:$PATH
Validate the environment variable.
source ~/.bashrc
Python 3.7.4 or later has been installed. For details, see Installing and Configuring Python.
Install hb.
python3 -m pip install --user ohos-build
Set an environment variable.
vim ~/.bashrc
Copy the following command to the last line of the .bashrc file, save the file, and exit.
export PATH=~/.local/bin:$PATH
Update the environment variable.
source ~/.bashrc
Run the hb -h command. If the following information is displayed, the installation is successful:
usage: hb
OHOS build system
positional arguments:
{build,set,env,clean}
build Build source code
set OHOS build settings
env Show OHOS build env
clean Clean output
optional arguments:
-h, --help Show this help message and exit
python3 -m pip uninstall ohos-build
NOTICE: If you encounter any problem during the installation, resort to the FAQ.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。