Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4879)

Unified Diff: build/fuchsia/update_sdk.py

Issue 2875173002: Add hook to download Fuchsia SDK (Closed)
Patch Set: . Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « DEPS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/fuchsia/update_sdk.py
diff --git a/build/fuchsia/update_sdk.py b/build/fuchsia/update_sdk.py
new file mode 100755
index 0000000000000000000000000000000000000000..2cc321604c58bee1f95554e10f3a0ec94fd5dbd6
--- /dev/null
+++ b/build/fuchsia/update_sdk.py
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Updates the Fuchsia SDK to the given revision. Checks .gclient target_os
+so that it doesn't download unnecessarily."""
+
+import os
+import subprocess
+import sys
+import tarfile
+import tempfile
+
+REPOSITORY_ROOT = os.path.abspath(os.path.join(
+ os.path.dirname(__file__), '..', '..'))
+sys.path.append(os.path.join(REPOSITORY_ROOT, 'build'))
+sys.path.append(os.path.join(REPOSITORY_ROOT, 'tools', 'cr'))
+
+import cr.base
+import find_depot_tools
+
+
+def EnsureDirExists(path):
+ if not os.path.exists(path):
+ print 'Creating directory %s' % path
+ os.makedirs(path)
+
+
+def main():
+ if len(sys.argv) != 2:
+ print >>sys.stderr, 'usage: %s <sdk_hash>' % sys.argv[0]
+ return 1
+
+ # Check whether we're targeting Fuchsia.
+ user_path = os.path.expanduser(os.path.join('~', '.config', 'cr'))
+ cr.auto.user.__path__.append(user_path)
+ cr.loader.Scan()
+ with cr.base.context.Create(
+ description='Fuchsia SDK update tool',
+ epilog='') as context:
+
+ cr.base.client.DetectClient()
+ target_os = cr.context.gclient.get('target_os', [])
+ if 'fuchsia' not in target_os:
+ # Nothing to do.
+ return 0
Dirk Pranke 2017/05/11 22:31:30 Why use CR for this, rather than just loading .gcl
scottmg 2017/05/11 22:38:17 No good reason. I'll do that if the hooks_os thing
+
+ sdk_hash = sys.argv[1]
+ output_dir = os.path.join(REPOSITORY_ROOT, 'third_party', 'fuchsia-sdk')
+ bucket = 'gs://fuchsia-build/fuchsia/sdk/linux64/'
+ print 'Downloading SDK %s...' % sdk_hash
+
+ if os.path.isdir(output_dir):
+ os.removedirs(output_dir)
+
+ with tempfile.NamedTemporaryFile() as f:
+ cmd = [os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, 'gsutil.py'),
+ 'cp', bucket + sdk_hash, f.name]
+ print cmd
+ subprocess.check_call(cmd)
+ f.seek(0)
+ EnsureDirExists(output_dir)
+ tarfile.open(mode='r:gz', fileobj=f).extractall(path=output_dir)
+
+
+if __name__ == '__main__':
+ sys.exit(main())
« no previous file with comments | « DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698