diff options
Diffstat (limited to 'project2/ice/iceCompile.cpp')
-rw-r--r-- | project2/ice/iceCompile.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/project2/ice/iceCompile.cpp b/project2/ice/iceCompile.cpp index fc7e100..b7d53c1 100644 --- a/project2/ice/iceCompile.cpp +++ b/project2/ice/iceCompile.cpp @@ -39,22 +39,26 @@ DECLARE_OPTIONS(IceCompile, "ICE Compile Options") END_OPTIONS(IceCompile); IceCompile::IceCompile(const boost::filesystem::path & s) : - slice(s) + slice(s), + components(0) { } IceCompile::IceCompile(const boost::filesystem::path & s, const Deps & d) : slice(s), + components(0), deps(d) { } -IceCompile::~IceCompile() +void +IceCompile::countComponents(const fs::path & in) { + components = Count(in); } void -IceCompile::Update(int steps) const +IceCompile::Update(int steps) { fs::create_directories(IceCompile::tmpdir); BOOST_FOREACH(const auto & dep, deps) { @@ -62,7 +66,7 @@ IceCompile::Update(int steps) const } const fs::path cpp(tmpdir / OutputName(".cpp")); if (steps & UpdateBuild) - update(InputPath(), cpp, &IceCompile::Build); + update(InputPath(), cpp, &IceCompile::BuildInteral, &IceCompile::countComponents); const fs::path o(tmpdir / OutputName(".o")); if (steps & UpdateCompile) update(cpp, o, &IceCompile::Compile); @@ -72,20 +76,31 @@ IceCompile::Update(int steps) const } void -IceCompile::update(const fs::path & in, const fs::path & out, UpdateFunc func) const +IceCompile::update(const fs::path & in, const fs::path & out, UpdateFunc update, CountFunc count) { if (!fs::exists(out) || std::max(fs::last_write_time(in), fs::last_write_time("/proc/self/exe")) > fs::last_write_time(out)) { Logger()->messagebf(LOG_DEBUG, "updating %s from %s", out, in); - (this->*func)(in, out); + (this->*update)(in, out); } else { Logger()->messagebf(LOG_DEBUG, "%s already up to date", out); + if (count) { + (this->*count)(in); + } } } void -IceCompile::Compile(const fs::path & in, const fs::path & out) const +IceCompile::BuildInteral(const fs::path & in, const fs::path & out) { + components = Build(in, out); +} + +void +IceCompile::Compile(const fs::path & in, const fs::path & out) +{ + if (components == 0) return; + const auto compile = stringbf( "%s %s -o %s -x c++ -c -I %s -I %s -I ../libmisc/ -I %s -I %s -I %s -I %s -I %s `pkg-config --cflags glibmm-2.4` %s", cxx, cxxopts, out, tmpdir, @@ -103,8 +118,10 @@ IceCompile::Compile(const fs::path & in, const fs::path & out) const } void -IceCompile::Link(const fs::path & in, const fs::path & out) const +IceCompile::Link(const fs::path & in, const fs::path & out) { + if (components == 0) return; + auto link = stringbf("%s %s -o %s -shared %s", linker, linkeropts, out, in); Logger()->messagebf(LOG_DEBUG, "link command: %s", link); if (system(link.c_str())) { @@ -126,6 +143,8 @@ IceCompile::Open() const IceCompile::LibHandle IceCompile::OpenLib() const { + if (components == 0) return LibHandle(); + void * handle = dlopen((IceCompile::tmpdir / OutputName(".so")).string().c_str(), RTLD_GLOBAL | RTLD_NOW); if (!handle) { std::string msg(dlerror()); |