summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--project2/ice/buildClient.cpp4
-rw-r--r--project2/ice/buildClient.h2
-rw-r--r--project2/ice/buildComms.cpp36
-rw-r--r--project2/ice/buildComms.h6
-rw-r--r--project2/ice/buildDaemon.cpp4
-rw-r--r--project2/ice/buildDaemon.h2
-rw-r--r--project2/ice/iceBase.cpp6
-rw-r--r--project2/ice/iceBase.h4
-rw-r--r--project2/ice/iceCompile.cpp35
-rw-r--r--project2/ice/iceCompile.h20
-rw-r--r--project2/ice/iceDaemon.cpp4
-rw-r--r--project2/ice/iceDaemon.h2
-rw-r--r--project2/ice/iceDataSource.cpp4
-rw-r--r--project2/ice/iceDataSource.h2
-rw-r--r--project2/ice/slice2Common.cpp9
-rw-r--r--project2/ice/slice2Common.h2
-rw-r--r--project2/ice/slice2Daemon.cpp20
-rw-r--r--project2/ice/slice2Daemon.h7
-rw-r--r--project2/ice/slice2Rows.cpp14
-rw-r--r--project2/ice/slice2Task.cpp14
-rw-r--r--project2/ice/sliceCompile.cpp28
-rw-r--r--project2/ice/sliceCompile.h8
-rw-r--r--project2/ice/unittests/testClient.cpp15
-rw-r--r--project2/ice/unittests/testClientCompile.cpp24
-rw-r--r--project2/ice/unittests/testDaemon.cpp8
-rw-r--r--project2/ice/unittests/testDaemonCompile.cpp24
26 files changed, 229 insertions, 75 deletions
diff --git a/project2/ice/buildClient.cpp b/project2/ice/buildClient.cpp
index 676af31..97655c7 100644
--- a/project2/ice/buildClient.cpp
+++ b/project2/ice/buildClient.cpp
@@ -15,13 +15,15 @@ BuildClient::Headers(FILE * out) const
fprintf(out, "#include <iceRows.h>\n");
}
-void
+unsigned int
BuildClient::Body(FILE * out, Slice::UnitPtr u) const
{
Slice2Task taskBuilder(out);
Slice2Rows rowsBuilder(out);
u->visit(&taskBuilder, false);
u->visit(&rowsBuilder, false);
+
+ return taskBuilder.Components() + rowsBuilder.Components();
}
boost::filesystem::path
diff --git a/project2/ice/buildClient.h b/project2/ice/buildClient.h
index a8c0b6c..e16872e 100644
--- a/project2/ice/buildClient.h
+++ b/project2/ice/buildClient.h
@@ -9,7 +9,7 @@ class BuildClient : public SliceCompile {
BuildClient(const boost::filesystem::path & slice, const IceCompile::Deps & dep);
virtual void Headers(FILE *) const;
- virtual void Body(FILE *, Slice::UnitPtr) const;
+ virtual unsigned int Body(FILE *, Slice::UnitPtr) const;
boost::filesystem::path OutputName(const std::string & type) const;
};
diff --git a/project2/ice/buildComms.cpp b/project2/ice/buildComms.cpp
index bdba5e9..3ee548c 100644
--- a/project2/ice/buildComms.cpp
+++ b/project2/ice/buildComms.cpp
@@ -3,16 +3,34 @@
#include <logger.h>
#include <misc.h>
#include <boost/filesystem/operations.hpp>
+#include <slicer/parser.h>
namespace fs = boost::filesystem;
-BuildComms::BuildComms(const boost::filesystem::path & slice, bool ip) :
+BuildComms::BuildComms(const boost::filesystem::path & slice, bool ip, bool sp) :
IceCompile(slice),
- iceParts(ip)
+ iceParts(ip),
+ slicerParts(sp)
{
}
-void
+unsigned int
+BuildComms::Count(const boost::filesystem::path & in) const
+{
+ unsigned int components = 0;
+
+ if (iceParts) {
+ components += 1;
+ }
+
+ if (slicerParts) {
+ components += Slicer::Slicer::Apply(in, NULL);
+ }
+
+ return components;
+}
+
+unsigned int
BuildComms::Build(const boost::filesystem::path & in, const boost::filesystem::path & out) const
{
const auto slicecmd = stringbf("%s --output-dir %s %s", slice2cpp, out.parent_path(), in);
@@ -20,16 +38,20 @@ BuildComms::Build(const boost::filesystem::path & in, const boost::filesystem::p
if (system(slicecmd.c_str())) {
throw std::runtime_error("slice2cpp failed");
}
+ unsigned int components = 0;
if (!iceParts) {
// We always need to the header, but we can truncate the cpp if we don't need the ice bits
boost::filesystem::resize_file(out, 0);
}
+ else {
+ components += 1;
+ }
- const auto slicercmd = stringbf("%s %s %s", slicer, in, out);
- Logger()->messagebf(LOG_DEBUG, "%s: slicer command: %s", __PRETTY_FUNCTION__, slicercmd);
- if (system(slicercmd.c_str())) {
- throw std::runtime_error("slicer failed");
+ if (slicerParts) {
+ components += Slicer::Slicer::Apply(in, out);
}
+
+ return components;
}
boost::filesystem::path
diff --git a/project2/ice/buildComms.h b/project2/ice/buildComms.h
index 116051e..efce380 100644
--- a/project2/ice/buildComms.h
+++ b/project2/ice/buildComms.h
@@ -6,13 +6,15 @@
class BuildComms : public IceCompile {
public:
- BuildComms(const boost::filesystem::path & slice, bool iceParts);
+ BuildComms(const boost::filesystem::path & slice, bool iceParts, bool slicerParts);
- void Build(const boost::filesystem::path & in, const boost::filesystem::path & out) const;
+ unsigned int Build(const boost::filesystem::path & in, const boost::filesystem::path & out) const;
+ unsigned int Count(const boost::filesystem::path & in) const;
boost::filesystem::path InputPath() const;
boost::filesystem::path OutputName(const std::string & type) const;
const bool iceParts;
+ const bool slicerParts;
};
#endif
diff --git a/project2/ice/buildDaemon.cpp b/project2/ice/buildDaemon.cpp
index 674ef21..5bb4cfd 100644
--- a/project2/ice/buildDaemon.cpp
+++ b/project2/ice/buildDaemon.cpp
@@ -13,11 +13,13 @@ BuildDaemon::Headers(FILE * out) const
fprintf(out, "#include <iceModule.h>\n");
}
-void
+unsigned int
BuildDaemon::Body(FILE * out, Slice::UnitPtr u) const
{
Slice2Daemon daemonBuilder(out);
u->visit(&daemonBuilder, false);
+
+ return daemonBuilder.Components();
}
boost::filesystem::path
diff --git a/project2/ice/buildDaemon.h b/project2/ice/buildDaemon.h
index 8c22ea6..b2dd8ca 100644
--- a/project2/ice/buildDaemon.h
+++ b/project2/ice/buildDaemon.h
@@ -9,7 +9,7 @@ class BuildDaemon : public SliceCompile {
BuildDaemon(const boost::filesystem::path & slice, const IceCompile::Deps & dep);
virtual void Headers(FILE *) const;
- virtual void Body(FILE *, Slice::UnitPtr) const;
+ virtual unsigned int Body(FILE *, Slice::UnitPtr) const;
boost::filesystem::path OutputName(const std::string & type) const;
};
diff --git a/project2/ice/iceBase.cpp b/project2/ice/iceBase.cpp
index ce50782..aaabad6 100644
--- a/project2/ice/iceBase.cpp
+++ b/project2/ice/iceBase.cpp
@@ -5,11 +5,9 @@ void
IceBase::SetSlice(Libs & libs, const GetComponentCompiler & gcc, const VariableType & vslice, bool iceParts, bool slicerParts)
{
auto slice = vslice.as<std::string>();
- IceCompile::CPtr bc(new BuildComms(slice, iceParts));
+ IceCompile::Ptr bc(new BuildComms(slice, iceParts, slicerParts));
bc->Update(IceCompile::UpdateBuild);
- IceCompile::CPtr bcl(( !iceParts && !slicerParts ) ?
- gcc(slice, { }) :
- gcc(slice, { bc }));
+ IceCompile::Ptr bcl(gcc(slice, { bc }));
libs.push_back(LibCompile(bcl, new std::thread(&IceCompile::Update, bcl.get(),
IceCompile::UpdateBuild | IceCompile::UpdateCompile | IceCompile::UpdateLink)));
}
diff --git a/project2/ice/iceBase.h b/project2/ice/iceBase.h
index 1d45346..0a59416 100644
--- a/project2/ice/iceBase.h
+++ b/project2/ice/iceBase.h
@@ -8,10 +8,10 @@
class IceBase {
public:
- typedef boost::tuple<IceCompile::CPtr, std::thread *> LibCompile;
+ typedef boost::tuple<IceCompile::Ptr, std::thread *> LibCompile;
typedef boost::variant<LibCompile, IceCompile::LibHandles> LibPromise;
typedef std::vector<LibPromise> Libs;
- typedef boost::function<IceCompile::CPtr(const std::string &, const IceCompile::Deps &)> GetComponentCompiler;
+ typedef boost::function<IceCompile::Ptr(const std::string &, const IceCompile::Deps &)> GetComponentCompiler;
static void FinaliseLoad(Libs & libs);
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());
diff --git a/project2/ice/iceCompile.h b/project2/ice/iceCompile.h
index a66b1d7..3c89f69 100644
--- a/project2/ice/iceCompile.h
+++ b/project2/ice/iceCompile.h
@@ -13,7 +13,7 @@ class IceCompile {
typedef boost::shared_ptr<IceCompile> Ptr;
typedef boost::shared_ptr<const IceCompile> CPtr;
- typedef std::vector<CPtr> Deps;
+ typedef std::vector<Ptr> Deps;
static std::string slice2cpp;
static std::string slicer;
@@ -27,7 +27,6 @@ class IceCompile {
IceCompile(const boost::filesystem::path & slice);
IceCompile(const boost::filesystem::path & slice, const Deps & deps);
- virtual ~IceCompile();
enum Steps {
UpdateBuild = 0x1,
@@ -35,7 +34,7 @@ class IceCompile {
UpdateLink = 0x4,
};
/// Conditionally execute Build, Compile, Link as required
- void Update(int steps = UpdateBuild | UpdateCompile | UpdateLink) const;
+ void Update(int steps = UpdateBuild | UpdateCompile | UpdateLink);
/// Source file path (e.g. /some/path/slice.ice)
virtual boost::filesystem::path InputPath() const = 0;
/// File name (no extension) in temporary directory (e.g. clientSlice)
@@ -46,16 +45,21 @@ class IceCompile {
LibHandles Open() const;
protected:
- virtual void Build(const boost::filesystem::path & in, const boost::filesystem::path & out) const = 0;
- void Compile(const boost::filesystem::path & in, const boost::filesystem::path & out) const;
- void Link(const boost::filesystem::path & in, const boost::filesystem::path & out) const;
+ virtual unsigned int Build(const boost::filesystem::path & in, const boost::filesystem::path & out) const = 0;
+ virtual unsigned int Count(const boost::filesystem::path & in) const = 0;
+ void BuildInteral(const boost::filesystem::path & in, const boost::filesystem::path & out);
+ void Compile(const boost::filesystem::path & in, const boost::filesystem::path & out);
+ void Link(const boost::filesystem::path & in, const boost::filesystem::path & out);
- typedef void (IceCompile::*UpdateFunc)(const boost::filesystem::path & in, const boost::filesystem::path & out) const;
- void update(const boost::filesystem::path & in, const boost::filesystem::path & out, UpdateFunc func) const;
+ typedef void (IceCompile::*UpdateFunc)(const boost::filesystem::path & in, const boost::filesystem::path & out);
+ typedef void (IceCompile::*CountFunc)(const boost::filesystem::path & in);
+ void update(const boost::filesystem::path & in, const boost::filesystem::path & out, UpdateFunc func, CountFunc count = NULL);
const boost::filesystem::path slice;
private:
+ void countComponents(const boost::filesystem::path & in);
+ unsigned int components;
LibHandle OpenLib() const;
const Deps deps;
};
diff --git a/project2/ice/iceDaemon.cpp b/project2/ice/iceDaemon.cpp
index 2dae17e..d09f85e 100644
--- a/project2/ice/iceDaemon.cpp
+++ b/project2/ice/iceDaemon.cpp
@@ -169,10 +169,10 @@ IceDaemon::executeTask(const std::string & name, const ParamMap & pm) const
t->executeTask(&icc);
}
-IceCompile::CPtr
+IceCompile::Ptr
IceDaemon::GetComponentCompiler(const std::string & slice, const IceCompile::Deps & deps)
{
- return IceCompile::CPtr(new BuildDaemon(slice, deps));
+ return IceCompile::Ptr(new BuildDaemon(slice, deps));
}
void
diff --git a/project2/ice/iceDaemon.h b/project2/ice/iceDaemon.h
index 1ec9d11..3164699 100644
--- a/project2/ice/iceDaemon.h
+++ b/project2/ice/iceDaemon.h
@@ -23,7 +23,7 @@ class IceDaemon : public Daemon, IceBase {
static std::string taskRoot;
static Libs libs;
- static IceCompile::CPtr GetComponentCompiler(const std::string & slice, const IceCompile::Deps &);
+ static IceCompile::Ptr GetComponentCompiler(const std::string & slice, const IceCompile::Deps &);
private:
Ice::CommunicatorPtr ic;
diff --git a/project2/ice/iceDataSource.cpp b/project2/ice/iceDataSource.cpp
index 1b0c9e8..5f2004c 100644
--- a/project2/ice/iceDataSource.cpp
+++ b/project2/ice/iceDataSource.cpp
@@ -25,10 +25,10 @@ IceDataSource::IceDataSource(ScriptNodePtr p) :
Logger()->messagebf(LOG_DEBUG, "%s: endpoint: %s", __PRETTY_FUNCTION__, endpoint(NULL));
}
-IceCompile::CPtr
+IceCompile::Ptr
IceDataSource::GetComponentCompiler(const std::string & slice, const IceCompile::Deps & deps)
{
- return IceCompile::CPtr(new BuildClient(slice, deps));
+ return IceCompile::Ptr(new BuildClient(slice, deps));
}
void
diff --git a/project2/ice/iceDataSource.h b/project2/ice/iceDataSource.h
index 4bea344..fa0c92a 100644
--- a/project2/ice/iceDataSource.h
+++ b/project2/ice/iceDataSource.h
@@ -26,7 +26,7 @@ class IceDataSource : public DataSource, IceBase {
}
const Ice::CommunicatorPtr GetCommunicator() const { return ic; }
- static IceCompile::CPtr GetComponentCompiler(const std::string & slice, const IceCompile::Deps &);
+ static IceCompile::Ptr GetComponentCompiler(const std::string & slice, const IceCompile::Deps &);
static void ClearSlice();
static Libs libs;
diff --git a/project2/ice/slice2Common.cpp b/project2/ice/slice2Common.cpp
index 1b5f9ee..5886d07 100644
--- a/project2/ice/slice2Common.cpp
+++ b/project2/ice/slice2Common.cpp
@@ -3,10 +3,17 @@
#include <boost/foreach.hpp>
Slice2Common::Slice2Common(FILE * c) :
- code(c)
+ code(c),
+ components(0)
{
}
+unsigned int
+Slice2Common::Components() const
+{
+ return components;
+}
+
void
Slice2Common::FunctionBegin(Slice::OperationPtr o)
{
diff --git a/project2/ice/slice2Common.h b/project2/ice/slice2Common.h
index bb4719b..170f0e7 100644
--- a/project2/ice/slice2Common.h
+++ b/project2/ice/slice2Common.h
@@ -11,9 +11,11 @@ class Slice2Common : public Slice::ParserVisitor {
void ParameterVariables(Slice::OperationPtr o);
void Declaration(Slice::OperationPtr o);
void CallOperation(Slice::OperationPtr o);
+ unsigned int Components() const;
protected:
FILE * code;
+ unsigned int components;
std::string interface;
std::string module;
diff --git a/project2/ice/slice2Daemon.cpp b/project2/ice/slice2Daemon.cpp
index 73da741..05be959 100644
--- a/project2/ice/slice2Daemon.cpp
+++ b/project2/ice/slice2Daemon.cpp
@@ -4,7 +4,7 @@
#include <Slice/CPlusPlusUtil.h>
Slice2Daemon::Slice2Daemon(FILE * c) :
- code(c)
+ Slice2Common(c)
{
}
@@ -22,6 +22,9 @@ Slice2Daemon::visitClassDefStart(const Slice::ClassDefPtr & c)
if (c->operations().empty()) return false;
interface = c->name();
+
+ if (!code) return true;
+
fprintf(code, "\tclass %sImpl : public IceDaemonModule, public %s {\n", c->name().c_str(), c->name().c_str());
fprintf(code, "\t\tpublic:\n");
fprintf(code, "\t\t\t%sImpl(const IceDaemon * id) :\n", c->name().c_str());
@@ -33,6 +36,8 @@ Slice2Daemon::visitClassDefStart(const Slice::ClassDefPtr & c)
void
Slice2Daemon::visitOperation(const Slice::OperationPtr & o)
{
+ if (!code) return;
+
if (o->returnType()) {
fprintf(code, "\t\t\t%s %s(", returnTypeToString(o->returnType(), o->returnIsOptional()).c_str(), o->name().c_str());
}
@@ -59,20 +64,27 @@ Slice2Daemon::visitOperation(const Slice::OperationPtr & o)
void
Slice2Daemon::visitClassDefEnd(const Slice::ClassDefPtr & c)
{
- fprintf(code, "\t}; // class %sImpl\n\n", c->name().c_str());
- fprintf(code, "\tDECLARE_GENERIC_LOADER(\"%s-%s\", IceDaemonAdapterHandlerLoader, %sImpl);\n\n",
- module.c_str(), c->name().c_str(), c->name().c_str());
+ if (code) {
+ fprintf(code, "\t}; // class %sImpl\n\n", c->name().c_str());
+ fprintf(code, "\tDECLARE_GENERIC_LOADER(\"%s-%s\", IceDaemonAdapterHandlerLoader, %sImpl);\n\n",
+ module.c_str(), c->name().c_str(), c->name().c_str());
+ }
+ components += 1;
}
void
Slice2Daemon::visitModuleEnd(const Slice::ModulePtr & m)
{
+ if (!code) return;
+
fprintf(code, "}; // namespace %s\n\n", m->name().c_str());
}
void
Slice2Daemon::visitParameterMap(const Slice::OperationPtr & o)
{
+ if (!code) return;
+
fprintf(code, "\t\t\t\tParamMap params {\n");
BOOST_FOREACH(const auto & p, o->parameters()) {
Slice::StructPtr s = dynamic_cast<Slice::Struct *>(p->type().get());
diff --git a/project2/ice/slice2Daemon.h b/project2/ice/slice2Daemon.h
index 4487f9b..2cb5782 100644
--- a/project2/ice/slice2Daemon.h
+++ b/project2/ice/slice2Daemon.h
@@ -1,9 +1,9 @@
#ifndef ICEBUILDDAEMON_H
#define ICEBUILDDAEMON_H
-#include <Slice/Parser.h>
+#include "slice2Common.h"
-class Slice2Daemon : public Slice::ParserVisitor {
+class Slice2Daemon : public Slice2Common {
public:
Slice2Daemon(FILE * c);
@@ -15,9 +15,6 @@ class Slice2Daemon : public Slice::ParserVisitor {
private:
void visitParameterMap(const Slice::OperationPtr & o);
- FILE * code;
- std::string interface;
- std::string module;
};
#endif
diff --git a/project2/ice/slice2Rows.cpp b/project2/ice/slice2Rows.cpp
index 10d319e..2f1c6f2 100644
--- a/project2/ice/slice2Rows.cpp
+++ b/project2/ice/slice2Rows.cpp
@@ -12,6 +12,9 @@ bool
Slice2Rows::visitModuleStart(const Slice::ModulePtr & m)
{
module = m->name();
+
+ if (!code) return true;
+
fprintf(code, "namespace IceRowsWrappers {\n");
fprintf(code, "\tnamespace %s {\n", m->name().c_str());
return true;
@@ -23,6 +26,9 @@ Slice2Rows::visitClassDefStart(const Slice::ClassDefPtr & c)
if (c->operations().empty()) return false;
interface = c->name();
+
+ if (!code) return true;
+
fprintf(code, "\t\tnamespace %s {\n", c->name().c_str());
return true;
}
@@ -31,6 +37,10 @@ void
Slice2Rows::visitOperation(const Slice::OperationPtr & o)
{
if (o->hasMetaData("project2:rows")) {
+ components += 1;
+
+ if (!code) return;
+
fprintf(code, "\t\t\tclass %s : public IceRows< ::%s::%sPrx > {\n", o->name().c_str(), module.c_str(), interface.c_str());
fprintf(code, "\t\t\t\tpublic:\n");
// Constructor
@@ -61,12 +71,16 @@ Slice2Rows::visitOperation(const Slice::OperationPtr & o)
void
Slice2Rows::visitClassDefEnd(const Slice::ClassDefPtr & c)
{
+ if (!code) return;
+
fprintf(code, "\t\t} // namespace %s\n\n", c->name().c_str());
}
void
Slice2Rows::visitModuleEnd(const Slice::ModulePtr & m)
{
+ if (!code) return;
+
fprintf(code, "\t}; // namespace %s\n", m->name().c_str());
fprintf(code, "}; // namespace IceRowsWrappers\n\n");
}
diff --git a/project2/ice/slice2Task.cpp b/project2/ice/slice2Task.cpp
index 16be9e0..fa60bd0 100644
--- a/project2/ice/slice2Task.cpp
+++ b/project2/ice/slice2Task.cpp
@@ -12,6 +12,9 @@ bool
Slice2Task::visitModuleStart(const Slice::ModulePtr & m)
{
module = m->name();
+
+ if (!code) return true;
+
fprintf(code, "namespace IceTaskWrappers {\n");
fprintf(code, "\tnamespace %s {\n", m->name().c_str());
return true;
@@ -23,6 +26,9 @@ Slice2Task::visitClassDefStart(const Slice::ClassDefPtr & c)
if (c->operations().empty()) return false;
interface = c->name();
+
+ if (!code) return true;
+
fprintf(code, "\t\tnamespace %s {\n", c->name().c_str());
return true;
}
@@ -31,6 +37,10 @@ void
Slice2Task::visitOperation(const Slice::OperationPtr & o)
{
if (o->hasMetaData("project2:task")) {
+ components += 1;
+
+ if (!code) return;
+
fprintf(code, "\t\t\tclass %s : public IceTask< ::%s::%sPrx > {\n", o->name().c_str(), module.c_str(), interface.c_str());
fprintf(code, "\t\t\t\tpublic:\n");
// Constructor
@@ -59,12 +69,16 @@ Slice2Task::visitOperation(const Slice::OperationPtr & o)
void
Slice2Task::visitClassDefEnd(const Slice::ClassDefPtr & c)
{
+ if (!code) return;
+
fprintf(code, "\t\t} // namespace %s\n\n", c->name().c_str());
}
void
Slice2Task::visitModuleEnd(const Slice::ModulePtr & m)
{
+ if (!code) return;
+
fprintf(code, "\t}; // namespace %s\n", m->name().c_str());
fprintf(code, "}; // namespace IceTaskWrappers\n\n");
}
diff --git a/project2/ice/sliceCompile.cpp b/project2/ice/sliceCompile.cpp
index f98ecde..32831ac 100644
--- a/project2/ice/sliceCompile.cpp
+++ b/project2/ice/sliceCompile.cpp
@@ -7,8 +7,8 @@ SliceCompile::SliceCompile(const boost::filesystem::path & slice, const IceCompi
{
}
-void
-SliceCompile::Build(const boost::filesystem::path & in, const boost::filesystem::path & outpath) const
+unsigned int
+SliceCompile::build(const boost::filesystem::path & in, FILE * out) const
{
std::vector<std::string> cppArgs;
Slice::PreprocessorPtr icecpp = Slice::Preprocessor::create("slice2project2", in.string(), cppArgs);
@@ -31,19 +31,35 @@ SliceCompile::Build(const boost::filesystem::path & in, const boost::filesystem:
throw std::runtime_error("unit parse failed");
}
+ if (out) {
+ fprintf(out, "#include <%s>\n", (in.filename().replace_extension(".h")).string().c_str());
+ Headers(out);
+ fprintf(out, "\n");
+ }
+ return Body(out, u);
+}
+
+unsigned int
+SliceCompile::Build(const boost::filesystem::path & in, const boost::filesystem::path & outpath) const
+{
FILE * out = fopen(outpath.string().c_str(), "w");
if (!out) {
throw std::runtime_error("failed to open target");
}
- fprintf(out, "#include <%s>\n", (in.filename().replace_extension(".h")).string().c_str());
- Headers(out);
- fprintf(out, "\n");
- Body(out, u);
+ auto components = build(in, out);
if (fclose(out)) {
throw std::runtime_error("failed to close target");
}
+
+ return components;
+}
+
+unsigned int
+SliceCompile::Count(const boost::filesystem::path & in) const
+{
+ return build(in, NULL);
}
void
diff --git a/project2/ice/sliceCompile.h b/project2/ice/sliceCompile.h
index 5f11c88..d8e8e32 100644
--- a/project2/ice/sliceCompile.h
+++ b/project2/ice/sliceCompile.h
@@ -10,11 +10,15 @@ class SliceCompile : public IceCompile {
public:
SliceCompile(const boost::filesystem::path & slice, const IceCompile::Deps & dep);
- void Build(const boost::filesystem::path & in, const boost::filesystem::path & out) const;
+ unsigned int Count(const boost::filesystem::path & in) const;
+ unsigned int Build(const boost::filesystem::path & in, const boost::filesystem::path & out) const;
virtual void Headers(FILE *) const;
- virtual void Body(FILE *, Slice::UnitPtr) const = 0;
+ virtual unsigned int Body(FILE *, Slice::UnitPtr) const = 0;
boost::filesystem::path InputPath() const;
+
+ private:
+ unsigned int build(const boost::filesystem::path & in, FILE *) const;
};
#endif
diff --git a/project2/ice/unittests/testClient.cpp b/project2/ice/unittests/testClient.cpp
index dce6b2f..4c89184 100644
--- a/project2/ice/unittests/testClient.cpp
+++ b/project2/ice/unittests/testClient.cpp
@@ -107,21 +107,32 @@ unloadTests()
BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRowsParams"), NotSupported);
}
+void test_client_run(const boost::filesystem::path & tmpdir);
BOOST_AUTO_TEST_CASE( test_client )
{
- const std::string tmpdir = "/tmp/ut/project2.slice-client";
+ const boost::filesystem::path tmpdir = "/tmp/ut/project2.slice-client";
BOOST_TEST_CHECKPOINT("Clean up");
boost::filesystem::remove_all(tmpdir);
+ test_client_run(tmpdir);
+ test_client_run(tmpdir);
+}
+
+void test_client_run(const boost::filesystem::path & tmpdir)
+{
BOOST_TEST_CHECKPOINT("Configure, compile, link, load");
TestOptionsSource::LoadTestOptions({
{ "library", (bindir / "slicer-yes" / "libunittestr.so").string() },
{ "common.datasourceRoot", iceroot.string() },
- { "ice.compile.tmpdir", tmpdir },
+ { "ice.compile.tmpdir", tmpdir.string() },
{ "ice.compile.headers", headers.string() },
{ "ice.client.slicerclient", (iceroot / "unittestTypes.ice").string() },
{ "ice.client.slicerclient", (iceroot / "unittest.ice").string() }
});
+ BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittest.so"));
+ BOOST_REQUIRE(boost::filesystem::exists(tmpdir / "unittest.client.so"));
+ BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestTypes.so"));
+ BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestTypes.client.so"));
commonTests();
TestOptionsSource::LoadTestOptions({ });
diff --git a/project2/ice/unittests/testClientCompile.cpp b/project2/ice/unittests/testClientCompile.cpp
index 8a93270..213497e 100644
--- a/project2/ice/unittests/testClientCompile.cpp
+++ b/project2/ice/unittests/testClientCompile.cpp
@@ -39,18 +39,22 @@ unloadTests()
BOOST_AUTO_TEST_CASE( compile_client_full )
{
- const std::string tmpdir = "/tmp/ut/project2.slice-clientCompile/full";
+ const boost::filesystem::path tmpdir = "/tmp/ut/project2.slice-clientCompile/full";
BOOST_TEST_CHECKPOINT("Clean up");
boost::filesystem::remove_all(tmpdir);
BOOST_TEST_CHECKPOINT("Configure, compile, link, load");
TestOptionsSource::LoadTestOptions({
{ "common.datasourceRoot", iceroot.string() },
- { "ice.compile.tmpdir", tmpdir },
+ { "ice.compile.tmpdir", tmpdir.string() },
{ "ice.compile.headers", headers.string() },
{ "ice.client.slice", (iceroot / "unittestTypes.ice").string() },
{ "ice.client.slice", (iceroot / "unittest.ice").string() }
});
+ BOOST_REQUIRE(boost::filesystem::exists(tmpdir / "unittest.so"));
+ BOOST_REQUIRE(boost::filesystem::exists(tmpdir / "unittest.client.so"));
+ BOOST_REQUIRE(boost::filesystem::exists(tmpdir / "unittestTypes.so"));
+ BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestTypes.client.so"));
commonTests();
TestOptionsSource::LoadTestOptions({ });
@@ -59,7 +63,7 @@ BOOST_AUTO_TEST_CASE( compile_client_full )
BOOST_AUTO_TEST_CASE( compile_client_clientOnly )
{
- const std::string tmpdir = "/tmp/ut/project2.slice-clientCompile/clientOnly";
+ const boost::filesystem::path tmpdir = "/tmp/ut/project2.slice-clientCompile/clientOnly";
BOOST_TEST_CHECKPOINT("Clean up");
boost::filesystem::remove_all(tmpdir);
@@ -67,11 +71,15 @@ BOOST_AUTO_TEST_CASE( compile_client_clientOnly )
TestOptionsSource::LoadTestOptions({
{ "library", (bindir / "libunittest.so").string() },
{ "common.datasourceRoot", iceroot.string() },
- { "ice.compile.tmpdir", tmpdir },
+ { "ice.compile.tmpdir", tmpdir.string() },
{ "ice.compile.headers", headers.string() },
{ "ice.client.sliceclient", (iceroot / "unittestTypes.ice").string() },
{ "ice.client.sliceclient", (iceroot / "unittest.ice").string() }
});
+ BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittest.so"));
+ BOOST_REQUIRE(boost::filesystem::exists(tmpdir / "unittest.client.so"));
+ BOOST_REQUIRE(boost::filesystem::exists(tmpdir / "unittestTypes.so"));
+ BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestTypes.client.so"));
commonTests();
TestOptionsSource::LoadTestOptions({ });
@@ -80,7 +88,7 @@ BOOST_AUTO_TEST_CASE( compile_client_clientOnly )
BOOST_AUTO_TEST_CASE( compile_client_slicer )
{
- const std::string tmpdir = "/tmp/ut/project2.slice-clientCompile/slicer";
+ const boost::filesystem::path tmpdir = "/tmp/ut/project2.slice-clientCompile/slicer";
BOOST_TEST_CHECKPOINT("Clean up");
boost::filesystem::remove_all(tmpdir);
@@ -88,11 +96,15 @@ BOOST_AUTO_TEST_CASE( compile_client_slicer )
TestOptionsSource::LoadTestOptions({
{ "library", (bindir / "slicer-yes" / "libunittestr.so").string() },
{ "common.datasourceRoot", iceroot.string() },
- { "ice.compile.tmpdir", tmpdir },
+ { "ice.compile.tmpdir", tmpdir.string() },
{ "ice.compile.headers", headers.string() },
{ "ice.client.slicerclient", (iceroot / "unittestTypes.ice").string() },
{ "ice.client.slicerclient", (iceroot / "unittest.ice").string() }
});
+ BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittest.so"));
+ BOOST_REQUIRE(boost::filesystem::exists(tmpdir / "unittest.client.so"));
+ BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestTypes.so"));
+ BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestTypes.client.so"));
commonTests();
TestOptionsSource::LoadTestOptions({ });
diff --git a/project2/ice/unittests/testDaemon.cpp b/project2/ice/unittests/testDaemon.cpp
index 2a5a5df..e1b1b9e 100644
--- a/project2/ice/unittests/testDaemon.cpp
+++ b/project2/ice/unittests/testDaemon.cpp
@@ -138,7 +138,7 @@ unloadTests()
BOOST_AUTO_TEST_CASE( test_daemon )
{
- const std::string tmpdir = "/tmp/ut/project2.slice-daemon";
+ const boost::filesystem::path tmpdir = "/tmp/ut/project2.slice-daemon";
BOOST_TEST_CHECKPOINT("Clean up");
boost::filesystem::remove_all(tmpdir);
@@ -150,11 +150,15 @@ BOOST_AUTO_TEST_CASE( test_daemon )
{ "ice.daemon.adapterEndpoint", "tcp -p 12024" },
{ "ice.daemon.viewRoot", (iceroot / "views").string() },
{ "ice.daemon.taskRoot", (iceroot / "tasks").string() },
- { "ice.compile.tmpdir", tmpdir },
+ { "ice.compile.tmpdir", tmpdir.string() },
{ "ice.compile.headers", headers.string() },
{ "ice.daemon.slicerdaemon", (iceroot / "unittestTypes.ice").string() },
{ "ice.daemon.slicerdaemon", (iceroot / "unittest.ice").string() }
});
+ BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittest.so"));
+ BOOST_REQUIRE(boost::filesystem::exists(tmpdir / "unittest.daemon.so"));
+ BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestTypes.so"));
+ BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestTypes.daemon.so"));
commonTests();
TestOptionsSource::LoadTestOptions({ });
diff --git a/project2/ice/unittests/testDaemonCompile.cpp b/project2/ice/unittests/testDaemonCompile.cpp
index 22fcaed..ecbef13 100644
--- a/project2/ice/unittests/testDaemonCompile.cpp
+++ b/project2/ice/unittests/testDaemonCompile.cpp
@@ -29,17 +29,21 @@ unloadTests()
BOOST_AUTO_TEST_CASE( compile_daemon_full )
{
- const std::string tmpdir = "/tmp/ut/project2.slice-daemonCompile/full";
+ const boost::filesystem::path tmpdir = "/tmp/ut/project2.slice-daemonCompile/full";
BOOST_TEST_CHECKPOINT("Clean up");
boost::filesystem::remove_all(tmpdir);
BOOST_TEST_CHECKPOINT("Configure, compile, link, load");
TestOptionsSource::LoadTestOptions({
- { "ice.compile.tmpdir", tmpdir },
+ { "ice.compile.tmpdir", tmpdir.string() },
{ "ice.compile.headers", headers.string() },
{ "ice.daemon.slice", (iceroot / "unittestTypes.ice").string() },
{ "ice.daemon.slice", (iceroot / "unittest.ice").string() }
});
+ BOOST_REQUIRE(boost::filesystem::exists(tmpdir / "unittest.so"));
+ BOOST_REQUIRE(boost::filesystem::exists(tmpdir / "unittest.daemon.so"));
+ BOOST_REQUIRE(boost::filesystem::exists(tmpdir / "unittestTypes.so"));
+ BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestTypes.daemon.so"));
commonTests();
TestOptionsSource::LoadTestOptions({ });
@@ -48,18 +52,22 @@ BOOST_AUTO_TEST_CASE( compile_daemon_full )
BOOST_AUTO_TEST_CASE( compile_daemon_daemonOnly )
{
- const std::string tmpdir = "/tmp/ut/project2.slice-daemonCompile/daemonOnly";
+ const boost::filesystem::path tmpdir = "/tmp/ut/project2.slice-daemonCompile/daemonOnly";
BOOST_TEST_CHECKPOINT("Clean up");
boost::filesystem::remove_all(tmpdir);
BOOST_TEST_CHECKPOINT("Configure, compile, link, load");
TestOptionsSource::LoadTestOptions({
{ "library", (bindir / "libunittest.so").string() },
- { "ice.compile.tmpdir", tmpdir },
+ { "ice.compile.tmpdir", tmpdir.string() },
{ "ice.compile.headers", headers.string() },
{ "ice.daemon.slicedaemon", (iceroot / "unittestTypes.ice").string() },
{ "ice.daemon.slicedaemon", (iceroot / "unittest.ice").string() }
});
+ BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittest.so"));
+ BOOST_REQUIRE(boost::filesystem::exists(tmpdir / "unittest.daemon.so"));
+ BOOST_REQUIRE(boost::filesystem::exists(tmpdir / "unittestTypes.so"));
+ BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestTypes.daemon.so"));
commonTests();
TestOptionsSource::LoadTestOptions({ });
@@ -68,18 +76,22 @@ BOOST_AUTO_TEST_CASE( compile_daemon_daemonOnly )
BOOST_AUTO_TEST_CASE( compile_daemon_slicer )
{
- const std::string tmpdir = "/tmp/ut/project2.slice-daemonCompile/slicer";
+ const boost::filesystem::path tmpdir = "/tmp/ut/project2.slice-daemonCompile/slicer";
BOOST_TEST_CHECKPOINT("Clean up");
boost::filesystem::remove_all(tmpdir);
BOOST_TEST_CHECKPOINT("Configure, compile, link, load");
TestOptionsSource::LoadTestOptions({
{ "library", (bindir / "slicer-yes" / "libunittestr.so").string() },
- { "ice.compile.tmpdir", tmpdir },
+ { "ice.compile.tmpdir", tmpdir.string() },
{ "ice.compile.headers", headers.string() },
{ "ice.daemon.slicerdaemon", (iceroot / "unittestTypes.ice").string() },
{ "ice.daemon.slicerdaemon", (iceroot / "unittest.ice").string() }
});
+ BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittest.so"));
+ BOOST_REQUIRE(boost::filesystem::exists(tmpdir / "unittest.daemon.so"));
+ BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestTypes.so"));
+ BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestTypes.daemon.so"));
commonTests();
TestOptionsSource::LoadTestOptions({ });