windows平臺下載android源碼

須要工具以下:node

下載msysgit,安裝     官方下載: http://download.csdn.net/detail/jason0539/7212993
 下載python,安裝      官方網址: http://www.python.org
 
打開Git Bash,執行命令,我是放在d盤的,路徑可自定義
 
cd D:
 
 
這裏會遇到問題,說你鏈接不上站點,錯誤代碼443
解決方案,在電腦的hosts文件中添加以下幾行,不知道hosts在哪的自行百度
 

輸入命令,切換到manifest目錄python

cd manifest

git tag 列出android各個分支版本android

下載android-4.4系統源碼,輸入下面命令,若是要下載其餘版本源碼,checkout git tag列出的版本號便可git

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)  

  


執行這個腳本以後,就開始自動下載了,
 
截張圖:
 
估計須要一段時間,耐心等待。
相關文章
相關標籤/搜索