Android源码仓库地址:https://android.googlesource.com/platform/manifest/+refs
需科学上网,以下下载操作同样需要。
如何下载:
1、Git 下载manifest描述文件
git clone https://android.googlesource.com/platform/manifest
2、Git 查看分支
两种方式看到分支名:
- 通过网站看到tag:https://android.googlesource.com/platform/manifest/+refs
- 通过git命令查看: git tag
3、Git 切分支(例如切到 android-6.0.1_r9 分支)
git checkout android-6.0.1_r9
4、通过python脚本下载源码(文件名自己定,注意下面代码中相对于自己电脑的绝对路径)
import xml.dom.minidom
import os
from subprocess import call
#downloaded source path
rootdir = "D:/Android/source/android-6.0.1_r9"
#git program path
git = "C:/Program Files (x86)/Git/bin/git.exe"
dom = xml.dom.minidom.parse("D:/Android/source/manifest/default.xml")
root = dom.documentElement
prefix = git + " clone https://android.googlesource.com/"
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
call(cmd)
5、执行py文件(命令行或者双击打开都行)
python download-src.py
然后就是等待过程了
参考博文:https://www.cnblogs.com/zhangtingkuo/p/4703142.html
十分感谢分享!