in build/fbcode_builder/getdeps/buildopts.py [0:0]
def compute_env_for_install_dirs(self, install_dirs, env=None, manifest=None):
if env is not None:
env = env.copy()
else:
env = Env()
env["GETDEPS_BUILD_DIR"] = os.path.join(self.scratch_dir, "build")
env["GETDEPS_INSTALL_DIR"] = self.install_dir
# On macOS we need to set `SDKROOT` when we use clang for system
# header files.
if self.is_darwin() and "SDKROOT" not in env:
sdkroot = subprocess.check_output(["xcrun", "--show-sdk-path"])
env["SDKROOT"] = sdkroot.decode().strip()
if self.fbsource_dir:
env["YARN_YARN_OFFLINE_MIRROR"] = os.path.join(
self.fbsource_dir, "xplat/third-party/yarn/offline-mirror"
)
yarn_exe = "yarn.bat" if self.is_windows() else "yarn"
env["YARN_PATH"] = os.path.join(
self.fbsource_dir, "xplat/third-party/yarn/", yarn_exe
)
node_exe = "node-win-x64.exe" if self.is_windows() else "node"
env["NODE_BIN"] = os.path.join(
self.fbsource_dir, "xplat/third-party/node/bin/", node_exe
)
env["RUST_VENDORED_CRATES_DIR"] = os.path.join(
self.fbsource_dir, "third-party/rust/vendor"
)
hash_data = get_fbsource_repo_data(self)
env["FBSOURCE_HASH"] = hash_data.hash
env["FBSOURCE_DATE"] = hash_data.date
lib_path = None
if self.is_darwin():
lib_path = "DYLD_LIBRARY_PATH"
elif self.is_linux():
lib_path = "LD_LIBRARY_PATH"
elif self.is_windows():
lib_path = "PATH"
else:
lib_path = None
for d in install_dirs:
bindir = os.path.join(d, "bin")
pkgconfig = os.path.join(d, "lib/pkgconfig")
if os.path.exists(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)
add_path_entry(env, "CMAKE_PREFIX_PATH", d)
# 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
if os.path.exists(bindir):
add_path_entry(env, "PATH", bindir, append=False)
# If rustc is present in the `bin` directory, set RUSTC to prevent
# cargo uses the rustc installed in the system.
if self.is_windows():
cargo_path = os.path.join(bindir, "cargo.exe")
rustc_path = os.path.join(bindir, "rustc.exe")
rustdoc_path = os.path.join(bindir, "rustdoc.exe")
else:
cargo_path = os.path.join(bindir, "cargo")
rustc_path = os.path.join(bindir, "rustc")
rustdoc_path = os.path.join(bindir, "rustdoc")
if os.path.isfile(rustc_path):
env["CARGO_BIN"] = cargo_path
env["RUSTC"] = rustc_path
env["RUSTDOC"] = rustdoc_path
openssl_include = os.path.join(d, "include/openssl")
if os.path.isdir(openssl_include) and any(
os.path.isfile(os.path.join(d, "lib", libcrypto))
for libcrypto in ("libcrypto.lib", "libcrypto.so", "libcrypto.a")
):
# This must be the openssl library, let Rust know about it
env["OPENSSL_DIR"] = d
# And let openssl know to pick up the system certs if present
for system_ssl_cfg in ["/etc/pki/tls", "/etc/ssl"]:
if os.path.isdir(system_ssl_cfg):
cert_dir = system_ssl_cfg + "/certs"
if os.path.isdir(cert_dir):
env["SSL_CERT_DIR"] = cert_dir
cert_file = system_ssl_cfg + "/cert.pem"
if os.path.isfile(cert_file):
env["SSL_CERT_FILE"] = cert_file
return env