码迷,mamicode.com
首页 > 移动开发 > 详细

windows平台下载android源码

时间:2015-06-04 20:44:28      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:

需要工具如下:

下载msysgit,安装     官方下载:http://download.csdn.net/detail/jason0539/7212993
 下载python,安装      官方网址:http://www.python.org
 
打开Git Bash,执行命令,我是放在d盘的,路径可自定义
 
cd D:
 
技术分享
 
这里会遇到问题,说你连接不上站点,错误代码443
解决方案,在电脑的hosts文件中添加如下几行,不知道hosts在哪的自行百度
 

输入命令,切换到manifest目录

cd manifest

git tag 列出android各个分支版本

下载android-4.4系统源码,输入下面命令,如果要下载其他版本源码,checkout git tag列出的版本号即可

git checkout android-4.4.2_r1
checkout之后,manifest/default.xml文件中记录的就是android4.4系统各个模块的路径,
 
下面就轮到python出场了,这里用的是网上的一段python代码,实现源码的批量下载
执行此脚本的前提是已经执行了git checkout,选择好了要下载的Android源码版本,如果你的manifest文件不是D:/manifest/default.xml,还要把里面的git.exe的路经修改成你的安装路径,请自行修改脚本。

 
import xml.dom.minidom  
import os  
from subprocess import call  
  
#downloaded source path  
rootdir = "F:/anroid4.4"  
  
#git program path  
git = "C:/Program Files/Git/bin/git.exe"  
  
dom = xml.dom.minidom.parse("F:/anroid4.4/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)  

  


执行这个脚本之后,就开始自动下载了,
 
截张图:
技术分享
 
估计需要一段时间,耐心等待。

windows平台下载android源码

标签:

原文地址:http://www.cnblogs.com/try-catch/p/4552797.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!