#include #include "sliceCompile.h" #include SliceCompile::SliceCompile(const boost::filesystem::path & slice, const IceCompile::Deps & dep) : IceCompile(slice, dep) { } void SliceCompile::Build(const boost::filesystem::path & in, const boost::filesystem::path & outpath) const { std::vector cppArgs; Slice::PreprocessorPtr icecpp = Slice::Preprocessor::create("slice2project2", in.string(), cppArgs); FILE * cppHandle = icecpp->preprocess(false); if (cppHandle == NULL) { throw std::runtime_error("preprocess failed"); } Slice::UnitPtr u = Slice::Unit::createUnit(false, false, false, false); ScopeObject uDestroy(boost::bind(&Slice::Unit::destroy, u.get())); int parseStatus = u->parse(in.string(), cppHandle, false); if (!icecpp->close()) { throw std::runtime_error("preprocess close failed"); } if (parseStatus == EXIT_FAILURE) { throw std::runtime_error("unit parse failed"); } 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); if (fclose(out)) { throw std::runtime_error("failed to close target"); } } void SliceCompile::Headers(FILE *) const { } boost::filesystem::path SliceCompile::InputPath() const { return slice; }