1
0
mirror of https://github.com/facebook/proxygen.git synced 2025-08-07 07:02:53 +03:00

Add annotations to opensource/fbcode_builder

Reviewed By: shannonzhu

Differential Revision: D34332682

fbshipit-source-id: 498c63851f98dd76502a20a9d1589df5b0c4e7b9
This commit is contained in:
Pyre Bot Jr
2022-02-17 22:54:34 -08:00
committed by Facebook GitHub Bot
parent a9b46b7cc6
commit 1f77084c8e
8 changed files with 15 additions and 15 deletions

View File

@@ -86,14 +86,14 @@ class BuilderBase(object):
allow_fail=allow_fail, allow_fail=allow_fail,
) )
def _reconfigure(self, reconfigure): def _reconfigure(self, reconfigure) -> bool:
if self.build_dir is not None: if self.build_dir is not None:
if not os.path.isdir(self.build_dir): if not os.path.isdir(self.build_dir):
os.makedirs(self.build_dir) os.makedirs(self.build_dir)
reconfigure = True reconfigure = True
return reconfigure return reconfigure
def prepare(self, install_dirs, reconfigure): def prepare(self, install_dirs, reconfigure) -> None:
print("Preparing %s..." % self.manifest.name) print("Preparing %s..." % self.manifest.name)
reconfigure = self._reconfigure(reconfigure) reconfigure = self._reconfigure(reconfigure)
self._prepare(install_dirs=install_dirs, reconfigure=reconfigure) self._prepare(install_dirs=install_dirs, reconfigure=reconfigure)
@@ -143,7 +143,7 @@ class BuilderBase(object):
raise an exception.""" raise an exception."""
pass pass
def _prepare(self, install_dirs, reconfigure): def _prepare(self, install_dirs, reconfigure) -> None:
"""Prepare the build. Useful when need to generate config, """Prepare the build. Useful when need to generate config,
but builder is not the primary build system. but builder is not the primary build system.
e.g. cargo when called from cmake""" e.g. cargo when called from cmake"""
@@ -690,7 +690,7 @@ if __name__ == "__main__":
return define_args return define_args
def _build(self, install_dirs, reconfigure) -> None: def _build(self, install_dirs, reconfigure: bool) -> None:
reconfigure = reconfigure or self._needs_reconfigure() reconfigure = reconfigure or self._needs_reconfigure()
env = self._compute_env(install_dirs) env = self._compute_env(install_dirs)

View File

