1 Star 0 Fork 5.1K

youguilin / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
ubuntu-build-environment-10.md 5.87 KB
一键复制 编辑 原始数据 按行查看 历史

Ubuntu Build Environment

You can use either the Docker environment or installation package provided by OpenHarmony to set up a Ubuntu build environment. This section describes the two methods.

Setting up a Ubuntu Build Environment Using a Docker Environment

The standard OpenHarmony system provides a Docker environment which encapsulates build tools. To use the Docker environment, perform the following steps:

  1. Obtain the system source code.
  2. Install and use the Docker environment.

Obtaining System Source Code

For details, see Source Code Acquisition.

Installing and Using the Docker Environment

For details, see Installing and Using Docker.

Setting up a Ubuntu Build Environment Using an Installation Package

The procedure is as follows:

  1. Obtain the system source code.
  2. Install dependent tools.
  3. Obtain prebuilts.
  4. Configure the Node.js environment and obtain the Node_modules dependency package.
  5. Install the hc-gen tool.

Obtaining Standard-System Source Code

For details, see Source Code Acquisition.

Installing Dependent Tools

The installation command is as follows:

sudo apt-get install binutils git-core git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 python2.7 python-minimal

Obtaining prebuilts

  1. Go to the OpenHarmony working directory.

    cd OpenHarmony
  2. Download the script.

    curl https://gitee.com/landwind/script-tools/raw/master/Shell/OpenHarmony/OpenHarmony_2.0_canary_prebuilts_download.sh >./prebuilts_download.sh
  3. Download and decompress the prebuilts package in a specified directory.

    bash ./prebuilts_download.sh

    By default, binary files are stored in the OpenHarmony_2.0_canary_prebuilts directory, which is in the same directory as OpenHarmony. To change the storage path, change the value of bin_dir in prebuilts_download.sh.

  4. Return to the previous directory.

    cd -

Configuring the Node.js Environment and Obtaining the Node_modules Dependency Package

To build the JS framework, you need to download and configure Node.js on a Linux server. The procedure is as follows:

  1. Download Node.js on a Linux server.

    mkdir -p OpenHarmony/prebuilts/build-tools/common/nodejs                                # Create the nodejs directory.
    cd OpenHarmony/prebuilts/build-tools/common/nodejs                                      # Go to the nodejs directory.
    wget --no-check-certificate https://nodejs.org/download/release/v12.18.4/node-v12.18.4-linux-x64.tar.gz # Download the Node.js package.
  2. Decompress the Node.js package and configure the Node.js environment.

    tar -zxvf node-v12.18.4-linux-x64.tar.gz                                                      # Decompress the Node.js package.
    echo "export PATH=`pwd`/node-v12.18.4-linux-x64/bin:${PATH}" >> ~/.bashrc;source ~/.bashrc    # Set a Node.js environment variable.
    cd -                                                                                          # Return to the previous directory.
  3. Go to the third_party/jsframework directory of the OpenHarmony code and download the node_modules package.

    cd OpenHarmony/third_party/jsframework                  # Go to the jsframework directory.
    npm install                                             # Download the node_modules package.
    cd -                                                    # Return to the previous directory.
  4. Store the node_modules package in the prebuilts/build-tools/common/js-framework directory of the OpenHarmony code.

    mkdir -p OpenHarmony/prebuilts/build-tools/common/js-framework          # Create the js-framework directory.
    cp -rp OpenHarmony/third_party/jsframework/node_modules OpenHarmony/prebuilts/build-tools/common/js-framework/

Installing the hc-gen Tool

hc-gen is used to compile the driver. To install hc-gen, perform the following steps:

  1. Start a Linux server.

  2. Download hc-gen.

  3. Decompress the hc-gen installation package to ~/hc-gen on the Linux server.

    tar -xvf hc-gen-0.65-linux.tar -C ~/
  4. 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
  5. Validate the environment variable.

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

搜索帮助

53164aa7 5694891 3bd8fe86 5694891