windows下载Android最新源码

这篇博客介绍了如何通过Python脚本来批量克隆Android开放源代码项目(AOSP)的仓库。首先,从Tsinghua University的AOSP镜像仓库克隆manifest文件,然后运行Python脚本`sync.py`,利用`git`命令获取所有仓库的最新代码。如果需要,也可以单独克隆特定仓库,如`platform/packages/apps/Launcher3`。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.查看最新源码repo仓库

git clone https://aosp.tuna.tsinghua.edu.cn/platform/manifest
cd .\manifest\

2.克隆所有仓库

python sync.py

import xml.dom.minidom
import os
from subprocess import call
 
# 保存源码路径
rootdir = "C:/Users/wdp/Desktop/source/android-12.0.0_r2"
 
# git路径
git = "C:/Program Files/Git/bin/git.exe"
 
dom = xml.dom.minidom.parse("C:/Users/wdp/Desktop/source/manifest/default.xml")
root = dom.documentElement
# 默认下载master分支最新代码
prefix = git + " clone https://aosp.tuna.tsinghua.edu.cn/"
# 只拉去最新一次commit,减小源码体积
# 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
    call(cmd)

3.单独克隆某个仓库

git clone https://aosp.tuna.tsinghua.edu.cn/platform/packages/apps/Launcher3.git
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值