開源鴻蒙OpenHarmony4.1源碼下載、編譯,生成OHOS_Image可執(zhí)行文件的最簡(jiǎn)易流程
作者 | 將狼才鯨 |
---|---|
日期 | 2024-03-01 |
-
準(zhǔn)備一臺(tái)Windows電腦
-
安裝VMware或者VMware Player虛擬機(jī)
-
從華為鏡像下載Ubuntu系統(tǒng),用國(guó)內(nèi)源下載速度更快
- Ubuntu 鏡像說(shuō)明
- https://repo.huaweicloud.com/ubuntu-releases/ 選擇要下載的系統(tǒng)版本
- https://repo.huaweicloud.com/ubuntu-releases/18.04.6/ubuntu-18.04.6-desktop-amd64.iso 我使用此鏈接下載
-
下載開源鴻蒙系統(tǒng)源碼
- https://repo.huaweicloud.com/harmonyos/os/ 選擇要下載的系統(tǒng)版本
- https://repo.huaweicloud.com/harmonyos/os/4.0-Release/code-v4.0-Release.tar.gz 我下載這個(gè),28G
-
在VMware虛擬機(jī)中安裝Ubuntu系統(tǒng)
-
安裝完之后進(jìn)入系統(tǒng),使用命令行將官方源換成華為源,這樣下載軟件時(shí)更快
- 參考自: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系統(tǒng)中解壓上面已經(jīng)下載的openHarmony源碼
-
在Ubuntu系統(tǒng)中安裝Docker
- 官方文檔介紹-Docker編譯環(huán)境
- sudo apt install docker.io
- sudo docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/docker_oh_mini:3.2 獲取輕量系統(tǒng)鏡像,獲取小型和標(biāo)準(zhǔn)的則使用不同的參數(shù)
-
將你下載好的鴻蒙源碼在Ubuntu下解壓,進(jìn)入已經(jīng)解壓的源碼根目錄
-
執(zhí)行 sudo docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/docker_oh_mini:3.2 將源碼路徑導(dǎo)入到Docker中
-
編譯
- 輕型系統(tǒng)
- python3 build.py -p qemu_mini_system_demo@ohemu
- 小型系統(tǒng)
- python3 build.py -p ipcamera_hispark_taurus@hisilicon
- python3 build.py -p qemu_small_system_demo@ohemu
- 編譯工具和開發(fā)板都分為輕型、小型、標(biāo)準(zhǔn),必須屬于同一種類型,否則編譯時(shí)各種報(bào)錯(cuò)
- 輕型系統(tǒng)
-
編譯成功后是這樣的打?。?/p>
[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$
-
生成的系統(tǒng)鏡像image是這里面的OHOS_Image文件
-
如需退出Docker,執(zhí)行exit命令即可。這個(gè)命令會(huì)停止當(dāng)前的Docker容器,并返回到您的操作系統(tǒng)。文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-847378.html
-
下一步就可以把編譯好的操作系統(tǒng)在QEMU模擬器中運(yùn)行起來(lái)了。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-847378.html
到了這里,關(guān)于3 開源鴻蒙OpenHarmony4.1源碼下載、編譯,生成OHOS_Image可執(zhí)行文件的最簡(jiǎn)易流程的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!