Linux上搭建 OpenHarmonyOS 编译环境

参考

主要是参考这两篇文章

https://raamdev.com/2008/howto-install-md5sum-sha1sum-on-mac-os-x/

https://blog.csdn.net/nanzhanfei/article/details/121951919

apt换源

  • 备份原来的源
cp -ra /etc/apt/sources.list /etc/apt/sources.list.bak
  • 将源换成阿里源
sudo vim /etc/apt/sources.list
  • 将里面的内容清空,把下面的内容复制进去,保存退出
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
  • 更新和升级
sudo apt-get update
sudo apt-get upgrade

python

sudo apt-get -y update
sudo apt-get install python3
sudo apt-get install python3-pip
sudo ln -s /usr/bin/python3.8 /usr/bin/python

install git

sudo apt install git-all

gitee账号信息

  • 生成公私钥
ssh-keygen -t rsa -C "message"
  • 注册gitee

  • 将本机ssh公钥放置gitee上

configure git

git config --global user.name "binny111"
git config --global user.email "[email protected]"
git config --global credential.helper store

install git-lfs

  • 方式1(行不通,410了)
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash

sudo apt-get install git-lfs

git lfs install
  • 方式2

https://gitee.com/mirrors/git-lfs?_from=gitee_search

install repo

curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo
chmod a+x /usr/local/bin/repo
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple requests

下载源码

repo init -u [email protected]:openharmony/manifest.git -b master --no-repo-verify

同步源码

repo sync -c -d -j8 --force-sync --fail-fast -q --no-tags --prune ; repo forall -j8 -c "git lfs pull"
  • 或者
repo sync -c

同步大文件

  • 好像是编译器之类的,没仔细看日志
repo forall -c 'git lfs pull'

rk3568对应仓库

路径可能有改变

编译

安装依赖工具

ubuntu

sudo apt-get update && sudo apt-get install binutils  gnupg flex bison gperf build-essential zip  zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev genext2fs liblz4-tool libssl-dev libtinfo5 lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin  ruby

java环境

  • 没有的话,安装
sudo apt install openjdk-17-jre-headless

prebuilts

  • 执行prebuilts,在源码根目录下执行,安装编译器及二进制工具
sudo bash build/prebuilts_download.sh –no-check-certificatie-skip-ssl
  • 缺少补啥
sudo npm i -g nan

编译 SDK

sudo ./build.sh --product-name ohos-sdk
root@ohos:~/ohos# sudo ./build.sh --product-name ohos-sdk
++++++++++++++++++++++++++++++++++++++++
2022-05-25 14:21:08
--product-name ohos-sdk
[OHOS INFO] Set cache size limit to 50.0 GB
[OHOS INFO] root_out_dir=//out/sdk
[OHOS INFO] root_build_dir=//out/sdk
[OHOS INFO] root_gen_dir=//out/sdk/gen
[OHOS INFO] current_toolchain=//build/toolchain/ohos:ohos_clang_arm64
[OHOS INFO] host_toolchain=//build/toolchain/linux:clang_x64
[OHOS INFO]
[OHOS INFO] args: Namespace(platforms_config_file='/root/ohos/out/preloader/ohos-sdk/platforms.build', subsystem_config_file='/root/ohos/out/preloader/ohos-sdk/subsystem_config.json', example_subsystem_file=None, source_root_dir='/root/ohos/', gn_root_out_dir='/root/ohos/out/sdk', build_platform_name='phone', build_xts=False, target_os='ohos', target_cpu='arm64', os_level='standard', ignore_api_check=['xts', 'common', 'developertest'], scalable_build=False)
[OHOS INFO]
[OHOS INFO] build configs generation is complete.

你可能感兴趣的:(Linux上搭建 OpenHarmonyOS 编译环境)