git clone https://android.googlesource.com/platform/manifest.git
//没有梯子使用清华源
git clone https://aosp.tuna.tsinghua.edu.cn/platform/manifest.git
cd manifest
//没有梯子,使用 git branch -a 查看所有分支,找到想要的分支
git branch -a
git checkout android-6.0.1_r79 //这里以 6.0 最后一个版本下载
// git checkout studio-master-dev // 这里检出 Android Studio源码
创建 download.py 并执行, 这里进行了优化, 只检出最近一次的git历史代码, 耐心等待即可
import xml.dom.minidom
import os
from subprocess import call
# 1. 修改为源码要保存的路径
rootdir = "D:/AOSP/studio"
# 2. 设置 git 安装的路径
git = "C:/Program Files/Git/bin/git.exe"
# 3. 修改为第一步中 manifest 中 default.xml 保存的路径
dom = xml.dom.minidom.parse("D:/AOSP/manifest/default.xml")
root = dom.documentElement
#prefix = git + " clone https://android.googlesource.com/"
# 4. 没有梯子使用清华源下载
prefix = git + " clone --depth 1 https://aosp.tuna.tsinghua.edu.cn/"
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)