X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fvcxprojectgenerator.cpp;h=bafa8d94f42ee629d84454171be34514e4b603e5;hb=d1eb133ab529cdae131be7b150209f03189248f3;hp=871cde9f9eebfdf4bcc8825c67b5526abf6bfbb5;hpb=f0a97cb158bef2656bbb8e1dafe072af7ff9c596;p=builder.git diff --git a/source/vcxprojectgenerator.cpp b/source/vcxprojectgenerator.cpp index 871cde9..bafa8d9 100644 --- a/source/vcxprojectgenerator.cpp +++ b/source/vcxprojectgenerator.cpp @@ -5,6 +5,7 @@ #include "builder.h" #include "csourcefile.h" #include "executable.h" +#include "internaltask.h" #include "sourcepackage.h" #include "vcxprojectfile.h" #include "vcxprojectgenerator.h" @@ -12,11 +13,7 @@ using namespace std; using namespace Msp; -VcxProjectGenerator::VcxProjectGenerator(Builder &b): - Tool(b, "VCXG") -{ } - -Target *VcxProjectGenerator::create_target(const list &, const string &) +Target *VcxProjectGenerator::create_target(const vector &, const string &) { throw logic_error("Not implemented"); } @@ -24,32 +21,26 @@ Target *VcxProjectGenerator::create_target(const list &, const string Task *VcxProjectGenerator::run(const Target &target) const { const VcxProjectFile &project = dynamic_cast(target); - Worker *worker = new Worker(project); - return new InternalTask(worker); + return new InternalTask([&project]{ return _run(project); }); } - -VcxProjectGenerator::Worker::Worker(const VcxProjectFile &t): - target(t) -{ } - -void VcxProjectGenerator::Worker::main() +bool VcxProjectGenerator::_run(const VcxProjectFile &project) { - const SourcePackage &spkg = *target.get_package(); + const SourcePackage &spkg = *project.get_package(); Builder &builder = spkg.get_builder(); - IO::BufferedFile out(target.get_path().str(), IO::M_WRITE); + IO::BufferedFile out(project.get_path().str(), IO::M_WRITE); IO::print(out, "\n"); IO::print(out, "\t\n"); vector build_types = builder.get_build_types(); - const char *platforms[] = { "Win32", "x64", 0 }; - for(const char **i=platforms; *i; ++i) - for(vector::const_iterator j=build_types.begin(); j!=build_types.end(); ++j) + const char *platforms[] = { "Win32", "x64" }; + for(const char *p: platforms) + for(const string &b: build_types) { - IO::print(out, "\t\t\n", *j, *i); - IO::print(out, "\t\t\t%s\n", *j); - IO::print(out, "\t\t\t%s\n", *i); + IO::print(out, "\t\t\n", b, p); + IO::print(out, "\t\t\t%s\n", b); + IO::print(out, "\t\t\t%s\n", p); IO::print(out, "\t\t\n"); } IO::print(out, "\t\n"); @@ -57,24 +48,24 @@ void VcxProjectGenerator::Worker::main() IO::print(out, "\t\n"); IO::print(out, "\t\t15.0\n"); IO::print(out, "\t\tMakeFileProj\n"); + IO::print(out, "\t\t{%s}\n", project.get_guid()); IO::print(out, "\t\n"); IO::print(out, "\t\n"); - const Target *world = builder.get_build_graph().get_target("world"); - const Target::Dependencies &world_deps = world->get_dependencies(); const Executable *exe = 0; - for(Target::Dependencies::const_iterator i=world_deps.begin(); (!exe && i!=world_deps.end()); ++i) - if((*i)->get_package()==&spkg) - exe = dynamic_cast(*i); + for(const Target *t: builder.get_build_graph().get_target("world")->get_dependencies()) + if(t->get_package()==&spkg) + if((exe = dynamic_cast(t))) + break; const char *argv0 = Application::get_argv0(); const string &toolchain = builder.get_current_arch().get_toolchain(); - for(const char **i=platforms; *i; ++i) - for(vector::const_iterator j=build_types.begin(); j!=build_types.end(); ++j) + for(const char *p: platforms) + for(const string &b: build_types) { - string base_cmd = format("%s --arch=%s-%s --build-type=%s --prefix=%s", argv0, *i, toolchain, *j, builder.get_prefix()); - IO::print(out, "\t\n", *j, *i); + string base_cmd = format("%s --arch=%s-%s --build-type=%s --prefix=%s", argv0, p, toolchain, b, builder.get_prefix()); + IO::print(out, "\t\n", b, p); IO::print(out, "\t\tMakeFile\n"); IO::print(out, "\t\t%s\n", base_cmd); IO::print(out, "\t\t%s -c\n", base_cmd); @@ -86,21 +77,20 @@ void VcxProjectGenerator::Worker::main() IO::print(out, "\t\n"); - const BuildGraph::TargetMap &targets = builder.get_build_graph().get_targets(); vector sources; vector includes; vector others; BuildInfo build_info; - for(BuildGraph::TargetMap::const_iterator i=targets.begin(); i!=targets.end(); ++i) - if(i->second->get_package()==&spkg) + for(const auto &kvp: builder.get_build_graph().get_targets()) + if(kvp.second->get_package()==&spkg) { - if(i->second->is_buildable()) + if(kvp.second->is_buildable()) { BuildInfo tgt_binfo; - i->second->collect_build_info(tgt_binfo); + kvp.second->collect_build_info(tgt_binfo); build_info.update_from(tgt_binfo, BuildInfo::CHAINED); } - else if(const FileTarget *file = dynamic_cast(i->second)) + else if(const FileTarget *file = dynamic_cast(kvp.second)) { if(dynamic_cast(file)) { @@ -119,29 +109,29 @@ void VcxProjectGenerator::Worker::main() { IO::print(out, "\t\n"); string path_str; - for(BuildInfo::PathList::const_iterator i=build_info.incpath.begin(); i!=build_info.incpath.end(); ++i) - append(path_str, ";", i->str()); + for(const FS::Path &p: build_info.incpath) + append(path_str, ";", p.str()); IO::print(out, "\t\t%s\n", path_str); IO::print(out, "\t\n"); } IO::print(out, "\t\n"); - for(vector::const_iterator i=sources.begin(); i!=sources.end(); ++i) - IO::print(out, "\t\t\n", (*i)->get_path()); + for(const FileTarget *s: sources) + IO::print(out, "\t\t\n", s->get_path()); IO::print(out, "\t\n"); IO::print(out, "\t\n"); - for(vector::const_iterator i=includes.begin(); i!=includes.end(); ++i) - IO::print(out, "\t\t\n", (*i)->get_path()); + for(const FileTarget *i: includes) + IO::print(out, "\t\t\n", i->get_path()); IO::print(out, "\t\n"); IO::print(out, "\t\n"); - for(vector::const_iterator i=others.begin(); i!=others.end(); ++i) - IO::print(out, "\t\t\n", (*i)->get_path()); + for(const FileTarget *t: others) + IO::print(out, "\t\t\n", t->get_path()); IO::print(out, "\t\n"); IO::print(out, "\t\n"); IO::print(out, "\n"); - status = Task::SUCCESS; + return true; }