def _RunCommandInDirectory(directory, command): """Changes to a directory, runs a command, then changes back.""" saved_dir = os.getcwd() os.chdir(directory) return_code = bisect_utils.RunProcess(command) os.chdir(saved_dir) return return_code
def BuildImage(opts, depot): """Builds test image for cros. Args: opts: Program options containing cros_board. depot: The depot being bisected. Returns: True if successful. """ cmd = [bisect_utils.CROS_SDK_PATH] if depot != 'cros': path_to_chrome = os.path.join(os.getcwd(), '..') cmd += ['--chrome_root=%s' % path_to_chrome] cmd += ['--'] if depot != 'cros': cmd += ['CHROME_ORIGIN=LOCAL_SOURCE'] cmd += [ 'BUILDTYPE=%s' % opts.target_build_type, '--', './build_image', '--board=%s' % opts.cros_board, 'test' ] return_code = bisect_utils.RunProcess(cmd) return not return_code
def BuildWithNinja(threads, targets, build_type='Release'): """Runs a ninja command with the given targets.""" cmd = ['ninja', '-C', os.path.join('out', build_type)] if threads: cmd.append('-j%d' % threads) cmd += targets return_code = bisect_utils.RunProcess(cmd) return not return_code
def BuildWithVisualStudio(targets, build_type='Release'): """Runs a command to build the given targets with Visual Studio.""" path_to_devenv = os.path.abspath( os.path.join(os.environ['VS100COMNTOOLS'], '..', 'IDE', 'devenv.com')) path_to_sln = os.path.join(os.getcwd(), 'chrome', 'chrome.sln') cmd = [path_to_devenv, '/build', build_type, path_to_sln] for t in targets: cmd.extend(['/Project', t]) return_code = bisect_utils.RunProcess(cmd) return not return_code
def BuildWithMake(threads, targets, build_type='Release'): """Runs a make command with the given targets. Args: threads: The number of threads to use. None means unspecified/unlimited. targets: List of make targets. build_type: Release or Debug. Returns: True if the command had a 0 exit code, False otherwise. """ cmd = ['make', 'BUILDTYPE=%s' % build_type] if threads: cmd.append('-j%d' % threads) cmd += targets return_code = bisect_utils.RunProcess(cmd) return not return_code
def ImageToTarget(opts): """Installs latest image to target specified by opts.cros_remote_ip. Args: opts: Program options containing cros_board and cros_remote_ip. Returns: True if successful. """ try: # Keys will most likely be set to 0640 after wiping the chroot. os.chmod(bisect_utils.CROS_SCRIPT_KEY_PATH, 0600) os.chmod(bisect_utils.CROS_TEST_KEY_PATH, 0600) cmd = [bisect_utils.CROS_SDK_PATH, '--', './bin/cros_image_to_target.py', '--remote=%s' % opts.cros_remote_ip, '--board=%s' % opts.cros_board, '--test', '--verbose'] return_code = bisect_utils.RunProcess(cmd) return not return_code except OSError: return False