Windows下載Android源碼

來源:互聯網
上載者:User

下載msysgit,安裝

官方下載:http://code.google.com/p/msysgit/downloads/list,

 

開啟Git Bash,執行命令

cd D:git clone https://android.googlesource.com/platform/manifest.git

 

輸入命令,切換到manifest目錄

cd manifest

git tag 列出android各個分支版本

git tag

下載android-2.2系統源碼,輸入下面命令,如果要下載其他版本源碼,checkout git tag列出的版本號碼即可

git checkout android-2.2_r1

checkout之後,manifest/default.xml檔案中記錄的就是android2.2系統各個模組的路徑

 

我們來分析一下default.xml檔案,

以bionic為例,path屬性工作表示bionic源碼的相對路徑,假設android源碼在d:/android-source,下載bionic之後,應該存放在d:/android-source/bionic目錄

name屬性是bionic原始碼在庫上的路徑,完整的路徑就是:http://android.googlesource.com/platform/bionic.git,有了源碼下載路徑,執行git clone就可以將bionic源碼下載到本地

 

<project path="bionic" name="platform/bionic" />

 

Android源碼中project很多,一個一個下載比較麻煩,本人寫了一個python指令碼,雙擊download-src.py執行此指令碼,就可以將android完整源碼下載到本地。

PS:執行此指令碼的前提是已經執行了git checkout,選擇好了要下載的Android源碼版本,如果你的manifest檔案不是D:/manifest/default.xml,請自行修改指令碼。

 

download-src.py源碼:

import xml.dom.minidomimport osfrom subprocess import call#downloaded source pathrootdir = "D:/android-source"#git program pathgit = "D:/Program Files/Git/bin/git.exe"dom = xml.dom.minidom.parse("D:/manifest/default.xml")root = dom.documentElementprefix = 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個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.