def ListInstalledPackages(board, all_packages=False): """Return a list of all packages installed for a particular board.""" # If all_packages is set to True, all packages visible in the build # chroot are used to generate the licensing file. This is not what you want # for a release license file, but it's a way to run licensing checks against # all packages. # If it's set to False, it will only generate a licensing file that contains # packages used for a release build (as determined by the dependencies for # virtual/target-os). if all_packages: # The following returns all packages that were part of the build tree # (many get built or used during the build, but do not get shipped). # Note that it also contains packages that are in the build as # defined by build_packages but not part of the image we ship. equery_cmd = cros_build_lib.GetSysrootToolPath( cros_build_lib.GetSysroot(board), 'equery') args = [equery_cmd, 'list', '*'] packages = cros_build_lib.RunCommand( args, print_cmd=debug, redirect_stdout=True).output.splitlines() else: # The following returns all packages that were part of the build tree # (many get built or used during the build, but do not get shipped). # Note that it also contains packages that are in the build as # defined by build_packages but not part of the image we ship. emerge_cmd = cros_build_lib.GetSysrootToolPath( cros_build_lib.GetSysroot(board), 'emerge') args = [ emerge_cmd, '--with-bdeps=y', '--usepkgonly', '--emptytree', '--pretend', '--color=n', 'virtual/target-os' ] emerge = cros_build_lib.RunCommand( args, print_cmd=debug, redirect_stdout=True).output.splitlines() # Another option which we've decided not to use, is bdeps=n. This outputs # just the packages we ship, but does not packages that were used to build # them, including a package like flex which generates a .a that is included # and shipped in ChromeOS. # We've decided to credit build packages, even if we're not legally required # to (it's always nice to do), and that way we get corner case packages like # flex. This is why we use bdep=y and not bdep=n. packages = [] # [binary R ] x11-libs/libva-1.1.1 to /build/x86-alex/ pkg_rgx = re.compile(r'\[[^]]+R[^]]+\] (.+) to /build/.*') # If we match something else without the 'R' like # [binary U ] chromeos-base/pepper-flash-13.0.0.133-r1 [12.0.0.77-r1] # this is bad and we should die on this. pkg_rgx2 = re.compile(r'(\[[^]]+\] .+) to /build/.*') for line in emerge: match = pkg_rgx.search(line) match2 = pkg_rgx2.search(line) if match: packages.append(match.group(1)) elif match2: raise AssertionError( 'Package incorrectly installed, try eclean-%s' % board, '\n%s' % match2.group(1)) return packages
def run_tidy(board: str, ebuild_list: List[portage_util.EBuild], keep_dirs: bool, parse_errors_are_nonfatal: bool) -> Set[TidyDiagnostic]: """Runs clang-tidy on the given ebuilds for the given board. Returns the set of |TidyDiagnostic|s produced by doing so. """ # Since we rely on build actions _actually_ running, we can't live with a # cache. osutils.RmDir( Path(cros_build_lib.GetSysroot(board)) / 'var' / 'cache' / 'portage', ignore_missing=True, sudo=True, ) results = set() # If clang-tidy dumps a lot of diags, it can take 1-10secs of CPU while # holding the GIL to |yaml.load| on my otherwise-idle dev box. |yaml_pool| # lets us do this in parallel. with multiprocessing.pool.Pool() as yaml_pool: for ebuild in ebuild_list: lint_tmpdir = generate_lints(board, ebuild.ebuild_path) try: results |= collect_lints(lint_tmpdir, yaml_pool) except ClangTidyParseError: if not parse_errors_are_nonfatal: raise logging.exception('Working on %r', ebuild) finally: if keep_dirs: logging.info('Lints for %r are in %r', ebuild.ebuild_path, lint_tmpdir) else: osutils.RmDir(lint_tmpdir, ignore_missing=True, sudo=True) return results
def _FindEbuildPath(self): """Discover the path to a package's associated ebuild. This method is not valid during the emerge hook process. Returns: full path file name of the ebuild file for this package. Raises: AssertionError if it can't be discovered for some reason. """ equery_cmd = cros_build_lib.GetSysrootToolPath( cros_build_lib.GetSysroot(self.board), 'equery') args = [equery_cmd, '-q', '-C', 'which', self.fullnamerev] try: path = cros_build_lib.RunCommand( args, print_cmd=True, redirect_stdout=True).output.strip() except cros_build_lib.RunCommandError: path = None # Path can be false because of an exception, or a command result. if not path: raise AssertionError('_FindEbuildPath for %s failed.\n' 'Is your tree clean? Try a rebuild?' % self.fullnamerev) logging.debug('%s -> %s', ' '.join(args), path) if not os.access(path, os.F_OK): raise AssertionError('Can\'t access %s', path) return path
def main(argv): options = ParseArgs(argv) if not cros_build_lib.IsInsideChroot(): raise commandline.ChrootRequiredError() if os.geteuid() != 0: cros_build_lib.SudoRunCommand(sys.argv) return # sysroot must have a trailing / as the tree dictionary produced by # create_trees in indexed with a trailing /. sysroot = cros_build_lib.GetSysroot(options.board) + '/' trees = create_trees(target_root=sysroot, config_root=sysroot) vartree = trees[sysroot]['vartree'] cache_dir = os.path.join(path_util.FindCacheDir(), 'cros_install_debug_syms-v' + CACHE_VERSION) if options.clearcache: osutils.RmDir(cache_dir, ignore_missing=True) binhost_cache = None if options.cachebinhost: binhost_cache = cache.DiskCache(cache_dir) boto_file = vartree.settings['BOTO_CONFIG'] if boto_file: os.environ['BOTO_CONFIG'] = boto_file gs_context = gs.GSContext() symbols_mapping = RemoteSymbols(vartree, binhost_cache) if options.all: to_install = vartree.dbapi.cpv_all() else: to_install = [GetMatchingCPV(p, vartree.dbapi) for p in options.packages] to_install = [p for p in to_install if ShouldGetSymbols(p, vartree.dbapi, symbols_mapping)] if not to_install: logging.info('nothing to do, exit') return with DebugSymbolsInstaller(vartree, gs_context, sysroot, not options.debug) as installer: args = [(p, symbols_mapping[p]) for p in to_install] parallel.RunTasksInProcessPool(installer.Install, args, processes=options.jobs) logging.debug('installation done, updating packages index file') packages_dir = os.path.join(sysroot, 'packages') packages_file = os.path.join(packages_dir, 'Packages') # binpkg will set DEBUG_SYMBOLS automatically if it detects the debug symbols # in the packages dir. pkgindex = binpkg.GrabLocalPackageIndex(packages_dir) with open(packages_file, 'w') as p: pkgindex.Write(p)
def FindSymbols(firmware_dir, board, use): """Find the symbolized depthcharge ELF (may be supplied by -s flag).""" if not firmware_dir: firmware_dir = os.path.join(cros_build_lib.GetSysroot(board), 'firmware') # Allow overriding the file directly just in case our detection screws up if firmware_dir.endswith('.elf'): return firmware_dir if 'unified_depthcharge' in use: basename = 'dev.elf' else: basename = 'dev.ro.elf' path = os.path.join(firmware_dir, 'depthcharge', basename) if not os.path.exists(path): path = os.path.join(firmware_dir, basename) if os.path.exists(path): logging.warning( 'Auto-detected symbol file at %s... make sure that this ' 'matches the image on your DUT!', path) return path raise ValueError('Could not find %s symbol file!' % basename)
def DebugInfoTest(input_proto, _output_proto, config): """Run the debug info tests.""" sysroot_path = input_proto.sysroot.path target_name = input_proto.sysroot.build_target.name if not sysroot_path: if target_name: sysroot_path = cros_build_lib.GetSysroot(target_name) else: cros_build_lib.Die( "The sysroot path or the sysroot's build target name " 'must be provided.') # We could get away with out this, but it's a cheap check. sysroot = sysroot_lib.Sysroot(sysroot_path) if not sysroot.Exists(): cros_build_lib.Die('The provided sysroot does not exist.') if config.validate_only: return controller.RETURN_CODE_VALID_INPUT if test.DebugInfoTest(sysroot_path): return controller.RETURN_CODE_SUCCESS else: return controller.RETURN_CODE_COMPLETED_UNSUCCESSFULLY
def _InstallBuildDependencies(self): # Calculate buildtime deps that are not runtime deps. raw_sysroot = cros_build_lib.GetSysroot(board=self.options.board) packages = [] if not self.options.deps_only: packages = self.options.package.split() else: for pkg in self.options.package.split(): cmd = ['qdepends', '-q', '-C', pkg] output = cros_build_lib.run(cmd, extra_env={ 'ROOT': raw_sysroot }, capture_output=True).output if output.count('\n') > 1: raise AssertionError( 'Too many packages matched for given pattern') # qdepend outputs "package: deps", so only grab the deps. deps = output.partition(':')[2].split() packages.extend(deps) # Install the required packages. if packages: self._Emerge(*packages)
def GenerateSysroot(sysroot_path, board, build_tests, unpack_only=False): """Create a sysroot using only binary packages from local binhost. Args: sysroot_path: Where we want to place the sysroot. board: Board we want to build for. build_tests: If we should include autotest packages. unpack_only: If we only want to unpack the binary packages, and not build them. """ osutils.SafeMakedirs(sysroot_path) if not unpack_only: # Generate the sysroot configuration. sysroot = sysroot_lib.Sysroot(sysroot_path) sysroot.WriteConfig(sysroot.GenerateBoardConfiguration(board)) cros_build_lib.RunCommand( [os.path.join(constants.CROSUTILS_DIR, 'install_toolchain'), '--noconfigure', '--sysroot', sysroot_path]) cmd = list(_BUILD_PKGS_CMD) cmd.extend(['--board_root', sysroot_path, '--board', board]) if unpack_only: cmd.append('--unpackonly') if not build_tests: cmd.append('--nowithautotest') env = {'USE': os.environ.get('USE', ''), 'PORTAGE_BINHOST': 'file://%s' % portage_util.GetBinaryPackageDir( sysroot=cros_build_lib.GetSysroot(board))} cros_build_lib.RunCommand(cmd, extra_env=env)
def __init__(self, test_bin, board, host, framework, run_as_root, gtest_filter, user_gtest_filter, sysroot, test_bin_args): if not test_bin_args: test_bin_args = [test_bin] if not test_bin: test_bin = test_bin_args[0] self.bin = test_bin self.args = test_bin_args self.board = board self.host = host self.run_as_root = run_as_root (self.gtest_filter, self.user_gtest_filter) = \ self.generateGtestFilter(gtest_filter, user_gtest_filter) if sysroot: self.sysroot = sysroot else: self.sysroot = cros_build_lib.GetSysroot(self.board) self.framework = framework if self.framework == 'auto': qemu_arch = qemu.Qemu.DetectArch(self.bin, self.sysroot) if qemu_arch is None: self.framework = 'ldso' else: self.framework = 'qemu' if self.framework == 'qemu': self.qemu = qemu.Qemu(self.sysroot, arch=qemu_arch)
def PerformStage(self): cmd = [ 'debug_info_test', os.path.join(cros_build_lib.GetSysroot(board=self._current_board), 'usr/lib/debug') ] cros_build_lib.run(cmd, enter_chroot=True)
def main(argv): opts = ParseArgs(argv) sysroot = opts.sysroot or cros_build_lib.GetSysroot(opts.board) deps_list, _ = ExtractDeps(sysroot, opts.pkgs, opts.format) pformat.json(deps_list, fp=opts.output_path if opts.output_path else sys.stdout)
def license_dump_path(self): """e.g. /build/x86-alex/var/db/pkg/sys-apps/dtc-1.4.0/license.yaml. Only valid for packages that have already been emerged. """ return os.path.join(cros_build_lib.GetSysroot(self.board), PER_PKG_LICENSE_DIR, self.fullnamerev, 'license.yaml')
def main(argv): parser = GetParser() options = parser.parse_args(argv) options.Freeze() if options.command == 'list-all': board_to_packages = workon_helper.ListAllWorkedOnAtoms() color = terminal.Color() for board in sorted(board_to_packages): print(color.Start(color.GREEN) + board + ':' + color.Stop()) for package in board_to_packages[board]: print(' ' + package) print('') return 0 # TODO(wiley): Assert that we're not running as root. cros_build_lib.AssertInsideChroot() if options.host: friendly_name = 'host' sysroot = '/' elif options.board: friendly_name = options.board sysroot = cros_build_lib.GetSysroot(board=options.board) else: cros_build_lib.Die('You must specify either --host, --board') helper = workon_helper.WorkonHelper(sysroot, friendly_name) try: if options.command == 'start': helper.StartWorkingOnPackages(options.packages, use_all=options.all, use_workon_only=options.workon_only) elif options.command == 'stop': helper.StopWorkingOnPackages(options.packages, use_all=options.all, use_workon_only=options.workon_only) elif options.command == 'info': triples = helper.GetPackageInfo( options.packages, use_all=options.all, use_workon_only=options.workon_only) for package, repos, paths in triples: print(package, ','.join(repos), ','.join(paths)) elif options.command == 'list': packages = helper.ListAtoms(use_all=options.all, use_workon_only=options.workon_only) if packages: print('\n'.join(packages)) elif options.command == 'iterate': helper.RunCommandInPackages(options.packages, options.iterate_command, use_all=options.all, use_workon_only=options.workon_only) except workon_helper.WorkonError as e: cros_build_lib.Die(e) return 0
def _GenerateTestBits(self, tempdir): """Generate and transfer to the Moblab the test bits we require. Args: tempdir: Temporary Directory to store the generated test artifacts. """ build_root = cros_build_lib.GetSysroot(board=self.board) cwd = os.path.join(build_root, BOARD_BUILD_DIR) commands.BuildAutotestTarballsForHWTest(build_root, cwd, tempdir)
def main(): opts = ParseArgs(sys.argv[1:]) sysroot = opts.sysroot or cros_build_lib.GetSysroot(opts.build_target) out_dir = opts.output_path or '.' out_name = opts.output_name runtime_tree = CreateRuntimeTree(sysroot, opts.pkgs) dep_vis = visualize.DepVisualizer(runtime_tree) dep_vis.VisualizeGraph(output_name=out_name, output_dir=out_dir) if opts.include_histograms: dep_vis.GenerateHistograms(opts.build_target, out_dir)
def SetPathToSysroot(cls, board): """Sets path_to_sysroot Args: board: The board we will use for our sysroot. Returns: The path to the sysroot (the value of path_to_sysroot). """ cls.path_to_sysroot = cros_build_lib.GetSysroot(board) return cls.path_to_sysroot
def main(argv): opts = ParseArgs(argv) cros_build_lib.AssertInsideChroot() sysroot = opts.sysroot or cros_build_lib.GetSysroot(opts.board) package_blacklist = portage_util.UNITTEST_PACKAGE_BLACKLIST if opts.package_blacklist: package_blacklist |= set(opts.package_blacklist.split()) packages = set() # The list of packages to test can be passed as a file containing a # space-separated list of package names. # This is used by the builder to test only the packages that were upreved. if opts.package_file and os.path.exists(opts.package_file): packages = set(osutils.ReadFile(opts.package_file).split()) if opts.packages: packages |= set(opts.packages.split()) # If no packages were specified, use all testable packages. if not (opts.packages or opts.package_file): workon = workon_helper.WorkonHelper(sysroot) packages = (workon.InstalledWorkonAtoms() if opts.installed else workon.ListAtoms(use_all=True)) for cp in packages & package_blacklist: logging.info('Skipping blacklisted package %s.', cp) packages = packages - package_blacklist pkg_with_test = portage_util.PackagesWithTest(sysroot, packages) if packages - pkg_with_test: logging.warning('The following packages do not have tests:') logging.warning('\n'.join(sorted(packages - pkg_with_test))) if opts.pretend: print('\n'.join(sorted(pkg_with_test))) return env = None if opts.nowithdebug: use_flags = os.environ.get('USE', '') use_flags += ' -cros-debug' env = {'USE': use_flags} try: chroot_util.RunUnittests(sysroot, pkg_with_test, extra_env=env, jobs=min(10, multiprocessing.cpu_count())) except cros_build_lib.RunCommandError: logging.error('Unittests failed.') raise
def main(argv): opts = ParseArgs(argv) sysroot = opts.sysroot or cros_build_lib.GetSysroot(opts.board) deps_list, _ = ExtractDeps(sysroot, opts.pkgs, opts.format) deps_output = json.dumps(deps_list, sort_keys=True, indent=2) if opts.output_path: with open(opts.output_path, 'w') as f: f.write(deps_output) else: print(deps_output)
def main(argv): logging.getLogger().setLevel(logging.INFO) flags = _ParseArguments(argv) sysroot = None if flags.board: sysroot = cros_build_lib.GetSysroot(flags.board) elif flags.host: sysroot = '/' else: sysroot = flags.sysroot modified = ListModifiedWorkonPackages(sysroot_lib.Sysroot(sysroot)) print(' '.join(sorted(modified)))
def main(args): parser = get_parser() opts = parser.parse_args(args) if not opts.output and not opts.gen_licenses: parser.error('You must specify --output and/or --generate-licenses') sysroot = opts.sysroot or cros_build_lib.GetSysroot(opts.board) licensing = LoadPackageInfo(sysroot, opts.all_packages, opts.gen_licenses, opts.packages) if opts.output: licensing.GenerateHTMLLicenseOutput(opts.output)
def _RunEbuildPhases(self, ebuild_path, phases): """Run a list of ebuild phases on an ebuild. Args: ebuild_path: exact path of the ebuild file. phases: list of phases like ['clean', 'fetch'] or ['unpack']. Returns: ebuild command output """ ebuild_cmd = cros_build_lib.GetSysrootToolPath( cros_build_lib.GetSysroot(self.board), 'ebuild') return cros_build_lib.RunCommand([ebuild_cmd, ebuild_path] + phases, print_cmd=debug, redirect_stdout=True)
def _GenerateTestBits(self, tempdir): """Generate and transfer to the Moblab the test bits we require. Args: tempdir: Temporary Directory to store the generated test artifacts. """ build_root = cros_build_lib.GetSysroot(board=self.board) cwd = os.path.join(build_root, BOARD_BUILD_DIR) tarball_funcs = [ commands.BuildAutotestControlFilesTarball, commands.BuildAutotestPackagesTarball, commands.BuildAutotestTestSuitesTarball, commands.BuildAutotestServerPackageTarball ] for tarball_func in tarball_funcs: tarball_func(build_root, cwd, tempdir)
def AddLicensingFile(self, dlc_dir): """Add the licensing file for this DLC. Args: dlc_dir: (str) The path to the mounted point during image creation. """ if not self.ebuild_params.fullnamerev: return sysroot = cros_build_lib.GetSysroot(self.board) licensing = licenses_lib.Licensing(sysroot, [self.ebuild_params.fullnamerev], True) licensing.LoadPackageInfo() licensing.ProcessPackageLicenses() license_path = os.path.join(dlc_dir, LICENSE) # The first (and only) item contains the values for |self.fullnamerev|. _, license_txt = next(iter(licensing.GenerateLicenseText().items())) osutils.WriteFile(license_path, license_txt)
def LoadPackageInfo(board, all_packages, generateMissing, packages): """Do the work when we're not called as a hook.""" logging.info('Using board %s.', board) builddir = os.path.join(cros_build_lib.GetSysroot(board=board), 'tmp', 'portage') if not os.path.exists(builddir): raise AssertionError( 'FATAL: %s missing.\n' 'Did you give the right board and build that tree?' % builddir) detect_packages = not packages if detect_packages: # If no packages were specified, we look up the full list. packages = licenses_lib.ListInstalledPackages(board, all_packages) if not packages: raise AssertionError('FATAL: Could not get any packages for board %s' % board) logging.debug('Initial Package list to work through:\n%s', '\n'.join(sorted(packages))) licensing = licenses_lib.Licensing(board, packages, generateMissing) licensing.LoadPackageInfo() logging.debug( 'Package list to skip:\n%s', '\n'.join([p for p in sorted(packages) if licensing.packages[p].skip])) logging.debug( 'Package list left to work through:\n%s', '\n'.join( [p for p in sorted(packages) if not licensing.packages[p].skip])) licensing.ProcessPackageLicenses() if detect_packages: # If we detected 'all' packages, we have to add in these extras. for fullnamewithrev, homepages, names, files in EXTRA_PACKAGES: license_texts = [ osutils.ReadFile(os.path.join(EXTRA_LICENSES_DIR, f)) for f in files ] licensing.AddExtraPkg(fullnamewithrev, homepages, names, license_texts) return licensing
def __init__(self, options): super(BuildCommand, self).__init__(options) self.chroot_update = options.chroot_update and options.deps if options.chroot_update and not options.deps: logging.debug('Skipping chroot update due to --nodeps') self.build_pkgs = options.packages self.host = False self.board = None if self.options.host: self.host = True elif self.options.board: self.board = self.options.board else: # If nothing is explicitly set, use the default board. self.board = cros_build_lib.GetDefaultBoard() # Set sysroot and friendly name. The latter is None if building for host. self.sysroot = cros_build_lib.GetSysroot(self.board)
def GenerateSDKCPVList(board): """Find all SDK packages from package.provided Args: board: The board to use when finding SDK packages. Returns: A list of CPV Name strings, e.g. ["sys-libs/glibc-2.23-r9", "dev-lang/go-1.8.3-r1"] """ # Look at packages in package.provided. board_root = cros_build_lib.GetSysroot(board) sdk_file_path = os.path.join(board_root, 'etc', 'portage', 'profile', 'package.provided') for line in osutils.ReadFile(sdk_file_path).splitlines(): # Skip comments and empty lines. line = line.split('#', 1)[0].strip() if not line: continue yield line
def _InstallBuildDependencies(self): # Calculate buildtime deps that are not runtime deps. raw_sysroot = cros_build_lib.GetSysroot(board=self.options.board) cmd = ['qdepends', '-q', '-C', self.options.package] output = cros_build_lib.RunCommand(cmd, extra_env={ 'ROOT': raw_sysroot }, capture_output=True).output if output.count('\n') > 1: raise AssertionError( 'Too many packages matched given package pattern') # qdepend outputs "package: deps", so only grab the deps. atoms = output.partition(':')[2].split() # Install the buildtime deps. if atoms: self._Emerge(*atoms)
def main(argv): if not cros_build_lib.IsInsideChroot(): raise commandline.ChrootRequiredError(argv) cmd = [ os.path.join(constants.CHROMITE_BIN_DIR, 'cros_install_debug_syms') ] + argv if os.geteuid() != 0: cros_build_lib.sudo_run(cmd) return options = ParseArgs(argv) # sysroot must have a trailing / as the tree dictionary produced by # create_trees in indexed with a trailing /. sysroot = cros_build_lib.GetSysroot(options.board) + '/' if options.list: ListInstallArgs(options, sysroot) return args = GetInstallArgsList(cmd) if not args: logging.info('No packages found needing debug symbols.') return # Partial to simplify the arguments to parallel since the first two are the # same for every call. partial_install = functools.partial(_InstallOne, sysroot, options.debug) pool = multiprocessing.Pool(processes=options.jobs) pool.map(partial_install, args) logging.debug('installation done, updating packages index file') packages_dir = os.path.join(sysroot, 'packages') packages_file = os.path.join(packages_dir, 'Packages') # binpkg will set DEBUG_SYMBOLS automatically if it detects the debug symbols # in the packages dir. pkgindex = binpkg.GrabLocalPackageIndex(packages_dir) with open(packages_file, 'w') as p: pkgindex.Write(p)
def FindSymbols(firmware_dir, board): """Find the symbolized depthcharge ELF (may be supplied by -s flag).""" # Allow overriding the file directly just in case our detection screws up. if firmware_dir and firmware_dir.endswith('.elf'): return firmware_dir if not firmware_dir: # Unified builds have the format # /build/<board|family>/firmware/<build_target|model>/. The board in # depthcharge corresponds to the build_target in unified builds. For this # reason we need to glob all boards to find the correct build_target. unified_build_dirs = glob.glob('/build/*/firmware/%s' % board) if len(unified_build_dirs) == 1: firmware_dir = unified_build_dirs[0] elif len(unified_build_dirs) > 1: raise ValueError( 'Multiple boards were found (%s). Use -s to specify manually' % (', '.join(unified_build_dirs))) if not firmware_dir: firmware_dir = os.path.join(cros_build_lib.GetSysroot(board), 'firmware') # Very old firmware you might still find on GoldenEye had dev.ro.elf. basenames = ['dev.elf', 'dev.ro.elf'] for basename in basenames: path = os.path.join(firmware_dir, 'depthcharge', basename) if not os.path.exists(path): path = os.path.join(firmware_dir, basename) if os.path.exists(path): logging.warning( 'Auto-detected symbol file at %s... make sure that this' ' matches the image on your DUT!', path) return path raise ValueError('Could not find depthcharge symbol file (dev.elf)! ' '(You can use -s to supply it manually.)')
def FindSymbols(firmware_dir, board): """Find the symbolized depthcharge ELF (may be supplied by -s flag).""" if not firmware_dir: firmware_dir = os.path.join(cros_build_lib.GetSysroot(board), 'firmware') # Allow overriding the file directly just in case our detection screws up if firmware_dir.endswith('.elf'): return firmware_dir # Very old firmware you might still find on GoldenEye had dev.ro.elf. basenames = ['dev.elf', 'dev.ro.elf'] for basename in basenames: path = os.path.join(firmware_dir, 'depthcharge', basename) if not os.path.exists(path): path = os.path.join(firmware_dir, basename) if os.path.exists(path): logging.warning( 'Auto-detected symbol file at %s... make sure that this' ' matches the image on your DUT!', path) return path raise ValueError('Could not find depthcharge symbol file (dev.elf)! ' '(You can use -s to supply it manually.)')