mirror of
https://github.com/facebook/proxygen.git
synced 2025-08-08 18:02:05 +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:
committed by
Facebook GitHub Bot
parent
2526d2f007
commit
20c5bb797b
@@ -7,6 +7,7 @@
|
|||||||
import glob
|
import glob
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import pathlib
|
||||||
import shutil
|
import shutil
|
||||||
import stat
|
import stat
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -38,6 +39,8 @@ class BuilderBase(object):
|
|||||||
if subdir:
|
if subdir:
|
||||||
src_dir = os.path.join(src_dir, 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.ctx = ctx
|
||||||
self.src_dir = src_dir
|
self.src_dir = src_dir
|
||||||
self.build_dir = build_dir or src_dir
|
self.build_dir = build_dir or src_dir
|
||||||
@@ -93,14 +96,39 @@ class BuilderBase(object):
|
|||||||
reconfigure = True
|
reconfigure = True
|
||||||
return reconfigure
|
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:
|
def prepare(self, install_dirs, reconfigure: bool) -> None:
|
||||||
print("Preparing %s..." % self.manifest.name)
|
print("Preparing %s..." % self.manifest.name)
|
||||||
reconfigure = self._reconfigure(reconfigure)
|
reconfigure = self._reconfigure(reconfigure)
|
||||||
|
self._apply_patchfile()
|
||||||
self._prepare(install_dirs=install_dirs, reconfigure=reconfigure)
|
self._prepare(install_dirs=install_dirs, reconfigure=reconfigure)
|
||||||
|
|
||||||
def build(self, install_dirs, reconfigure: bool) -> None:
|
def build(self, install_dirs, reconfigure: bool) -> None:
|
||||||
print("Building %s..." % self.manifest.name)
|
print("Building %s..." % self.manifest.name)
|
||||||
reconfigure = self._reconfigure(reconfigure)
|
reconfigure = self._reconfigure(reconfigure)
|
||||||
|
self._apply_patchfile()
|
||||||
self._prepare(install_dirs=install_dirs, reconfigure=reconfigure)
|
self._prepare(install_dirs=install_dirs, reconfigure=reconfigure)
|
||||||
self._build(install_dirs=install_dirs, reconfigure=reconfigure)
|
self._build(install_dirs=install_dirs, reconfigure=reconfigure)
|
||||||
|
|
||||||
|
@@ -65,6 +65,8 @@ SCHEMA = {
|
|||||||
"make_binary": OPTIONAL,
|
"make_binary": OPTIONAL,
|
||||||
"build_in_src_dir": OPTIONAL,
|
"build_in_src_dir": OPTIONAL,
|
||||||
"job_weight_mib": OPTIONAL,
|
"job_weight_mib": OPTIONAL,
|
||||||
|
"patchfile": OPTIONAL,
|
||||||
|
"patchfile_opts": OPTIONAL,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"msbuild": {"optional_section": True, "fields": {"project": REQUIRED}},
|
"msbuild": {"optional_section": True, "fields": {"project": REQUIRED}},
|
||||||
|
Reference in New Issue
Block a user