[win-cross] Support using a zip file for the Windows SDK

Renames DEPOT_TOOLS_WIN_TOOLCHAIN_HTTP_BASE_URL to
DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_LOCATION. This environment variable can
now point to a local directory where the Windows SDK zip file is stored.
This allows non-Googlers to cross-compile Chromium for Windows.

Bug: 852347
Change-Id: I00650e84247f35b4b8cfba204e0f2afd0882b69b
Reviewed-on: https://chromium-review.googlesource.com/1098256
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
changes/56/1098256/15
Henrique Ferreiro 7 years ago committed by Commit Bot
parent 7999d92680
commit c5a26a769e

@ -238,8 +238,20 @@ def CanAccessToolchainBucket():
return code == 0 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(): 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(): def RequestGsAuthentication():
@ -282,17 +294,14 @@ def DelayBeforeRemoving(target_dir):
def DownloadUsingHttp(filename): def DownloadUsingHttp(filename):
"""Downloads the given file from a url defined in """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 urlparse
import urllib2 import urllib2
from contextlib import closing from contextlib import closing
temp_dir = tempfile.mkdtemp() temp_dir = tempfile.mkdtemp()
assert os.path.basename(filename) == filename assert os.path.basename(filename) == filename
target_path = os.path.join(temp_dir, filename) target_path = os.path.join(temp_dir, filename)
base_url = os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN_HTTP_BASE_URL') base_url = ToolchainBaseURL()
if base_url == None:
sys.exit('Missing DEPOT_TOOLS_WIN_TOOLCHAIN_HTTP_BASE_URL environment '
'variable')
src_url = urlparse.urljoin(base_url, filename) src_url = urlparse.urljoin(base_url, filename)
try: try:
with closing(urllib2.urlopen(src_url)) as fsrc, \ 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 """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 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.""" 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 UsesToolchainFromFile():
if use_local_zip:
temp_dir = None 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(): elif UsesToolchainFromHttp():
temp_dir, local_zip = DownloadUsingHttp(tree_sha1 + '.zip') temp_dir, local_zip = DownloadUsingHttp(tree_sha1 + '.zip')
else: else:
@ -482,9 +492,12 @@ def main():
# based on timestamps to make that case fast. # based on timestamps to make that case fast.
current_hashes = CalculateToolchainHashes(target_dir, True) current_hashes = CalculateToolchainHashes(target_dir, True)
if desired_hash not in current_hashes: if desired_hash not in current_hashes:
should_use_file = False
should_use_http = False should_use_http = False
should_use_gs = False should_use_gs = False
if UsesToolchainFromHttp(): if UsesToolchainFromFile():
should_use_file = True
elif UsesToolchainFromHttp():
should_use_http = True should_use_http = True
elif (HaveSrcInternalAccess() or elif (HaveSrcInternalAccess() or
LooksLikeGoogler() or LooksLikeGoogler() or
@ -492,10 +505,14 @@ def main():
should_use_gs = True should_use_gs = True
if not CanAccessToolchainBucket(): if not CanAccessToolchainBucket():
RequestGsAuthentication() RequestGsAuthentication()
if not should_use_gs and not should_use_http: if not should_use_file and not should_use_gs and not should_use_http:
print('\n\n\nPlease follow the instructions at ' if sys.platform not in ('win32', 'cygwin'):
'https://www.chromium.org/developers/how-tos/' doc = 'https://chromium.googlesource.com/chromium/src/+/master/docs/' \
'build-instructions-windows\n\n') 'win_cross.md'
else:
doc = 'https://chromium.googlesource.com/chromium/src/+/master/docs/' \
'windows_build_instructions.md'
print('\n\n\nPlease follow the instructions at %s\n\n' % doc)
return 1 return 1
print('Windows toolchain out of date or doesn\'t exist, updating (Pro)...') print('Windows toolchain out of date or doesn\'t exist, updating (Pro)...')
print(' current_hashes: %s' % ', '.join(current_hashes)) print(' current_hashes: %s' % ', '.join(current_hashes))

Loading…
Cancel
Save