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

getdeps: move the guts of _compute_env to a helper in buildopts

Summary: I want to use this logic outside of a builder implementation

Reviewed By: pkaush

Differential Revision: D16101914

fbshipit-source-id: db3c9ac6c84a92ab84a18dddb931953b0a51f127
This commit is contained in:
Wez Furlong
2019-07-03 16:18:27 -07:00
committed by Facebook Github Bot
parent cd21fdafd2
commit ecc5dd6d71
2 changed files with 40 additions and 34 deletions

View File

@@ -86,39 +86,7 @@ class BuilderBase(object):
def _compute_env(self, install_dirs):
# CMAKE_PREFIX_PATH is only respected when passed through the
# environment, so we construct an appropriate path to pass down
env = self.env.copy()
lib_path = None
if self.build_opts.is_darwin():
lib_path = "DYLD_LIBRARY_PATH"
elif self.build_opts.is_linux():
lib_path = "LD_LIBRARY_PATH"
else:
lib_path = None
for d in install_dirs:
add_path_entry(env, "CMAKE_PREFIX_PATH", d)
pkgconfig = os.path.join(d, "lib/pkgconfig")
if os.path.exists(pkgconfig):
add_path_entry(env, "PKG_CONFIG_PATH", pkgconfig)
# Allow resolving shared objects built earlier (eg: zstd
# doesn't include the full path to the dylib in its linkage
# so we need to give it an assist)
if lib_path:
for lib in ["lib", "lib64"]:
libdir = os.path.join(d, lib)
if os.path.exists(libdir):
add_path_entry(env, lib_path, libdir)
# Allow resolving binaries (eg: cmake, ninja) and dlls
# built by earlier steps
bindir = os.path.join(d, "bin")
if os.path.exists(bindir):
add_path_entry(env, "PATH", bindir, append=False)
return env
return self.build_opts.compute_env_for_install_dirs(install_dirs, env=self.env)
class MakeBuilder(BuilderBase):

View File

@@ -16,7 +16,7 @@ import os
import subprocess
import tempfile
from .envfuncs import path_search
from .envfuncs import Env, add_path_entry, path_search
from .platform import HostType, is_windows
@@ -190,6 +190,44 @@ class BuildOptions(object):
return {"build_dir": build_dir, "inst_dir": inst_dir, "hash": hash}
def compute_env_for_install_dirs(self, install_dirs, env=None):
if env:
env = env.copy()
else:
env = Env()
lib_path = None
if self.is_darwin():
lib_path = "DYLD_LIBRARY_PATH"
elif self.is_linux():
lib_path = "LD_LIBRARY_PATH"
else:
lib_path = None
for d in install_dirs:
add_path_entry(env, "CMAKE_PREFIX_PATH", d)
pkgconfig = os.path.join(d, "lib/pkgconfig")
if os.path.exists(pkgconfig):
add_path_entry(env, "PKG_CONFIG_PATH", pkgconfig)
# Allow resolving shared objects built earlier (eg: zstd
# doesn't include the full path to the dylib in its linkage
# so we need to give it an assist)
if lib_path:
for lib in ["lib", "lib64"]:
libdir = os.path.join(d, lib)
if os.path.exists(libdir):
add_path_entry(env, lib_path, libdir)
# Allow resolving binaries (eg: cmake, ninja) and dlls
# built by earlier steps
bindir = os.path.join(d, "bin")
if os.path.exists(bindir):
add_path_entry(env, "PATH", bindir, append=False)
return env
def list_win32_subst_letters():
output = subprocess.check_output(["subst"]).decode("utf-8")