@ -238,8 +238,20 @@ def CanAccessToolchainBucket():
return code == 0
def ToolchainBaseURL ( ) :
base_url = os . environ . get ( ' DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL ' , ' ' )
if base_url . startswith ( ' file:// ' ) :
base_url = base_url [ len ( ' file:// ' ) : ]
return base_url
def UsesToolchainFromFile ( ) :
return os . path . isdir ( ToolchainBaseURL ( ) )
def UsesToolchainFromHttp ( ) :
return os . environ . get ( ' DEPOT_TOOLS_WIN_TOOLCHAIN_HTTP_BASE_URL ' ) != None
url = ToolchainBaseURL ( )
return url . startswith ( ' http:// ' ) or url . startswith ( ' https:// ' )
def RequestGsAuthentication ( ) :
@ -282,17 +294,14 @@ def DelayBeforeRemoving(target_dir):
def DownloadUsingHttp ( filename ) :
""" Downloads the given file from a url defined in
DEPOT_TOOLS_WIN_TOOLCHAIN_ HTTP_ BASE_URL environment variable . """
DEPOT_TOOLS_WIN_TOOLCHAIN_ 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 ' )
base_url = ToolchainBaseURL ( )
src_url = urlparse . urljoin ( base_url , filename )
try :
with closing ( urllib2 . urlopen ( src_url ) ) as fsrc , \
@ -330,10 +339,11 @@ def DoTreeMirror(target_dir, tree_sha1):
""" In order to save temporary space on bots that do not have enough space to
download ISOs , unpack them , and copy to the target location , the whole tree
is uploaded as a zip to internal storage , and then mirrored here . """
use_local_zip = bool ( int ( os . environ . get ( ' USE_LOCAL_ZIP ' , 0 ) ) )
if use_local_zip :
if UsesToolchainFromFile ( ) :
temp_dir = None
local_zip = tree_sha1 + ' .zip '
local_zip = os . path . join ( ToolchainBaseURL ( ) , tree_sha1 + ' .zip ' )
if not os . path . isfile ( local_zip ) :
sys . exit ( ' %s is not a valid file. ' % local_zip )
elif UsesToolchainFromHttp ( ) :
temp_dir , local_zip = DownloadUsingHttp ( tree_sha1 + ' .zip ' )
else :
@ -482,9 +492,12 @@ 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_file = False
should_use_http = False
should_use_gs = False
if UsesToolchainFromHttp ( ) :
if UsesToolchainFromFile ( ) :
should_use_file = True
elif UsesToolchainFromHttp ( ) :
should_use_http = True
elif ( HaveSrcInternalAccess ( ) or
LooksLikeGoogler ( ) or
@ -492,10 +505,14 @@ def main():
should_use_gs = True
if not CanAccessToolchainBucket ( ) :
RequestGsAuthentication ( )
if not should_use_gs and not should_use_http :
print ( ' \n \n \n Please follow the instructions at '
' https://www.chromium.org/developers/how-tos/ '
' build-instructions-windows \n \n ' )
if not should_use_file and not should_use_gs and not should_use_http :
if sys . platform not in ( ' win32 ' , ' cygwin ' ) :
doc = ' https://chromium.googlesource.com/chromium/src/+/master/docs/ ' \
' win_cross.md '
else :
doc = ' https://chromium.googlesource.com/chromium/src/+/master/docs/ ' \
' windows_build_instructions.md '
print ( ' \n \n \n Please follow the instructions at %s \n \n ' % doc )
return 1
print ( ' Windows toolchain out of date or doesn \' t exist, updating (Pro)... ' )
print ( ' current_hashes: %s ' % ' , ' . join ( current_hashes ) )