• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Configuring the Compilation Environment<a name="EN-US_TOPIC_0000001071315859"></a>
2
3-   [Linux Server](#section20979554791)
4-   [Node.js](#section9954105413153)
5-   [Installing hpm-cli Tool](#section15937194904819)
6-   [Python Environment](#section1621819180417)
7-   [File Packaging Tool](#section77617165913)
8-   [SCons](#section20558439191516)
9
10![](figure/3516dv300.png)
11
12## Linux Server<a name="section20979554791"></a>
13
14Prepare a 64-bit Linux server running Ubuntu 16.04 or later. \(Currently, the compilation in the Windows environment is not fully supported.\)
15
16Configure Ubuntu to use bash as the Linux system shell, by performing the following:
17
18```
19ls -l $(which sh)
20# If the file does not point to bash, modify the file using either of the provided methods.
21# Method 1: Run the following command and select no:
22dpkg-reconfigure dash
23# Method 2: Run the following commands to delete /bin/sh and then create a new symbolic link to bash:
24rm -f /bin/sh
25ln -s bash /bin/sh
26```
27
28## Node.js<a name="section9954105413153"></a>
29
30>![](../public_sys-resources/icon-note.gif) **NOTE:**
31>If the  **Node.js**  version of the source is outdated, run the following command before running  **apt-get install**:
32>```
33>curl -L https://deb.nodesource.com/setup_12.x | bash
34>```
35
36You are advised to install Node.js 12.x \(including npm 6.14.4\) or a later version \(12.13.0 or later is recommended\).
37
38```
39sudo apt-get install nodejs
40sudo apt-get install npm
41```
42
43Run the following commands to view  **Node.js**  and npm versions:
44
45```
46node --version  # Check the Node.js version.
47npm --version   # Check the npm version.
48```
49
50## Installing hpm-cli Tool<a name="section15937194904819"></a>
51
52Install the  **hpm-cli**  command line tool by using the npm \(default source: https://registry.npmjs.org/\) provided by  **Node.js**.
53
54```
55npm install -g @ohos/hpm-cli
56```
57
58After  **hpm-cli**  is installed, run the following command to view the default hpm configurations:
59
60```
61hpm config
62```
63
64You can modify the default configurations as required. The following lists common hpm configurations:
65
66```
67registry = https://hpm.harmonyos.com              # Address of the hpm registry. This is mandatory for downloading bundles.
68strictSsl = true                                  # Enable strict SSL verification as HTTPS is used for connection.
69http_proxy = http://your-proxy-server:port        # Configure the HTTP proxy.
70https_proxy = http://your-proxy-server:port       # Configure the HTTPS proxy.
71```
72
73For details about  **hpm-cli**  commands, see  [HPM Commands](bundles-standard-rules.md).
74
75## Python Environment<a name="section1621819180417"></a>
76
77Run the following commands to install Python later than 3.7:
78
79```
80sudo apt-get install python3.8
81sudo apt-get install python3-pip
82sudo pip3 install setuptools
83sudo pip3 install kconfiglib  # Install kconfiglib 13.2.0 or later.
84```
85
86>![](../public_sys-resources/icon-note.gif) **NOTE:**
87>The preceding method is applicable to Hi3518 and Hi3516 platforms. For Hi3861, run the following commands to install the Python environment:
88>```
89>sudo apt-get install python3.8
90>sudo apt-get install python3-pip
91>sudo pip3 install setuptools
92>sudo pip3 install kconfiglib  # Install kconfiglib 13.2.0 or later.
93>sudo pip3 install pycryptodome
94>sudo pip3 install six --upgrade --ignore-installed six
95>sudo pip3 install ecdsa
96>```
97
98If both Python2 and Python3 have been installed in the current system, run the following commands to set the default Python to Python3:
99
100```
101ll `which python`
102rm /usr/bin/python
103ln -s python3.8 /usr/bin/python
104```
105
106## File Packaging Tool<a name="section77617165913"></a>
107
108Run the following commands to install the tool:
109
110```
111which mkfs.vfat  # If mkfs.vfat is not found, run the following command:
112sudo apt-get install dosfstools
113which mcopy # If mcopy is not found, run the following command:
114sudo apt-get install mtools
115```
116
117>![](../public_sys-resources/icon-note.gif) **NOTE:**
118>Both Hi3518 and Hi3516 platforms require the file packaging tool. For Hi3861, the tool is not required.
119
120## SCons<a name="section20558439191516"></a>
121
1221.  Start a Linux server.
1232.  Run the following command to install the SCons installation package:
124
125    ```
126    python3 -m pip install scons
127    ```
128
1293.  Run the following command to check whether SCons is successfully installed. If the installation is successful, the query result shown in  [Figure 1](#fig235815252492)  is displayed.
130
131    ```
132    scons -v
133    ```
134
135    **Figure  1**  Successful installation \(SCons version requirement: 3.0.4 or later\)<a name="fig235815252492"></a>
136    ![](figure/successful-installation-(scons-version-requirement-3-0-4-or-later)-28.png "successful-installation-(scons-version-requirement-3-0-4-or-later)-28")
137
138
139>![](../public_sys-resources/icon-note.gif) **NOTE:**
140>SCons is required for the Hi3861 platform, but not for the Hi3518 or Hi3516 platform.
141
142