Example #1
0
def _SetupPrebuiltTools(adb):
    """Some of the android pylib scripts we depend on are lame and expect
  binaries to be in the out/ directory. So we copy any prebuilt binaries there
  as a prereq."""

    # TODO(bulach): Build the targets for x86/mips.
    device_tools = [
        'file_poller',
        'forwarder_dist/device_forwarder',
        'md5sum_dist/md5sum_bin',
        'purge_ashmem',
        'run_pie',
    ]

    host_tools = [
        'bitmaptools',
        'md5sum_bin_host',
    ]

    if platform.GetHostPlatform().GetOSName() == 'linux':
        host_tools.append('host_forwarder')

    arch_name = adb.device().GetABI()
    has_device_prebuilt = (arch_name.startswith('armeabi')
                           or arch_name.startswith('arm64'))
    if not has_device_prebuilt:
        logging.warning('Unknown architecture type: %s' % arch_name)
        return all(
            [support_binaries.FindLocallyBuiltPath(t) for t in device_tools])

    build_type = None
    for t in device_tools + host_tools:
        executable = os.path.basename(t)
        locally_built_path = support_binaries.FindLocallyBuiltPath(t)
        if not build_type:
            build_type = _GetBuildTypeOfPath(locally_built_path) or 'Release'
            constants.SetBuildType(build_type)
        dest = os.path.join(constants.GetOutDirectory(), t)
        if not locally_built_path:
            logging.info('Setting up prebuilt %s', dest)
            if not os.path.exists(os.path.dirname(dest)):
                os.makedirs(os.path.dirname(dest))
            platform_name = ('android' if t in device_tools else
                             platform.GetHostPlatform().GetOSName())
            bin_arch_name = (arch_name if t in device_tools else
                             platform.GetHostPlatform().GetArchName())
            prebuilt_path = support_binaries.FindPath(executable,
                                                      bin_arch_name,
                                                      platform_name)
            if not prebuilt_path or not os.path.exists(prebuilt_path):
                raise NotImplementedError("""
%s must be checked into cloud storage.
Instructions:
http://www.chromium.org/developers/telemetry/upload_to_cloud_storage
""" % t)
            shutil.copyfile(prebuilt_path, dest)
            os.chmod(dest, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
    return True
Example #2
0
    def LocalPath(self, dependency, platform, try_support_binaries=False):
        """Get a path to a locally stored executable for |dependency|.

    A path to a default executable may be returned if a platform specific
    version is not specified in the config(s).
    Will not download the executable.

    Args:
        dependency: Name of the desired dependency, as given in the config(s)
            used in this DependencyManager.
        platform: Name of the platform the dependency will run on. Often of the
            form 'os_architecture'. Must match those specified in the config(s)
            used in this DependencyManager.
        try_support_binaries: True if support_binaries should be queried if the
            dependency_manager was not initialized with data for |dependency|.

    Returns:
        A path to an executable for |dependency| that will run on |platform|.

    Raises:
        NoPathFoundError: If a local copy of the executable cannot be found.
    """
        # TODO(aiolos): Remove the support_binaries call and always raise
        # NoPathFound once the binary dependencies are moved over to the new
        # system.
        dependency_info = self._GetDependencyInfo(dependency, platform)
        if not dependency_info:
            if not try_support_binaries:
                raise exceptions.NoPathFoundError(dependency, platform)
            return support_binaries.FindLocallyBuiltPath(dependency)
        local_path = self._LocalPath(dependency_info)
        if not local_path or not os.path.exists(local_path):
            raise exceptions.NoPathFoundError(dependency, platform)
        return local_path
Example #3
0
def LocalPath(binary_name, platform, arch):
  """ Return a local path to the given binary name, or None if an executable
      cannot be found. Will not download the executable.
      """
  del platform, arch
  return support_binaries.FindLocallyBuiltPath(binary_name)