如何获取鸿蒙系统的源码下载

源码地址

https://gitee.com/openharmony

仓库说明

该项目总共有119个仓库,他的鸿蒙系统,结构类似于安卓,并不是由一个仓库维护,也就是说,鸿蒙的源码得下一堆仓库然后按照一定的目录规则存放,从而组成鸿蒙的系统源码。

规则仓库

https://gitee.com/openharmony/manifest.git
这个仓库里面的内容,就是告诉人们鸿蒙源码的存放规则。
仓库名以及其在鸿蒙源码的目录路径,一般仓库名字能看出目录结构。
在这里插入图片描述

根据规则仓库下载源码

git clone https://gitee.com/openharmony/manifest.git
然后在根据网友提供的py脚本自动的下载,注意修改rootdir,
我用的是py3.8.8

import xml.dom.minidom
import os
from subprocess import call

rootdir = "E:/WorkSpace/other-pro/openharmony/harmonysource/"
dom = xml.dom.minidom.parse("./manifest/default.xml")
root = dom.documentElement

prefix = "git clone  https://gitee.com/openharmony/"
suffix = ".git"

if not os.path.exists(rootdir):
    os.mkdir(rootdir)

for node in root.getElementsByTagName("project"):
    os.chdir(rootdir)
    d = node.getAttribute("path")
    last = d.rfind("/")
    if last != -1:
        d = rootdir + "/" + d[:last]
        if not os.path.exists(d):
            os.makedirs(d)
        os.chdir(d)
    cmd = prefix + node.getAttribute("name") + suffix
    print(cmd)
    call(cmd)

说明

这样下下来的鸿蒙源码是全包,也可以去https://hpm.harmonyos.com/ 下载定制的包。
或者去站点下载特殊平台的镜像包。
这有说明
https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/%E6%BA%90%E7%A0%81%E8%8E%B7%E5%8F%96.md
可以下载下面的全量代码就是整合在一起的代码,
下面二进制的是镜像。
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_41884251/article/details/117263734