bundles-demo-environment.md 4.8 KB
Newer Older
D
duangavin123 已提交
1
# Configuring the Compilation Environment<a name="EN-US_TOPIC_0000001071315859"></a>
Y
yangni 已提交
2 3 4

-   [Linux Server](#section20979554791)
-   [Node.js](#section9954105413153)
D
duangavin123 已提交
5
-   [Installing hpm-cli Tool](#section15937194904819)
Y
yangni 已提交
6 7 8 9
-   [Python Environment](#section1621819180417)
-   [File Packaging Tool](#section77617165913)
-   [SCons](#section20558439191516)

D
duangavin123 已提交
10 11
![](figure/3516dv300.png)

Y
yangni 已提交
12 13
## Linux Server<a name="section20979554791"></a>

D
duangavin123 已提交
14
Prepare a 64-bit Linux server running Ubuntu 16.04 or later. \(Currently, the compilation in the Windows environment is not fully supported.\)
Y
yangni 已提交
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

Configure Ubuntu to use bash as the Linux system shell, by performing the following:

```
ls -l $(which sh)
# If the file does not point to bash, modify the file using either of the provided methods.
# Method 1: Run the following command and select no:
dpkg-reconfigure dash
# Method 2: Run the following commands to delete /bin/sh and then create a new symbolic link to bash:
rm -f /bin/sh
ln -s bash /bin/sh
```

## Node.js<a name="section9954105413153"></a>

D
duangavin123 已提交
30
>![](../public_sys-resources/icon-note.gif) **NOTE:** 
D
duangavin123 已提交
31
>If the  **Node.js**  version of the source is outdated, run the following command before running  **apt-get install**:
M
mamingshuai 已提交
32 33 34 35
>```
>curl -L https://deb.nodesource.com/setup_12.x | bash
>```

Y
yangni 已提交
36 37 38 39 40 41 42
You are advised to install Node.js 12.x \(including npm 6.14.4\) or a later version \(12.13.0 or later is recommended\).

```
sudo apt-get install nodejs
sudo apt-get install npm
```

D
duangavin123 已提交
43
Run the following commands to view  **Node.js**  and npm versions:
Y
yangni 已提交
44 45 46

```
node --version  # Check the Node.js version.
D
duangavin123 已提交
47
npm --version   # Check the npm version.
Y
yangni 已提交
48 49
```

D
duangavin123 已提交
50
## Installing hpm-cli Tool<a name="section15937194904819"></a>
Y
yangni 已提交
51

D
duangavin123 已提交
52
Install the  **hpm-cli**  command line tool by using the npm \(default source: https://registry.npmjs.org/\) provided by  **Node.js**.
Y
yangni 已提交
53 54 55 56 57

```
npm install -g @ohos/hpm-cli
```

D
duangavin123 已提交
58
After  **hpm-cli**  is installed, run the following command to view the default hpm configurations:
Y
yangni 已提交
59 60 61 62 63

```
hpm config
```

D
duangavin123 已提交
64
You can modify the default configurations as required. The following lists common hpm configurations:
Y
yangni 已提交
65 66

```
D
duangavin123 已提交
67
registry = https://hpm.harmonyos.com              # Address of the hpm registry. This is mandatory for downloading bundles.
Y
yangni 已提交
68 69 70 71 72
strictSsl = true                                  # Enable strict SSL verification as HTTPS is used for connection.
http_proxy = http://your-proxy-server:port        # Configure the HTTP proxy.
https_proxy = http://your-proxy-server:port       # Configure the HTTPS proxy.
```

D
duangavin123 已提交
73
For details about  **hpm-cli**  commands, see  [HPM Commands](bundles-standard-rules.md).
Y
yangni 已提交
74 75 76 77 78 79 80 81 82 83 84 85

## Python Environment<a name="section1621819180417"></a>

Run the following commands to install Python later than 3.7:

```
sudo apt-get install python3.8
sudo apt-get install python3-pip
sudo pip3 install setuptools
sudo pip3 install kconfiglib  # Install kconfiglib 13.2.0 or later.
```

D
duangavin123 已提交
86
>![](../public_sys-resources/icon-note.gif) **NOTE:** 
Y
yangni 已提交
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
>The preceding method is applicable to Hi3518 and Hi3516 platforms. For Hi3861, run the following commands to install the Python environment:
>```
>sudo apt-get install python3.8
>sudo apt-get install python3-pip
>sudo pip3 install setuptools
>sudo pip3 install kconfiglib  # Install kconfiglib 13.2.0 or later.
>sudo pip3 install pycryptodome
>sudo pip3 install six --upgrade --ignore-installed six
>sudo pip3 install ecdsa
>```

If both Python2 and Python3 have been installed in the current system, run the following commands to set the default Python to Python3:

```
ll `which python`
rm /usr/bin/python
ln -s python3.8 /usr/bin/python
```

## File Packaging Tool<a name="section77617165913"></a>

Run the following commands to install the tool:

```
which mkfs.vfat  # If mkfs.vfat is not found, run the following command:
sudo apt-get install dosfstools
which mcopy # If mcopy is not found, run the following command:
sudo apt-get install mtools
```

D
duangavin123 已提交
117
>![](../public_sys-resources/icon-note.gif) **NOTE:** 
Y
yangni 已提交
118 119 120 121
>Both Hi3518 and Hi3516 platforms require the file packaging tool. For Hi3861, the tool is not required.

## SCons<a name="section20558439191516"></a>

M
mamingshuai 已提交
122 123 124 125 126 127 128
1.  Start a Linux server.
2.  Run the following command to install the SCons installation package:

    ```
    python3 -m pip install scons
    ```

D
duangavin123 已提交
129
3.  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.
M
mamingshuai 已提交
130 131 132 133 134 135

    ```
    scons -v
    ```

    **Figure  1**  Successful installation \(SCons version requirement: 3.0.4 or later\)<a name="fig235815252492"></a>  
D
duangavin123 已提交
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")
Y
yangni 已提交
137 138


D
duangavin123 已提交
139
>![](../public_sys-resources/icon-note.gif) **NOTE:** 
Y
yangni 已提交
140 141
>SCons is required for the Hi3861 platform, but not for the Hi3518 or Hi3516 platform.