@@ -176,7 +176,7 @@ class BuildOptions(object):
def is_freebsd(self): def is_freebsd(self):
return self.host_type.is_freebsd() return self.host_type.is_freebsd()
def get_num_jobs(self, job_weight: int): def get_num_jobs(self, job_weight: int) -> int:
"""Given an estimated job_weight in MiB, compute a reasonable concurrency limit.""" """Given an estimated job_weight in MiB, compute a reasonable concurrency limit."""
if self.specified_num_jobs: if self.specified_num_jobs:
return self.specified_num_jobs return self.specified_num_jobs
@@ -315,7 +315,7 @@ class BuildOptions(object):
return env return env
def add_homebrew_package_to_env(self, package, env): def add_homebrew_package_to_env(self, package, env) -> bool:
prefix = homebrew_package_prefix(package) prefix = homebrew_package_prefix(package)
if prefix and os.path.exists(prefix): if prefix and os.path.exists(prefix):
return self.add_prefix_to_env( return self.add_prefix_to_env(
@@ -472,7 +472,7 @@ def find_unused_drive_letter():
return available[-1] return available[-1]
def create_subst_path(path) -> str: def create_subst_path(path: str) -> str:
for _attempt in range(0, 24): for _attempt in range(0, 24):
drive = find_existing_win32_subst_for_path( drive = find_existing_win32_subst_for_path(
path, subst_mapping=list_win32_subst_letters() path, subst_mapping=list_win32_subst_letters()

View File

@@ -122,7 +122,7 @@ directory = "{vendored_dir}"
return dep_to_git return dep_to_git
def _prepare(self, install_dirs, reconfigure): def _prepare(self, install_dirs, reconfigure) -> None:
build_source_dir = self.build_source_dir() build_source_dir = self.build_source_dir()
self.recreate_dir(self.src_dir, build_source_dir) self.recreate_dir(self.src_dir, build_source_dir)

View File

@@ -137,7 +137,7 @@ def add_path_entry(
env.set(name, separator.join(val)) env.set(name, separator.join(val))
def add_flag(env, name, flag, append: bool = True) -> None: def add_flag(env, name, flag: str, append: bool = True) -> None:
"""Cause `flag` to be added to the CXXFLAGS-style env var named """Cause `flag` to be added to the CXXFLAGS-style env var named
`name` held in the `env` dict. `append` specifies whether the `name` held in the `env` dict. `append` specifies whether the
flag is added to the end (the default) or should be prepended if flag is added to the end (the default) or should be prepended if
@@ -180,7 +180,7 @@ def path_search(env, exename, defval=None):
return result return result
def _perform_path_search(path, exename): def _perform_path_search(path, exename: str):
is_win = sys.platform.startswith("win") is_win = sys.platform.startswith("win")
if is_win: if is_win:
exename = "%s.exe" % exename exename = "%s.exe" % exename

View File

@@ -275,7 +275,7 @@ class GitFetcher(Fetcher):
return ChangeStatus(True) return ChangeStatus(True)
def update(self): def update(self) -> ChangeStatus:
if os.path.exists(self.repo_dir): if os.path.exists(self.repo_dir):
return self._update() return self._update()
self._clone() self._clone()
@@ -556,7 +556,7 @@ class SimpleShipitTransformerFetcher(Fetcher):
if os.path.exists(self.repo_dir): if os.path.exists(self.repo_dir):
shutil.rmtree(self.repo_dir) shutil.rmtree(self.repo_dir)
def update(self): def update(self) -> ChangeStatus:
mapping = ShipitPathMap() mapping = ShipitPathMap()
for src, dest in self.manifest.get_section_as_ordered_pairs( for src, dest in self.manifest.get_section_as_ordered_pairs(
"shipit.pathmap", self.ctx "shipit.pathmap", self.ctx

View File

@@ -221,7 +221,7 @@ class PythonWheelBuilder(BuilderBase):
def _add_sources( def _add_sources(
self, path_mapping: Dict[str, str], src_path: str, install_path: str self, path_mapping: Dict[str, str], src_path: str, install_path: str
): ) -> None:
s = os.lstat(src_path) s = os.lstat(src_path)
if not stat.S_ISDIR(s.st_mode): if not stat.S_ISDIR(s.st_mode):
path_mapping[src_path] = install_path path_mapping[src_path] = install_path

View File

@@ -44,7 +44,7 @@ def _print_env_diff(env, log_fn) -> None:
log_fn("+ %s=%s \\\n" % (k, shellquote(env[k]))) log_fn("+ %s=%s \\\n" % (k, shellquote(env[k])))
def run_cmd(cmd, env=None, cwd=None, allow_fail: bool = False, log_file=None): def run_cmd(cmd, env=None, cwd=None, allow_fail: bool = False, log_file=None) -> int:
def log_to_stdout(msg): def log_to_stdout(msg):
sys.stdout.buffer.write(msg.encode(errors="surrogateescape")) sys.stdout.buffer.write(msg.encode(errors="surrogateescape"))

View File

@@ -91,7 +91,7 @@ def path_join(*args) -> ShellQuoted:
return ShellQuoted(os.path.join(*[raw_shell(shell_quote(s)) for s in args])) return ShellQuoted(os.path.join(*[raw_shell(shell_quote(s)) for s in args]))
def shell_comment(c): def shell_comment(c: ShellQuoted) -> ShellQuoted:
"Do not shell-escape raw strings in comments, but do handle line breaks." "Do not shell-escape raw strings in comments, but do handle line breaks."
return ShellQuoted("# {c}").format( return ShellQuoted("# {c}").format(
c=ShellQuoted( c=ShellQuoted(