Formatting: Format all python code with black.
This CL is probably not what you're looking for, it's only
automated formatting. Ignore it with
`git blame --ignore-rev <revision>` for this commit.
BUG=b:233893248
TEST=CQ
Change-Id: I66591d7a738d241aed3290138c0f68065ab10a6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3879174
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Alex Klein <saklein@chromium.org>
diff --git a/scripts/generate_reclient_inputs.py b/scripts/generate_reclient_inputs.py
index 925452b..e74df09 100644
--- a/scripts/generate_reclient_inputs.py
+++ b/scripts/generate_reclient_inputs.py
@@ -31,84 +31,92 @@
def _GetSymLinkPath(base_dir: Path, link_path: str) -> Path:
- """Return the actual symlink path relative to base directory."""
- if not link_path:
- return None
- # Handle absolute symlink paths.
- if link_path[0] == '/':
- return link_path
- # handle relative symlinks.
- return base_dir / link_path
+ """Return the actual symlink path relative to base directory."""
+ if not link_path:
+ return None
+ # Handle absolute symlink paths.
+ if link_path[0] == "/":
+ return link_path
+ # handle relative symlinks.
+ return base_dir / link_path
def _CollectElfDeps(elfpath: Path) -> Set[Path]:
- """Returns the set of dependent files for the elf file."""
- libs = set()
- to_process = [elfpath]
- elf = lddtree.ParseELF(elfpath, ldpaths=lddtree.LoadLdpaths())
- for _, lib_data in elf['libs'].items():
- if lib_data['path']:
- to_process.append(Path(lib_data['path']))
+ """Returns the set of dependent files for the elf file."""
+ libs = set()
+ to_process = [elfpath]
+ elf = lddtree.ParseELF(elfpath, ldpaths=lddtree.LoadLdpaths())
+ for _, lib_data in elf["libs"].items():
+ if lib_data["path"]:
+ to_process.append(Path(lib_data["path"]))
- while to_process:
- path = to_process.pop()
- if not path or path in libs:
- continue
- libs.add(path)
- if path.is_symlink():
- # TODO: Replace os.readlink() by path.readlink().
- to_process.append(_GetSymLinkPath(path.parent, os.readlink(path)))
+ while to_process:
+ path = to_process.pop()
+ if not path or path in libs:
+ continue
+ libs.add(path)
+ if path.is_symlink():
+ # TODO: Replace os.readlink() by path.readlink().
+ to_process.append(_GetSymLinkPath(path.parent, os.readlink(path)))
- return libs
+ return libs
def _GenerateRemoteInputsFile(out_file: str, clang_path: Path) -> None:
- """Generate Remote Inputs for Clang for executing on reclient/RBE."""
- clang_dir = clang_path.parent
- # Start with collecting shared library dependencies.
- paths = _CollectElfDeps(clang_path)
+ """Generate Remote Inputs for Clang for executing on reclient/RBE."""
+ clang_dir = clang_path.parent
+ # Start with collecting shared library dependencies.
+ paths = _CollectElfDeps(clang_path)
- # Clang is typically a symlink, collect actual files.
- paths.add(clang_path)
+ # Clang is typically a symlink, collect actual files.
+ paths.add(clang_path)
- # Add clang resources, gcc config and glibc loader files.
- cmd = [str(clang_path), '--print-resource-dir']
- resource_dir = cros_build_lib.run(
- cmd, capture_output=True, encoding='utf-8',
- print_cmd=False).stdout.splitlines()[0]
- paths.add(Path(resource_dir) / 'share')
- paths.update(
- Path(x) for x in (
- '/etc/env.d/gcc',
- '/etc/ld.so.cache',
- '/etc/ld.so.conf',
- '/etc/ld.so.conf.d',
- ))
+ # Add clang resources, gcc config and glibc loader files.
+ cmd = [str(clang_path), "--print-resource-dir"]
+ resource_dir = cros_build_lib.run(
+ cmd, capture_output=True, encoding="utf-8", print_cmd=False
+ ).stdout.splitlines()[0]
+ paths.add(Path(resource_dir) / "share")
+ paths.update(
+ Path(x)
+ for x in (
+ "/etc/env.d/gcc",
+ "/etc/ld.so.cache",
+ "/etc/ld.so.conf",
+ "/etc/ld.so.conf.d",
+ )
+ )
- # Write the files relative to clang binary location.
- osutils.WriteFile(
- clang_dir / out_file,
- [os.path.relpath(x, clang_dir) + '\n' for x in sorted(paths)],
- sudo=True)
+ # Write the files relative to clang binary location.
+ osutils.WriteFile(
+ clang_dir / out_file,
+ [os.path.relpath(x, clang_dir) + "\n" for x in sorted(paths)],
+ sudo=True,
+ )
def ParseArgs(argv: Optional[List[str]]) -> argparse.Namespace:
- """Parses program arguments."""
- parser = commandline.ArgumentParser(description=__doc__)
+ """Parses program arguments."""
+ parser = commandline.ArgumentParser(description=__doc__)
- parser.add_argument(
- '--output',
- default='remote_toolchain_inputs',
- help='Name of remote toolchain file relative to clang binary directory.')
- parser.add_argument(
- '--clang', type=Path, default='/usr/bin/clang', help='Clang binary path.')
+ parser.add_argument(
+ "--output",
+ default="remote_toolchain_inputs",
+ help="Name of remote toolchain file relative to clang binary directory.",
+ )
+ parser.add_argument(
+ "--clang",
+ type=Path,
+ default="/usr/bin/clang",
+ help="Clang binary path.",
+ )
- opts = parser.parse_args(argv)
- opts.Freeze()
- return opts
+ opts = parser.parse_args(argv)
+ opts.Freeze()
+ return opts
def main(argv: Optional[List[str]] = None) -> Optional[int]:
- cros_build_lib.AssertInsideChroot()
- opts = ParseArgs(argv)
- _GenerateRemoteInputsFile(opts.output, opts.clang)
+ cros_build_lib.AssertInsideChroot()
+ opts = ParseArgs(argv)
+ _GenerateRemoteInputsFile(opts.output, opts.clang)