Windows下载Android源代码
下載msysgit,安裝
官方下載:http://code.google.com/p/msysgit/downloads/list,
?
打開Git Bash,運(yùn)行命令
cd D:git clone https://android.googlesource.com/platform/manifest.git?
輸入命令,切換到manifest文件夾
cd manifestgit tag 列出android各個(gè)分支版本號
git tag下載android-2.2系統(tǒng)源代碼,輸入以下命令,假設(shè)要下載其它版本號源代碼,checkout git tag列出的版本號號就可以
git checkout android-2.2_r1checkout之后,manifest/default.xml文件里記錄的就是android2.2系統(tǒng)各個(gè)模塊的路徑
?
我們來分析一下default.xml文件,
以bionic為例,path屬性表示bionic源代碼的相對路徑,如果android源代碼在d:/android-source,下載bionic之后,應(yīng)該存放在d:/android-source/bionic文件夾
name屬性是bionic源代碼在庫上的路徑,完整的路徑就是:http://android.googlesource.com/platform/bionic.git,有了源代碼下載路徑,運(yùn)行g(shù)it clone就能夠?qū)ionic源代碼下載到本地
?
<project path="bionic" name="platform/bionic" />
?
Android源代碼中project非常多,一個(gè)一個(gè)下載比較麻煩,本人寫了一個(gè)python腳本,雙擊download-src.py運(yùn)行此腳本,就能夠?qū)ndroid完整源代碼下載到本地。
PS:運(yùn)行此腳本的前提是已經(jīng)運(yùn)行了git checkout,選擇好了要下載的Android源代碼版本號,假設(shè)你的manifest文件不是D:/manifest/default.xml,請自行改動腳本。
?
download-src.py源代碼:
import xml.dom.minidom import os from subprocess import call#downloaded source path rootdir = "D:/android-source"#git program path git = "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") + suffixcall(cmd)轉(zhuǎn)載于:https://www.cnblogs.com/mengfanrong/p/3884759.html
總結(jié)
以上是生活随笔為你收集整理的Windows下载Android源代码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: delphi 16 网页缩放
- 下一篇: Android实现点击事件的4种方式