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

Side by Side Diff: build/android/pylib/device/commands/install_commands.py

Issue 1325893002: Defer running of install_commands.Installed() until necessary (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@device2
Patch Set: single check Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | build/android/pylib/device/device_utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import os 5 import os
6 import posixpath
6 7
7 from pylib import constants 8 from pylib import constants
8 9
9 BIN_DIR = '%s/bin' % constants.TEST_EXECUTABLE_DIR 10 BIN_DIR = '%s/bin' % constants.TEST_EXECUTABLE_DIR
10 _FRAMEWORK_DIR = '%s/framework' % constants.TEST_EXECUTABLE_DIR 11 _FRAMEWORK_DIR = '%s/framework' % constants.TEST_EXECUTABLE_DIR
11 12
12 _COMMANDS = { 13 _COMMANDS = {
13 'unzip': 'org.chromium.android.commands.unzip.Unzip', 14 'unzip': 'org.chromium.android.commands.unzip.Unzip',
14 } 15 }
15 16
16 _SHELL_COMMAND_FORMAT = ( 17 _SHELL_COMMAND_FORMAT = (
17 """#!/system/bin/sh 18 """#!/system/bin/sh
18 base=%s 19 base=%s
19 export CLASSPATH=$base/framework/chromium_commands.jar 20 export CLASSPATH=$base/framework/chromium_commands.jar
20 exec app_process $base/bin %s $@ 21 exec app_process $base/bin %s $@
21 """) 22 """)
22 23
23 24
24 def Installed(device): 25 def Installed(device):
25 return (all(device.FileExists('%s/%s' % (BIN_DIR, c)) for c in _COMMANDS) 26 cmd = 'test'
jbudorick 2015/09/01 20:33:20 If we think that FileExists doesn't handle the mul
agrieve 2015/09/02 15:34:49 Done.
26 and device.FileExists('%s/chromium_commands.jar' % _FRAMEWORK_DIR)) 27 for c in _COMMANDS:
28 cmd += '-e %s -a' % posixpath.join(BIN_DIR, c)
29 cmd += '-e %s' % posixpath.join(_FRAMEWORK_DIR, 'chromium_commands.jar')
30 cmd += ' || echo 1'
31 return not device.RunShellCommand(cmd, check_return=True)
32
27 33
28 def InstallCommands(device): 34 def InstallCommands(device):
29 if device.IsUserBuild(): 35 if device.IsUserBuild():
30 raise Exception('chromium_commands currently requires a userdebug build.') 36 raise Exception('chromium_commands currently requires a userdebug build.')
31 37
32 chromium_commands_jar_path = os.path.join( 38 chromium_commands_jar_path = os.path.join(
33 constants.GetOutDirectory(), constants.SDK_BUILD_JAVALIB_DIR, 39 constants.GetOutDirectory(), constants.SDK_BUILD_JAVALIB_DIR,
34 'chromium_commands.dex.jar') 40 'chromium_commands.dex.jar')
35 if not os.path.exists(chromium_commands_jar_path): 41 if not os.path.exists(chromium_commands_jar_path):
36 raise Exception('%s not found. Please build chromium_commands.' 42 raise Exception('%s not found. Please build chromium_commands.'
37 % chromium_commands_jar_path) 43 % chromium_commands_jar_path)
38 44
39 device.RunShellCommand(['mkdir', BIN_DIR, _FRAMEWORK_DIR]) 45 device.RunShellCommand(['mkdir', BIN_DIR, _FRAMEWORK_DIR])
40 for command, main_class in _COMMANDS.iteritems(): 46 for command, main_class in _COMMANDS.iteritems():
41 shell_command = _SHELL_COMMAND_FORMAT % ( 47 shell_command = _SHELL_COMMAND_FORMAT % (
42 constants.TEST_EXECUTABLE_DIR, main_class) 48 constants.TEST_EXECUTABLE_DIR, main_class)
43 shell_file = '%s/%s' % (BIN_DIR, command) 49 shell_file = '%s/%s' % (BIN_DIR, command)
44 device.WriteFile(shell_file, shell_command) 50 device.WriteFile(shell_file, shell_command)
45 device.RunShellCommand( 51 device.RunShellCommand(
46 ['chmod', '755', shell_file], check_return=True) 52 ['chmod', '755', shell_file], check_return=True)
47 53
48 device.adb.Push( 54 device.adb.Push(
49 chromium_commands_jar_path, 55 chromium_commands_jar_path,
50 '%s/chromium_commands.jar' % _FRAMEWORK_DIR) 56 '%s/chromium_commands.jar' % _FRAMEWORK_DIR)
51 57
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/device/device_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698