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

Unified Diff: mojo/public/tools/download_shell_binary.py

Issue 892903003: Download and copy shell binary on Android as well as Linux. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Response to review Created 5 years, 10 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 | « mojo/public/tools/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/download_shell_binary.py
diff --git a/mojo/public/tools/download_shell_binary.py b/mojo/public/tools/download_shell_binary.py
index b46139e7ae1c7107fc4966bd2c290ee048bff719..f2d98c47c0b1c62e46d26c99cea1bb4383191c5c 100755
--- a/mojo/public/tools/download_shell_binary.py
+++ b/mojo/public/tools/download_shell_binary.py
@@ -10,6 +10,11 @@ import sys
import tempfile
import zipfile
+BINARY_FOR_PLATFORM = {
+ "linux-x64" : "mojo_shell",
+ "android-arm" : "MojoShell.apk"
+}
+
if not sys.platform.startswith("linux"):
print "Not supported for your platform"
sys.exit(0)
@@ -17,17 +22,9 @@ if not sys.platform.startswith("linux"):
def download(tools_directory):
current_path = os.path.dirname(os.path.realpath(__file__))
- find_depot_tools_path = os.path.join(current_path, tools_directory)
- sys.path.insert(0, find_depot_tools_path)
- # pylint: disable=F0401
- import find_depot_tools
-
prebuilt_file_path = os.path.join(current_path, "prebuilt")
qsr 2015/02/06 14:48:12 Maybe create a method for this, as you use it in m
blundell 2015/02/06 15:01:04 Made global vars, as both current_path and prebuil
stamp_path = os.path.join(prebuilt_file_path, "VERSION")
- depot_tools_path = find_depot_tools.add_depot_tools_to_path()
- gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil")
-
version_path = os.path.join(current_path, "../VERSION")
with open(version_path) as version_file:
version = version_file.read().strip()
@@ -38,13 +35,29 @@ def download(tools_directory):
if current_version == version:
return 0 # Already have the right version.
except IOError:
- pass # If the stamp file does not exist we need to download a new binary.
+ pass # If the stamp file does not exist we need to download new binaries.
- platform = "linux-x64" # TODO: configurate
- basename = platform + ".zip"
+ for platform in ["linux-x64", "android-arm"]:
+ download_version_for_platform(version, platform, tools_directory)
+ with open(stamp_path, 'w') as stamp_file:
+ stamp_file.write(version)
+ return 0
+
+def download_version_for_platform(version, platform, tools_directory):
+ current_path = os.path.dirname(os.path.realpath(__file__))
+ prebuilt_file_path = os.path.join(current_path, "prebuilt")
+ find_depot_tools_path = os.path.join(current_path, tools_directory)
+ sys.path.insert(0, find_depot_tools_path)
+ # pylint: disable=F0401
+ import find_depot_tools
+
+ basename = platform + ".zip"
gs_path = "gs://mojo/shell/" + version + "/" + basename
+ depot_tools_path = find_depot_tools.add_depot_tools_to_path()
+ gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil")
+
with tempfile.NamedTemporaryFile() as temp_zip_file:
# We're downloading from a public bucket which does not need authentication,
# but the user might have busted credential files somewhere such as ~/.boto
@@ -70,19 +83,16 @@ def download(tools_directory):
print e.output
sys.exit(1)
+ binary_name = BINARY_FOR_PLATFORM[platform]
with zipfile.ZipFile(temp_zip_file.name) as z:
- zi = z.getinfo("mojo_shell")
+ zi = z.getinfo(binary_name)
mode = zi.external_attr >> 16
z.extract(zi, prebuilt_file_path)
- os.chmod(os.path.join(prebuilt_file_path, "mojo_shell"), mode)
-
- with open(stamp_path, 'w') as stamp_file:
- stamp_file.write(version)
- return 0
+ os.chmod(os.path.join(prebuilt_file_path, binary_name), mode)
def main():
- parser = argparse.ArgumentParser(description="Download mojo_shell binary "
+ parser = argparse.ArgumentParser(description="Download mojo_shell binaries "
"from google storage")
parser.add_argument("--tools-directory",
dest="tools_directory",
« no previous file with comments | « mojo/public/tools/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698