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

Add patchfile support to getdeps

Summary:
This adds the ability to specify a patch file to be applied on top of any library in getdeps.

For example, zlib doesn't support static linking with CMake, but there's a small patch that can be applied to support static linking. This is the specific use case this diff is intended to support.

Reviewed By: bigfootjon

Differential Revision: D35410512

fbshipit-source-id: d1af0ddf9ec45ef28aa902c06735af86817ac194
This commit is contained in:
David Greenberg
2022-04-07 08:36:02 -07:00
committed by Facebook GitHub Bot
parent 2526d2f007
commit 20c5bb797b
2 changed files with 30 additions and 0 deletions

View File

@@ -7,6 +7,7 @@
import glob
import json
import os
import pathlib
import shutil
import stat
import subprocess
@@ -38,6 +39,8 @@ class BuilderBase(object):
if subdir:
src_dir = os.path.join(src_dir, subdir)
self.patchfile = manifest.get("build", "patchfile", ctx=ctx)
self.patchfile_opts = manifest.get("build", "patchfile_opts", ctx=ctx) or ""
self.ctx = ctx
self.src_dir = src_dir
self.build_dir = build_dir or src_dir
@@ -93,14 +96,39 @@ class BuilderBase(object):
reconfigure = True
return reconfigure
def _apply_patchfile(self) -> None:
# Only implemented patch support for linux
if not self.build_opts.is_linux() or self.patchfile is None:
return
patched_sentinel_file = pathlib.Path(self.src_dir + "/.getdeps_patched")
if patched_sentinel_file.exists():
return
old_wd = os.getcwd()
os.chdir(self.src_dir)
print(f"Patching {self.manifest.name} with {self.patchfile} in {self.src_dir}")
retval = os.system(
"patch "
+ self.patchfile_opts
+ " < "
+ self.build_opts.fbcode_builder_dir
+ "/patches/"
+ self.patchfile
)
if retval != 0:
raise ValueError(f"Failed to apply patch to {self.manifest.name}")
os.chdir(old_wd)
patched_sentinel_file.touch()
def prepare(self, install_dirs, reconfigure: bool) -> None:
print("Preparing %s..." % self.manifest.name)
reconfigure = self._reconfigure(reconfigure)
self._apply_patchfile()
self._prepare(install_dirs=install_dirs, reconfigure=reconfigure)
def build(self, install_dirs, reconfigure: bool) -> None:
print("Building %s..." % self.manifest.name)
reconfigure = self._reconfigure(reconfigure)
self._apply_patchfile()
self._prepare(install_dirs=install_dirs, reconfigure=reconfigure)
self._build(install_dirs=install_dirs, reconfigure=reconfigure)