forked from firka/flutter
Update the script to download fuchsia sdk. (flutter/engine#31154)
This commit is contained in:
5
DEPS
5
DEPS
@@ -74,10 +74,11 @@ vars = {
|
||||
# Checkout Linux dependencies only when building on Linux.
|
||||
'download_linux_deps': 'host_os == "linux"',
|
||||
|
||||
# Downloads the fuchsia SDK as listed in .fuchsia_sdk_version. This variable
|
||||
# Downloads the fuchsia SDK as listed in fuchsia_sdk_path var. This variable
|
||||
# is currently only used for the Fuchsia LSC process and is not intended for
|
||||
# local development.
|
||||
'download_fuchsia_sdk': False,
|
||||
'fuchsia_sdk_path': '',
|
||||
|
||||
# An LLVM backend needs LLVM binaries and headers. To avoid build time
|
||||
# increases we can use prebuilts. We don't want to download this on every
|
||||
@@ -728,6 +729,8 @@ hooks = [
|
||||
'--verbose',
|
||||
'--host-os',
|
||||
Var('host_os'),
|
||||
'--fuchsia-sdk-path',
|
||||
Var('fuchsia_sdk_path'),
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -18,21 +18,19 @@ import sys
|
||||
SRC_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
FUCHSIA_SDK_DIR = os.path.join(SRC_ROOT, 'fuchsia', 'sdk')
|
||||
FLUTTER_DIR = os.path.join(SRC_ROOT, 'flutter')
|
||||
SDK_VERSION_INFO_FILE = os.path.join(FLUTTER_DIR, '.fuchsia_sdk_version')
|
||||
|
||||
|
||||
# Prints to stderr.
|
||||
def eprint(*args, **kwargs):
|
||||
print(*args, file=sys.stderr, **kwargs)
|
||||
|
||||
|
||||
def FileNameForBucket(bucket):
|
||||
return bucket.split('/')[-1]
|
||||
def FileNameForSdkPath(sdk_path):
|
||||
return sdk_path.split('/')[-1]
|
||||
|
||||
|
||||
def DownloadFuchsiaSDKFromGCS(bucket, verbose):
|
||||
file = FileNameForBucket(bucket)
|
||||
url = 'https://storage.googleapis.com/{}'.format(bucket)
|
||||
def DownloadFuchsiaSDKFromGCS(sdk_path, verbose):
|
||||
file = FileNameForSdkPath(sdk_path)
|
||||
url = 'https://storage.googleapis.com/fuchsia-artifacts/{}'.format(sdk_path)
|
||||
dest = os.path.join(FUCHSIA_SDK_DIR, file)
|
||||
|
||||
if verbose:
|
||||
@@ -42,6 +40,8 @@ def DownloadFuchsiaSDKFromGCS(bucket, verbose):
|
||||
if os.path.isfile(dest):
|
||||
os.unlink(dest)
|
||||
|
||||
# Ensure destination folder exists.
|
||||
os.makedirs(FUCHSIA_SDK_DIR, exist_ok=True)
|
||||
curl_command = [
|
||||
'curl',
|
||||
'--retry', '3',
|
||||
@@ -108,36 +108,6 @@ def ExtractGzipArchive(archive, host_os, verbose):
|
||||
shutil.move(extract_dest, sdk_dest)
|
||||
|
||||
|
||||
# Reads the version file and returns the bucket to download
|
||||
# The file is expected to live at the flutter directory and be named .fuchsia_sdk_version.
|
||||
#
|
||||
# The file is a JSON file which contains a single object with the following schema:
|
||||
# ```
|
||||
# {
|
||||
# "protocol": "gcs",
|
||||
# "identifiers": [
|
||||
# {
|
||||
# "host_os": "linux",
|
||||
# "bucket": "fuchsia-artifacts/development/8824687191341324145/sdk/linux-amd64/core.tar.gz"
|
||||
# }
|
||||
# ]
|
||||
# }
|
||||
# ```
|
||||
def ReadVersionFile(host_os):
|
||||
with open(SDK_VERSION_INFO_FILE) as f:
|
||||
try:
|
||||
version_obj = json.loads(f.read())
|
||||
if version_obj['protocol'] != 'gcs':
|
||||
eprint('The gcs protocol is the only suppoted protocl at this time')
|
||||
return None
|
||||
for id_obj in version_obj['identifiers']:
|
||||
if id_obj['host_os'] == host_os:
|
||||
return id_obj['bucket']
|
||||
except:
|
||||
eprint('Could not read JSON version file')
|
||||
return None
|
||||
|
||||
|
||||
def Main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
@@ -156,20 +126,23 @@ def Main():
|
||||
'--host-os',
|
||||
help='The host os')
|
||||
|
||||
parser.add_argument(
|
||||
'--fuchsia-sdk-path',
|
||||
help='The path in gcs to the fuchsia sdk to download')
|
||||
|
||||
args = parser.parse_args()
|
||||
fail_loudly = 1 if args.fail_loudly else 0
|
||||
verbose = args.verbose
|
||||
host_os = args.host_os
|
||||
fuchsia_sdk_path = args.fuchsia_sdk_path
|
||||
|
||||
bucket = ReadVersionFile(host_os)
|
||||
|
||||
if bucket is None:
|
||||
eprint('Unable to find bucket in version file')
|
||||
if fuchsia_sdk_path is None:
|
||||
eprint('sdk_path can not be empty')
|
||||
return fail_loudly
|
||||
|
||||
archive = DownloadFuchsiaSDKFromGCS(bucket, verbose)
|
||||
archive = DownloadFuchsiaSDKFromGCS(fuchsia_sdk_path, verbose)
|
||||
if archive is None:
|
||||
eprint('Failed to download SDK from %s' % bucket)
|
||||
eprint('Failed to download SDK from %s' % fuchsia_sdk_path)
|
||||
return fail_loudly
|
||||
|
||||
ExtractGzipArchive(archive, host_os, verbose)
|
||||
|
||||
Reference in New Issue
Block a user