Skip to main content

Building PolyOS Mobile on Ubuntu

Build Environment for PolyOS Mobile

The construction milieu for PolyOS Mobile necessitates primarily network download utilities, C/C++ compilation and construction tools, Java JDK, along with sundry other Linux utilities.

note

The composition of this document was validated utilizing Ubuntu 20.04. It ought to function aptly on versions such as 20.04, 20.10, 21.04, 21.10, 22.04, et cetera.

We are actively seeking enhancements to render this document's applicability across a broader spectrum of versions.

Dependency Installation

apt-get install bc bsdmainutils rsync ssh xsltproc genext2fs cpio gawk \
libelf-dev dwarves exuberant-ctags \
curl iputils-ping openssl net-tools wget \
mtools tofrodos \
silversearcher-ag \
liblz4-tool pigz unzip zip zlib1g-dev \
autoconf automake cmake m4 make scons texinfo \
build-essential ccache pkg-config \
default-jdk openjdk-8-jdk ca-certificates-java \
perl python python3 ruby tcl \
device-tree-compiler libfdt-dev kmod u-boot-tools \
mtd-utils \
dwarves exuberant-ctags flex bison \
gcc-multilib g++-multilib \
libncurses5-dev lib32ncurses5-dev lib32z1-dev libtool \
git patchutils subversion \
mpc libmpc-dev\
gperf \
libexpat-dev libxml2-dev libxml2-utils \
libglib2.0-dev \
libgl1-mesa-dev \
libpixman-1-dev \
libgmp-dev libmpc-dev libmpfr-dev \
libmount-dev \
openssl libssl-dev libssl1.1 \
libtinfo5 \
libx11-dev x11proto-core-dev \
python-crypto python3-crypto python3-xlrd python3-pip python3-yaml
tip

To expedite download speeds, you have the option to employ a Ubuntu mirror source located within your local region.

repo installtion

Since the PolyOS Mobile source code is spread across multiple repositories, you will also need to download the repo tool to easily access the PolyOS Mobile source code.

mkdir -p ~/.local/bin
curl -L https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o ~/.local/bin/repo
chmod a+x ~/.local/bin/repo

You can also choose to add ~/.local/bin to your PATH environment variable if you need to.

cat << EOF >> ~/.bashrc
export PATH=$HOME/.local/bin:$PATH
EOF
source ~/.bashrc

(Optional) Docker Build Environment

For those employing alternative Linux operating systems, you can launch a container endowed with the construction environment to facilitate the build.

sudo fdocker run -it --name polyos_mobile_build -v /path/to/polyos-mobile-code:/ployos-mobile swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0
tip

Should you be devoid of Docker, you can peruse the Docker installation guide to gain insight into installation methodologies.

Acquisition of Prebuilt Tools

The compilation of PolyOS Mobile hinges upon a collection of binary tools. We have consigned these to the project's build directory within the source code. A shell script for downloading and configuring these prebuilt binaries is at your disposal. Execution is straightforward:

bash /path/to/polyos-mobile-code/build/prebuilts_download.sh

Patiently await completion of this process; you shall receive a directory housing the prebuilt programs.

Compilation of PolyOS Mobile Source Code

PolyOS Mobile furnishes a script to oversee the build process. In the subsequent discourse, we shall employ a shell script named build.sh located at the root of the source code project to execute PolyOS Mobile construction with a refined granularity.

Compiling the Complete PolyOS Mobile

By specifying qemu_riscv64_virt_linux_system as the target for the build script, we instigate the construction of a comprehensive PolyOS Mobile image.

bash /path/to/polyos-mobile-code/build.sh --product-name qemu_riscv64_virt_linux_system --ccache

The duration of this process hinges upon your hardware's potency. Upon completion, the image will be ensconced within the out/riscv64_virt/packages/phone/images directory of the PolyOS Mobile source code repository.

tip

--ccache serves to cache intermediary artifacts of compilation, facilitating recuperation in case of build interruptions.

Compiling a PolyOS Mobile Module

For the purpose of individually compiling a PolyOS Mobile module, we transmit a concrete target to the build script.

bash /path/to/polyos-mobile-code/build.sh --product-name qemu_riscv64_virt_linux_system --ccache --build-target {target_name}

Supported Build Parameters

A comprehensive list of supported build parameters can be retrieved using the --help parameter:

bash /path/to/polyos-mobile-code/build.sh --help