1.下载android代码:
import xml.dom.minidom
import os
from subprocess import call
rootdir = "Z:/files/android9"
git = "C:/Program Files/Git/git-bash.exe"
dom = xml.dom.minidom.parse("Z:/files/android9/manifest/default.xml")
root = dom.documentElement
prefix = "git clone --single-branch -b android-9.0.0_r6 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)
2.编译环境