1 Star 0 Fork 5.1K

youguilin / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
tool-acquisition.md 13.74 KB
一键复制 编辑 原始数据 按行查看 历史
mamingshuai 提交于 2021-06-02 01:00 . update OpenHarmony 2.0 Canary

Tool Acquisition

How to Obtain the Docker Environment

OpenHarmony provides the following two types of Docker environments for you to quickly get the development environment ready:

  • HPM-based Docker environment: applicable when using the HarmonyOS Package Manager (HPM) to build a distribution.

  • Standalone Docker environment: applicable when using Ubuntu or Windows to build a distribution.

    The following table lists container-based options needed for building in the standalone Docker environment.

    Table 1 Docker image

    Docker Image Repository

    Tag

    Description

    swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker

    0.0.3

    The OpenHarmony build environment has been pre-installed. This repository applies to Mini-System Devices (reference memory ≥ 128 KB) and Small-System Devices (reference memory ≥ 1 MB).

    swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard

    0.0.1

    The OpenHarmony build environment has been pre-installed. This repository applies to Standard-System Devices (reference memory ≥ 128 MB).

    NOTE: For details about how to install Docker, see Install Docker Engine on Ubuntu.

HPM-based Docker

docker_dist is a template component in the HPM system. It helps to quickly initialize an HPM project and use the Docker image to quickly build a distribution of OpenHarmony, greatly simplifying environment configurations needed for building. After configuring the Ubuntu and hpm-cli development environments, perform the following steps to access the Docker environment:

Setting Up the Docker Environment

  1. Initialize the installation template by running the following command in any of the working directories:

    hpm init -t @ohos/docker_dist
  2. Modify the publishAs field.

    The obtained bundle is of the template type. Open the bundle.json file in the current directory and change the value of publishAs from template to distribution as needed.

Building

Start building. Docker can be automatically installed only on Ubuntu. If you are using any other operating system, manually install Docker before pulling the image.

  • Automatically Installing Docker (Ubuntu)

    Running the following command will automatically install the Docker, pull the image, and start the pulling and building of the corresponding solution in the container.

    Method 1:

    Add a parameter to specify the solution. For example:

    hpm run docker solution={product}

    {product} indicates the solution, for example, @ohos/hispark_taurus, @ohos/hispark_aries, and @ohos/hispark_pegasus.

    Method 2:

    Set an environment variable to specify the solution, and then run the build command.

    1. Select the desired solution.
    export solution={product}

    {product} indicates the solution, for example, @ohos/hispark_taurus, @ohos/hispark_aries, and @ohos/hispark_pegasus.

    1. Start building.
    hpm run docker

    This example uses the @ohos/hispark_taurus solution for illustration. If the execution is successful, the output is as follows:

    ...
    ohos ipcamera_hispark_taurus build success!
    @ohos/hispark_taurus: distribution building completed.
  • Manually Installing Docker (Non-Ubuntu)

    Perform the following operations to install Docker:

    # Pull the image.
    docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.3
    # Build the distribution on Linux.
    hpm run distWithDocker solution={product}
    # When using Windows, make sure to configure the Git Bash.
    hpm config set shellPath "Git Bash path"
    hpm run distWithDocker solution={product}

Standalone Docker Environment

The Docker image of OpenHarmony is hosted on HUAWEI Cloud SWR. Using the Docker image will help simplify environment configurations needed for the building. After configuring the development environments, perform the procedures below to access the Docker environment. Both Ubuntu and Windows are supported. The following procedures use Ubuntu as an example.

Setting Up the Docker Environment for Mini-System Devices (reference memory ≥ 128 KB) and Small-System Devices (reference memory ≥ 1 MB)

Method 1: Obtaining the Docker image from HuaweiCloud SWR

  1. Obtain the Docker image.

    docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.3
  2. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment:

    docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.3

Method 2: Using the Dockerfile to Build a Local Docker Image

  1. Obtain the Dockerfile script for a local Docker image.

    git clone https://gitee.com/openharmony/docs.git
  2. Go to the directory of the Dockerfile code and run the following command to build the Docker image:

    cd docs/docker
    ./build.sh
  3. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment:

    docker run -it -v $(pwd):/home/openharmony openharmony-docker:0.0.3

Building for Mini-System Devices (reference memory ≥ 128 KB) and Small-System Devices (reference memory ≥ 1 MB)

The following uses the Hi3516 platform as an example to describe the build procedure. Run the following build scripts to start building:

Set the build path to the current path.

hb set
 .

Figure 1 Setting page

NOTE: The mapping between the development board and the building GUI:

  • Hi3861: wifiiot_hispark_pegasus@hisilicon
  • Hi3516: ipcamera_hispark_taurus@hisilicon
  • Hi3518: ipcamera_hispark_aries@hisilicon
  1. Select ipcamera_hispark_taurus@hisilicon and press Enter.

  2. Start building.

    hb build -f
  3. View the build result.

    The files will be generated in the out/hispark_taurus/ipcamera_hispark_taurus directory.

Setting Up the Docker Environment for Standard-System Devices (reference memory ≥ 128 MB)

Method 1: Obtaining the Docker image from HuaweiCloud SWR

  1. Obtain the Docker image.

    docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.1
  2. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment:

    docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.1

Method 2: Using the Dockerfile to Build a Local Docker Image

  1. Obtain the Dockerfile script for a local Docker image.

    git clone https://gitee.com/openharmony/docs.git
  2. Go to the directory of the Dockerfile code and run the following command to build the Docker image:

    cd docs/docker/standard
    ./build.sh
  3. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment:

    docker run -it -v $(pwd):/home/openharmony openharmony-docker-standard:0.0.1

Building for Standard-System Devices (reference memory ≥ 128 MB)

  1. Run the preprocessing script in the root directory of the source code.

    ../scripts/prepare.sh
  2. Run the following script to start building for Standard-System Devices (reference memory ≥ 128 MB).

    ./build.sh --product-name {product_name}

    product_name indicates the platform supported by the current distribution, for example, Hi3516D V300.

    Files generated during compilation are stored in the out/ohos-arm-release/ directory, and the generated image is stored in the out/ohos-arm-release/packages/phone/images/ directory.

NOTE: You can exit Docker by simply running the exit command.

Acquiring the Device Development Tool (HUAWEI DevEco Device Tool)

HUAWEI DevEco Device Tool is a one-stop integrated development environment (IDE) provided to develop applications for OpenHarmony-based smart devices. It allows on-demand customization of OpenHarmony components, code editing, compilation, burning, and debugging, and supports C and C++ languages. This tool is installed in Visual Studio Code as a plug-in. For details, see Tool Acquisition and HUAWEI DevEco Device Tool User Guide.

Acquiring the Application Development Tool (HUAWEI DevEco Studio)

HUAWEI DevEco Studio (DevEco Studio for short) is a one-stop IDE oriented to Huawei devices in all scenarios. It provides E2E OpenHarmony application development services, ranging from project template creation to development, compilation, debugging, and release. With DevEco Studio, you will be able to efficiently develop OpenHarmony applications with distributed capabilities while speeding up innovation. For details, see Tool Acquisition and HUAWEI DevEco Studio User Guide.

1
https://gitee.com/yougl/docs.git
git@gitee.com:yougl/docs.git
yougl
docs
docs
master

搜索帮助