1 #!/usr/bin/env python 2 # 3 # Copyright 2016 Google Inc. 4 # 5 # Use of this source code is governed by a BSD-style license that can be 6 # found in the LICENSE file. 7 8 9 import default_flavor 10 import os 11 import ssh_flavor 12 13 14 """Utils for building for and running tests on ChromeOS.""" 15 16 17 class ChromeOSFlavorUtils(ssh_flavor.SSHFlavorUtils): 18 def __init__(self, bot_info): 19 super(ChromeOSFlavorUtils, self).__init__(bot_info) 20 self.board = self._bot_info.spec['device_cfg'] 21 self.device_root_dir = '/usr/local/skiabot' 22 self.device_bin_dir = self.device_path_join(self.device_root_dir, 'bin') 23 24 def step(self, name, cmd, **kwargs): 25 """Wrapper for the Step API; runs a step as appropriate for this flavor.""" 26 local_path = self._bot_info.out_dir.join( 27 'config', 'chromeos-%s' % self.board, 28 self._bot_info.configuration, cmd[0]) 29 remote_path = self.device_path_join(self.device_bin_dir, cmd[0]) 30 self.copy_file_to_device(local_path, remote_path) 31 super(ChromeOSFlavorUtils, self).step(name=name, 32 cmd=[remote_path]+cmd[1:], 33 **kwargs) 34 35 def compile(self, target): 36 """Build the given target.""" 37 cmd = [os.path.join(self._bot_info.skia_dir, 'platform_tools', 'chromeos', 38 'bin', 'chromeos_make'), 39 '-d', self.board, 40 target] 41 self._bot_info.run(cmd) 42 43 def install(self): 44 """Run any device-specific installation steps.""" 45 self.create_clean_device_dir(self.device_bin_dir) 46 47 def get_device_dirs(self): 48 """ Set the directories which will be used by the build steps.""" 49 prefix = self.device_path_join(self.device_root_dir, 'skia_') 50 def join(suffix): 51 return ''.join((prefix, suffix)) 52 return default_flavor.DeviceDirs( 53 dm_dir=join('dm_out'), # 'dm' conflicts with the binary 54 perf_data_dir=join('perf'), 55 resource_dir=join('resources'), 56 images_dir=join('images'), 57 skp_dir=self.device_path_join(join('skp'), 'skps'), 58 tmp_dir=join('tmp_dir')) 59 60