1
0
mirror of https://github.com/facebook/proxygen.git synced 2025-08-10 05:22:59 +03:00

support patchfile on all platforms

Summary: Adding patching support for all platforms using `git apply`

Reviewed By: xavierd

Differential Revision: D36939728

fbshipit-source-id: ccf6e4ccd30257c6928ba804a76882d4d2f71700
This commit is contained in:
Zeyi (Rice) Fan
2022-06-06 14:11:44 -07:00
committed by Facebook GitHub Bot
parent ce1c8c8852
commit dc2b82a801

View File

@@ -102,8 +102,7 @@ class BuilderBase(object):
return reconfigure return reconfigure
def _apply_patchfile(self) -> None: def _apply_patchfile(self) -> None:
# Only implemented patch support for linux if self.patchfile is None:
if not self.build_opts.is_linux() or self.patchfile is None:
return return
patched_sentinel_file = pathlib.Path(self.src_dir + "/.getdeps_patched") patched_sentinel_file = pathlib.Path(self.src_dir + "/.getdeps_patched")
if patched_sentinel_file.exists(): if patched_sentinel_file.exists():
@@ -111,15 +110,15 @@ class BuilderBase(object):
old_wd = os.getcwd() old_wd = os.getcwd()
os.chdir(self.src_dir) os.chdir(self.src_dir)
print(f"Patching {self.manifest.name} with {self.patchfile} in {self.src_dir}") print(f"Patching {self.manifest.name} with {self.patchfile} in {self.src_dir}")
retval = os.system( patchfile = os.path.join(
"patch " self.build_opts.fbcode_builder_dir, "patches", self.patchfile
+ self.patchfile_opts
+ " < "
+ self.build_opts.fbcode_builder_dir
+ "/patches/"
+ self.patchfile
) )
if retval != 0: patchcmd = ["git", "apply"]
if self.patchfile_opts:
patchcmd.append(self.patchfile_opts)
try:
subprocess.check_call(patchcmd + [patchfile])
except subprocess.CalledProcessError:
raise ValueError(f"Failed to apply patch to {self.manifest.name}") raise ValueError(f"Failed to apply patch to {self.manifest.name}")
os.chdir(old_wd) os.chdir(old_wd)
patched_sentinel_file.touch() patched_sentinel_file.touch()