From 0ed26123e367945c740c46be27f800e27a750b20 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 4 Dec 2014 00:07:24 +0000 Subject: Load compiled libraries individually --- project2/ice/iceBase.cpp | 2 +- project2/ice/iceBase.h | 2 +- project2/ice/iceCompile.cpp | 16 ++++++++++++---- project2/ice/iceCompile.h | 5 ++++- project2/ice/iceDaemon.h | 4 ---- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/project2/ice/iceBase.cpp b/project2/ice/iceBase.cpp index 0171f1b..ce50782 100644 --- a/project2/ice/iceBase.cpp +++ b/project2/ice/iceBase.cpp @@ -25,7 +25,7 @@ class WaitAndLoad : public boost::static_visitor<> { lib = boost::get<0>(th)->Open(); } - void operator()(IceCompile::LibHandle) const + void operator()(IceCompile::LibHandles) const { } diff --git a/project2/ice/iceBase.h b/project2/ice/iceBase.h index 06d8994..1d45346 100644 --- a/project2/ice/iceBase.h +++ b/project2/ice/iceBase.h @@ -9,7 +9,7 @@ class IceBase { public: typedef boost::tuple LibCompile; - typedef boost::variant LibPromise; + typedef boost::variant LibPromise; typedef std::vector Libs; typedef boost::function GetComponentCompiler; diff --git a/project2/ice/iceCompile.cpp b/project2/ice/iceCompile.cpp index 74b0b45..fc7e100 100644 --- a/project2/ice/iceCompile.cpp +++ b/project2/ice/iceCompile.cpp @@ -106,17 +106,25 @@ void IceCompile::Link(const fs::path & in, const fs::path & out) const { auto link = stringbf("%s %s -o %s -shared %s", linker, linkeropts, out, in); - BOOST_FOREACH(const auto & dep, deps) { - link += " " + (tmpdir / dep->OutputName(".so")).string(); - } Logger()->messagebf(LOG_DEBUG, "link command: %s", link); if (system(link.c_str())) { throw std::runtime_error("link failed"); } } -IceCompile::LibHandle +IceCompile::LibHandles IceCompile::Open() const +{ + LibHandles rtn; + BOOST_FOREACH(const auto & dep, deps) { + rtn.insert(dep->OpenLib()); + } + rtn.insert(OpenLib()); + return rtn; +} + +IceCompile::LibHandle +IceCompile::OpenLib() const { void * handle = dlopen((IceCompile::tmpdir / OutputName(".so")).string().c_str(), RTLD_GLOBAL | RTLD_NOW); if (!handle) { diff --git a/project2/ice/iceCompile.h b/project2/ice/iceCompile.h index 5e6873a..a66b1d7 100644 --- a/project2/ice/iceCompile.h +++ b/project2/ice/iceCompile.h @@ -3,6 +3,7 @@ #include "options.h" #include +#include #include #include @@ -41,7 +42,8 @@ class IceCompile { virtual boost::filesystem::path OutputName(const std::string & type) const = 0; typedef boost::shared_ptr LibHandle; - LibHandle Open() const; + typedef std::set LibHandles; + LibHandles Open() const; protected: virtual void Build(const boost::filesystem::path & in, const boost::filesystem::path & out) const = 0; @@ -54,6 +56,7 @@ class IceCompile { const boost::filesystem::path slice; private: + LibHandle OpenLib() const; const Deps deps; }; diff --git a/project2/ice/iceDaemon.h b/project2/ice/iceDaemon.h index 623da11..1ec9d11 100644 --- a/project2/ice/iceDaemon.h +++ b/project2/ice/iceDaemon.h @@ -7,10 +7,6 @@ class IceDaemon : public Daemon, IceBase { public: - typedef boost::tuple LibCompile; - typedef boost::variant LibPromise; - typedef std::vector Libs; - IceDaemon(int & argc, char ** argv); virtual ~IceDaemon(); -- cgit v1.2.3