mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 16:46:47 +00:00
SDK: Let DDSEnvironment manage $LD_LIBRARY_PATH
* Remove configurable install prefix * Add singleton
This commit is contained in:
parent
5a7bf68c8c
commit
152c8431c6
|
@ -20,16 +20,24 @@ namespace mq {
|
||||||
namespace sdk {
|
namespace sdk {
|
||||||
|
|
||||||
// TODO https://github.com/FairRootGroup/DDS/issues/224
|
// TODO https://github.com/FairRootGroup/DDS/issues/224
|
||||||
auto LoadDDSEnv(const boost::filesystem::path& config_home, const boost::filesystem::path& prefix)
|
auto LoadDDSEnv(const boost::filesystem::path& config_home)
|
||||||
-> void
|
-> void
|
||||||
{
|
{
|
||||||
setenv("DDS_LOCATION", prefix.c_str(), 1);
|
setenv("DDS_LOCATION", DDSInstallPrefix.c_str(), 1);
|
||||||
if (!config_home.empty()) {
|
if (!config_home.empty()) {
|
||||||
setenv("HOME", config_home.c_str(), 1);
|
setenv("HOME", config_home.c_str(), 1);
|
||||||
}
|
}
|
||||||
std::string path(std::getenv("PATH"));
|
std::string path(std::getenv("PATH"));
|
||||||
path = DDSExecutableDir + std::string(":") + path;
|
path = DDSExecutableDir + std::string(":") + path;
|
||||||
setenv("PATH", path.c_str(), 1);
|
setenv("PATH", path.c_str(), 1);
|
||||||
|
|
||||||
|
#ifndef __APPLE__
|
||||||
|
std::string ldVar("LD_LIBRARY_PATH");
|
||||||
|
std::string ld(std::getenv(ldVar.c_str()));
|
||||||
|
ld = DDSLibraryDir + std::string(":") + ld;
|
||||||
|
setenv(ldVar.c_str(), ld.c_str(), 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
std::istringstream cmd;
|
std::istringstream cmd;
|
||||||
cmd.str("DDS_CFG=`dds-user-defaults --ignore-default-sid -p`\n"
|
cmd.str("DDS_CFG=`dds-user-defaults --ignore-default-sid -p`\n"
|
||||||
"if [ -z \"$DDS_CFG\" ]; then\n"
|
"if [ -z \"$DDS_CFG\" ]; then\n"
|
||||||
|
@ -41,31 +49,32 @@ auto LoadDDSEnv(const boost::filesystem::path& config_home, const boost::filesys
|
||||||
|
|
||||||
struct DDSEnvironment::Impl
|
struct DDSEnvironment::Impl
|
||||||
{
|
{
|
||||||
Impl(Path config_home, Path prefix)
|
explicit Impl(Path config_home)
|
||||||
: fConfigHome(std::move(config_home))
|
: fCount()
|
||||||
, fInstallPrefix(std::move(prefix))
|
, fConfigHome(std::move(config_home))
|
||||||
{
|
{
|
||||||
LoadDDSEnv(fConfigHome, fInstallPrefix);
|
LoadDDSEnv(fConfigHome);
|
||||||
if (fConfigHome.empty()) {
|
if (fConfigHome.empty()) {
|
||||||
fConfigHome = std::getenv("HOME");
|
fConfigHome = std::getenv("HOME");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Tag {};
|
||||||
|
friend auto operator<<(std::ostream& os, Tag) -> std::ostream& { return os << "DDSEnvironment"; }
|
||||||
|
tools::InstanceLimiter<Tag, 1> fCount;
|
||||||
|
|
||||||
Path fConfigHome;
|
Path fConfigHome;
|
||||||
Path fInstallPrefix;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DDSEnvironment::DDSEnvironment(Path config_home, Path prefix)
|
DDSEnvironment::DDSEnvironment(Path config_home)
|
||||||
: fImpl(std::make_shared<Impl>(std::move(config_home), std::move(prefix)))
|
: fImpl(std::make_shared<Impl>(std::move(config_home)))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
auto DDSEnvironment::GetConfigHome() const -> Path { return fImpl->fConfigHome; }
|
auto DDSEnvironment::GetConfigHome() const -> Path { return fImpl->fConfigHome; }
|
||||||
|
|
||||||
auto DDSEnvironment::GetInstallPrefix() const -> Path { return fImpl->fInstallPrefix; }
|
|
||||||
|
|
||||||
auto operator<<(std::ostream& os, DDSEnvironment env) -> std::ostream&
|
auto operator<<(std::ostream& os, DDSEnvironment env) -> std::ostream&
|
||||||
{
|
{
|
||||||
return os << "$DDS_LOCATION: " << env.GetInstallPrefix() << ", "
|
return os << "$DDS_LOCATION: " << DDSInstallPrefix << ", "
|
||||||
<< "$DDS_CONFIG_HOME: " << env.GetConfigHome() / DDSEnvironment::Path(".DDS");
|
<< "$DDS_CONFIG_HOME: " << env.GetConfigHome() / DDSEnvironment::Path(".DDS");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,14 +18,6 @@ namespace fair {
|
||||||
namespace mq {
|
namespace mq {
|
||||||
namespace sdk {
|
namespace sdk {
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Sets up the DDS environment
|
|
||||||
* @param config_home Path under which DDS creates a ".DDS" runtime directory for configuration and logs
|
|
||||||
* @param prefix Path where DDS is installed
|
|
||||||
*/
|
|
||||||
auto LoadDDSEnv(const boost::filesystem::path& config_home = "", const boost::filesystem::path& prefix = DDSInstallPrefix)
|
|
||||||
-> void;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class DDSEnvironment DDSSession.h <fairmq/sdk/DDSSession.h>
|
* @class DDSEnvironment DDSSession.h <fairmq/sdk/DDSSession.h>
|
||||||
* @brief Sets up the DDS environment (object helper)
|
* @brief Sets up the DDS environment (object helper)
|
||||||
|
@ -36,10 +28,9 @@ class DDSEnvironment
|
||||||
using Path = boost::filesystem::path;
|
using Path = boost::filesystem::path;
|
||||||
|
|
||||||
/// @brief See fair::mq::sdk::LoadDDSEnv
|
/// @brief See fair::mq::sdk::LoadDDSEnv
|
||||||
explicit DDSEnvironment(Path config_home = "", Path prefix = DDSInstallPrefix);
|
explicit DDSEnvironment(Path config_home = "");
|
||||||
|
|
||||||
auto GetConfigHome() const -> Path;
|
auto GetConfigHome() const -> Path;
|
||||||
auto GetInstallPrefix() const -> Path;
|
|
||||||
|
|
||||||
friend auto operator<<(std::ostream& os, DDSEnvironment env) -> std::ostream&;
|
friend auto operator<<(std::ostream& os, DDSEnvironment env) -> std::ostream&;
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user