使用代理当在gclient runhooks //这条命令将下载依赖的二进制包,产生ninja和v
使用代理下载源码,在gclient runhooks //这条命令将下载依赖的二进制包,产生ninja和vc工程 遇到如下错误:
Command 'vpython.bat src/testing/generate_location_tags.py --out src/testing/location_tags.json' returned non-zero exit status 1 in *******
1)通过查看generate_localtion_tags.py打印出该python要执行的命令如下:
['***\\src\\third_party\\depot_tools\\dirmd.bat', 'location-tags', '-out', 'src/testing/location_tags.json', '-root', 'src', '-repo', 'https://chromium.googlesource.com/chromium/src']
2)再查看dirmd.bat运行了如下脚本 :
call "%~dp0\cipd_bin_setup.bat" > nul 2>&1
"%~dp0\.cipd_bin\dirmd.exe" %* //在上一步运行成功会出现
3)cipd_bin_setup.bat再调用了如下:
"%~dp0\cipd.bat" ensure -log-level warning -ensure-file "%~dp0\cipd_manifest.txt" -root "%~dp0\.cipd_bin"
cipd_manifest.txt是要下载的工具列表,然后将工具保存到.cipd_bin
4)再看下cipd.bat,发现使用powershell执行.cipd_impl.ps1 (100多行代理而已)进行工具下载。耐着性子再完了.cipd_impl.ps1,发现有一处$wc.DownloadFile($URL, $TmpPath),显然是在这地方调用下载,于是添加了代理,果然成功了。代理设置参数如下:
$explicitProxy = "http://127.0.0.1:8111"
$explicitProxyUser = "user"
$explicitProxyPassword = "passwd"
$proxy = New-Object System.Net.WebProxy($explicitProxy, $true)
$proxy.Credentials=New-Object System.Net.NetworkCredential($explicitProxyUser,$explicitProxyPassword)
$wc.Proxy = $proxy
$wc.DownloadFile($Url, $Path)