add PKG_CONFIG_PATH in the env variable for build cmds

Summary: This enables appending PKG_CONFIG_PATH to env variable

Reviewed By: wez

Differential Revision: D17363236

fbshipit-source-id: 18c6d7a97ba83edf085278bccaafa80821ea8860
This commit is contained in:
Udip Pant 2019-09-18 11:54:27 -07:00 committed by Facebook Github Bot
parent 53d238a0cd
commit 7a1a19bd7e
2 changed files with 16 additions and 8 deletions

View File

@ -103,11 +103,19 @@ class MakeBuilder(BuilderBase):
self.args = args or [] self.args = args or []
def _build(self, install_dirs, reconfigure): def _build(self, install_dirs, reconfigure):
cmd = ["make", "-j%s" % self.build_opts.num_jobs] + self.args env = self._compute_env(install_dirs)
self._run_cmd(cmd)
# Need to ensure that PREFIX is set prior to install because
# libbpf uses it when generating its pkg-config file
cmd = (
["make", "-j%s" % self.build_opts.num_jobs]
+ self.args
+ ["PREFIX=" + self.inst_dir]
)
self._run_cmd(cmd, env=env)
install_cmd = ["make", "install", "PREFIX=" + self.inst_dir] install_cmd = ["make", "install", "PREFIX=" + self.inst_dir]
self._run_cmd(install_cmd) self._run_cmd(install_cmd, env=env)
class AutoconfBuilder(BuilderBase): class AutoconfBuilder(BuilderBase):
@ -121,11 +129,7 @@ class AutoconfBuilder(BuilderBase):
configure_path = os.path.join(self.src_dir, "configure") configure_path = os.path.join(self.src_dir, "configure")
autogen_path = os.path.join(self.src_dir, "autogen.sh") autogen_path = os.path.join(self.src_dir, "autogen.sh")
env = self.env.copy() env = self._compute_env(install_dirs)
for d in install_dirs:
add_path_entry(env, "PKG_CONFIG_PATH", "%s/lib/pkgconfig" % d)
bindir = os.path.join(d, "bin")
add_path_entry(env, "PATH", bindir, append=False)
if not os.path.exists(configure_path): if not os.path.exists(configure_path):
print("%s doesn't exist, so reconfiguring" % configure_path) print("%s doesn't exist, so reconfiguring" % configure_path)

View File

@ -172,6 +172,10 @@ class BuildOptions(object):
if os.path.exists(pkgconfig): if os.path.exists(pkgconfig):
add_path_entry(env, "PKG_CONFIG_PATH", pkgconfig) add_path_entry(env, "PKG_CONFIG_PATH", pkgconfig)
pkgconfig = os.path.join(d, "lib64/pkgconfig")
if os.path.exists(pkgconfig):
add_path_entry(env, "PKG_CONFIG_PATH", pkgconfig)
# Allow resolving shared objects built earlier (eg: zstd # Allow resolving shared objects built earlier (eg: zstd
# doesn't include the full path to the dylib in its linkage # doesn't include the full path to the dylib in its linkage
# so we need to give it an assist) # so we need to give it an assist)