开源鸿蒙OpenHarmony4.1源码下载、编译,生成OHOS_Image可实行文件的最简易流程
作者将狼才鲸日期2024-03-01
- 准备一台Windows电脑
- 安装VMware大概VMware Player虚拟机
- 从华为镜像下载Ubuntu系统,用国内源下载速度更快
- Ubuntu 镜像说明
- https://repo.huaweicloud.com/ubuntu-releases/ 选择要下载的系统版本
- https://repo.huaweicloud.com/ubuntu-releases/18.04.6/ubuntu-18.04.6-desktop-amd64.iso 我使用此链接下载
- 下载开源鸿蒙系统源码
- https://repo.huaweicloud.com/harmonyos/os/ 选择要下载的系统版本
- https://repo.huaweicloud.com/harmonyos/os/4.0-Release/code-v4.0-Release.tar.gz 我下载这个,28G
- 在VMware虚拟机中安装Ubuntu系统
- 安装完之后进入系统,使用命令行将官方源换成华为源,这样下载软件时更快
- 参考自:https://res-static.hc-cdn.cn/cloudbu-site/china/zh-cn/SEO/mirror/Ubuntu.pdf
- sudo cp -a /etc/apt/sources.list /etc/apt/sources.list.bak 备份设置文件
- sudo sed -i “s@http://.*archive.ubuntu.com@http://repo.huaweicloud.com@g” /etc/apt/sources.list
- sudo sed -i “s@http://.*security.ubuntu.com@http://repo.huaweicloud.com@g” /etc/apt/sources.list
- sudo apt-get update
- 在Ubuntu系统中解压上面已经下载的openHarmony源码
- 在Ubuntu系统中安装Docker
- 官方文档介绍-Docker编译环境
- sudo apt install docker.io
- sudo docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/docker_oh_mini:3.2 获取轻量系统镜像,获取小型和标准的则使用不同的参数
- 将你下载好的鸿蒙源码在Ubuntu下解压,进入已经解压的源码根目录
- 实行 sudo docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/docker_oh_mini:3.2 将源码路径导入到Docker中
- 编译
- 轻型系统
- python3 build.py -p qemu_mini_system_demo@ohemu
- 小型系统
- python3 build.py -p ipcamera_hispark_taurus@hisilicon
- python3 build.py -p qemu_small_system_demo@ohemu
- 编译工具和开发板都分为轻型、小型、标准,必须属于同一种范例,否则编译时各种报错
- 编译乐成后是这样的打印:
- [OHOS INFO] [1614/1615] STAMP obj/build/ohos/images/make_images.stamp
- [OHOS INFO] [1615/1615] STAMP obj/build/core/gn/images.stamp
- [OHOS INFO] ccache_dir = /root/.ccache, ccache_exec = /usr/bin/ccache
- [OHOS INFO] --------------------------------------------
- [OHOS INFO] ccache summary:
- [OHOS INFO] ccache version: 3.7.7
- [OHOS INFO] cache hit (direct): 0
- [OHOS INFO] cache hit (preprocessed): 0
- [OHOS INFO] cache miss: 0
- [OHOS INFO] hit rate: 0.00%
- [OHOS INFO] miss rate: 0.00%
- [OHOS INFO] Cache size (GB):
- [OHOS INFO] ---------------------------------------------
- [OHOS INFO] c targets overlap rate statistics
- [OHOS INFO] subsystem files NO. percentage builds NO. percentage overlap rate
- [OHOS INFO] hiviewdfx 12 0.8% 12 0.8% 1.00
- [OHOS INFO] kernel 902 63.5% 902 63.5% 1.00
- [OHOS INFO] security 61 4.3% 61 4.3% 1.00
- [OHOS INFO] startup 26 1.8% 26 1.8% 1.00
- [OHOS INFO] systemabilitymgr 15 1.1% 15 1.1% 1.00
- [OHOS INFO] thirdparty 393 27.7% 393 27.7% 1.00
- [OHOS INFO]
- [OHOS INFO] c overall build overlap rate: 1.00
- [OHOS INFO]
- [OHOS INFO]
- [OHOS INFO] qemu_mini_system_demo@ohemu build success
- [OHOS INFO] Cost time: 0:05:47
- root@ff38bf1e3e75:/home/openharmony#
- jim@ubuntu:~/openHarmony/out/arm_mps2_an386/qemu_mini_system_demo$ ls
- all_parts_host.json build_configs config.h kconfig_files.txt OHOS_Image.bin src_installed_parts.json
- all_parts_info.json build.log error.log libs OHOS_Image.map src_sa_infos_tmp.json
- args.gn build.ninja etc NOTICE_FILES OHOS_Image.sym.sorted startup
- binary_installed_parts.json build.ninja.d gen obj packages thirdparty
- build.1709259296.3884952.log build.trace.gz hiviewdfx OHOS_Image security toolchain.ninja
- build.1709259767.6772568.log config.gni kconfig_env.txt OHOS_Image.asm sorted_action_duration.txt
- jim@ubuntu:~/openHarmony/out/arm_mps2_an386/qemu_mini_system_demo$
复制代码
- 生成的系统镜像image是这里面的OHOS_Image文件
- 如需退出Docker,实行exit命令即可。这个命令会制止当前的Docker容器,并返回到您的操纵系统。
- 下一步就可以把编译好的操纵系统在QEMU模仿器中运行起来了。
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |