5 #ifndef _DDS_ENVIRONMENT_H_ 6 #define _DDS_ENVIRONMENT_H_ 9 #include "BuildConstants.h" 12 #include <boost/algorithm/string.hpp> 13 #include <boost/filesystem.hpp> 19 inline std::string
getEnv(
const std::string& _key)
21 auto value{ std::getenv(_key.c_str()) };
22 return (value !=
nullptr) ? std::string(value) : std::string();
26 const std::string& _varName,
27 const std::string& _dirName,
28 const std::string& _defaultDir)
30 namespace fs = boost::filesystem;
31 const fs::path locationPath(_location);
32 const std::string install{ (locationPath / fs::path(_dirName)).
string() };
35 if (path == install || boost::starts_with(path, install + std::string(
":")))
37 LOG(
info) <<
"DDS " << std::quoted(_dirName) <<
" directory (" << std::quoted(install)
38 <<
") already prepends $" << _varName <<
" (" << std::quoted(path) <<
")";
42 const std::string ddsInstall{ _location == kDDSInstallPrefix ? _defaultDir : install };
43 path = (path.empty()) ? ddsInstall : ddsInstall + std::string(
":") + path;
44 setenv(_varName.c_str(), path.c_str(), 1);
45 LOG(
info) <<
"Set $" << _varName <<
" to " << std::quoted(path);
54 setenv(
"LC_ALL",
"C", 1);
66 if (location != kDDSInstallPrefix)
70 location = kDDSInstallPrefix;
71 setenv(
"DDS_LOCATION", location.c_str(), 1);
72 LOG(
info) <<
"Set $DDS_LOCATION to " << std::quoted(location);
76 LOG(
info) <<
"$DDS_LOCATION (" << std::quoted(location) <<
") differs from the linked one (" 77 << std::quoted(kDDSInstallPrefix) <<
")";
85 const std::string ldVar =
"DYLD_LIBRARY_PATH";
87 const std::string ldVar =
"LD_LIBRARY_PATH";
#define LOG(severity)
Definition: Logger.h:34
void setupEnv()
Definition: Environment.h:59
std::string getEnv(const std::string &_key)
Definition: Environment.h:19
void setupEnvVar(const std::string &_location, const std::string &_varName, const std::string &_dirName, const std::string &_defaultDir)
Definition: Environment.h:25
void setupLocale()
Definition: Environment.h:49
Definition: BoostHelper.h:14