1.安装git
2.仓库目录下载
git clone https://aosp.tuna.tsinghua.edu.cn/platform/manifest.git
此仓库仅用于获取源码仓库目录,default.xml文件project标签列出来源码模块与属性
cd manifest
git branch -a
git checkout android-16.0.0_r2
查看并切换分支,确认default.xml内容切换到需要的版本
3.单模块下载
查看default.xml,查找需要下载的模块,根据project标签的path手动创建目录
根据project标签的name属性值下载具体模块(比如name="platform/build")
git clone https://aosp.tuna.tsinghua.edu.cn/platform/build.git
每一个仓库都是独立的,可以checkout不同的版本
4.批量下载
全量源代码大几百g,慎重!!!
创建download.bat文件,自动解析default.xml内容进行目录创建与下载
@echo off
setlocal enabledelayedexpansion
set rootdir=D:\sourcecode\android_source_16
set git="D:\Program Files\Git\bin\git.exe"
set xmlfile=D:\sourcecode\manifest\default.xml
if not exist "%rootdir%" (
mkdir "%rootdir%"
)
for /f "tokens=*" %%a in ('powershell -command "[xml]$xml=Get-Content '%xmlfile%'; $xml.manifest.project | %%{$_.path + '|' + $_.name}"') do (
for /f "tokens=1,2 delims=|" %%b in ("%%a") do (
set path=%%b
set name=%%c
set "dirPath=!path:/=\!"
set "fullpath=%rootdir%\!dirPath!\"
if not exist "!fullpath!" (
mkdir "!fullpath!"
)
cd /d "!fullpath!"
set "cmd=%git% clone https://aosp.tuna.tsinghua.edu.cn/!name!.git"
echo !cmd!
!cmd!
)
)
1861

被折叠的 条评论
为什么被折叠?



