mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Add support for downloading Windows VS toolchain from a HTTP URL
Add support for downloading Windows VS toolchain from a HTTP URL. This is useful for developers that do not have access to the Chrome toolchain. If the developer specifies DEPOT_TOOLS_WIN_TOOLCHAIN_HTTP_BASE_URL environment variable, the toolchain will be downloaded from that url. Bug: 830569 Change-Id: I41d815a4460085c3b028f56f2e01adc68d8410fe Reviewed-on: https://chromium-review.googlesource.com/1002892 Commit-Queue: Kimmo Kinnunen FI <kkinnunen@nvidia.com> Reviewed-by: Scott Graham <scottmg@chromium.org>
This commit is contained in:
committed by
Commit Bot
parent
53a115e67e
commit
54a81e45dd
@@ -238,6 +238,10 @@ def CanAccessToolchainBucket():
|
||||
return code == 0
|
||||
|
||||
|
||||
def UsesToolchainFromHttp():
|
||||
return os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN_HTTP_BASE_URL') != None
|
||||
|
||||
|
||||
def RequestGsAuthentication():
|
||||
"""Requests that the user authenticate to be able to access gs:// as a
|
||||
Googler. This allows much faster downloads, and pulling (old) toolchains
|
||||
@@ -276,6 +280,30 @@ def DelayBeforeRemoving(target_dir):
|
||||
print
|
||||
|
||||
|
||||
def DownloadUsingHttp(filename):
|
||||
"""Downloads the given file from a url defined in
|
||||
DEPOT_TOOLS_WIN_TOOLCHAIN_HTTP_BASE_URL environment variable."""
|
||||
import urlparse
|
||||
import urllib2
|
||||
from contextlib import closing
|
||||
temp_dir = tempfile.mkdtemp()
|
||||
assert os.path.basename(filename) == filename
|
||||
target_path = os.path.join(temp_dir, filename)
|
||||
base_url = os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN_HTTP_BASE_URL')
|
||||
if base_url == None:
|
||||
sys.exit('Missing DEPOT_TOOLS_WIN_TOOLCHAIN_HTTP_BASE_URL environment '
|
||||
'variable')
|
||||
src_url = urlparse.urljoin(base_url, filename)
|
||||
try:
|
||||
with closing(urllib2.urlopen(src_url)) as fsrc, \
|
||||
open(target_path, 'wb') as fdst:
|
||||
shutil.copyfileobj(fsrc, fdst)
|
||||
except urllib2.URLError as e:
|
||||
RmDir(temp_dir)
|
||||
sys.exit('Failed to retrieve file: %s' % e)
|
||||
return temp_dir, target_path
|
||||
|
||||
|
||||
def DownloadUsingGsutil(filename):
|
||||
"""Downloads the given file from Google Storage chrome-wintoolchain bucket."""
|
||||
temp_dir = tempfile.mkdtemp()
|
||||
@@ -306,6 +334,8 @@ def DoTreeMirror(target_dir, tree_sha1):
|
||||
if use_local_zip:
|
||||
temp_dir = None
|
||||
local_zip = tree_sha1 + '.zip'
|
||||
elif UsesToolchainFromHttp():
|
||||
temp_dir, local_zip = DownloadUsingHttp(tree_sha1 + '.zip')
|
||||
else:
|
||||
temp_dir, local_zip = DownloadUsingGsutil(tree_sha1 + '.zip')
|
||||
sys.stdout.write('Extracting %s...\n' % local_zip)
|
||||
@@ -452,14 +482,17 @@ def main():
|
||||
# based on timestamps to make that case fast.
|
||||
current_hashes = CalculateToolchainHashes(target_dir, True)
|
||||
if desired_hash not in current_hashes:
|
||||
should_use_http = False
|
||||
should_use_gs = False
|
||||
if (HaveSrcInternalAccess() or
|
||||
if UsesToolchainFromHttp():
|
||||
should_use_http = True
|
||||
elif (HaveSrcInternalAccess() or
|
||||
LooksLikeGoogler() or
|
||||
CanAccessToolchainBucket()):
|
||||
should_use_gs = True
|
||||
if not CanAccessToolchainBucket():
|
||||
RequestGsAuthentication()
|
||||
if not should_use_gs:
|
||||
if not should_use_gs and not should_use_http:
|
||||
print('\n\n\nPlease follow the instructions at '
|
||||
'https://www.chromium.org/developers/how-tos/'
|
||||
'build-instructions-windows\n\n')
|
||||
|
||||
Reference in New Issue
Block a user