X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fvcxprojectgenerator.cpp;h=bafa8d94f42ee629d84454171be34514e4b603e5;hb=d1eb133ab529cdae131be7b150209f03189248f3;hp=b5c42c5c2f0ce3715f552996ae47a28e25a49d1a;hpb=84da3f6c94dbe7e36aaf088890fda5fcf3b3efb0;p=builder.git diff --git a/source/vcxprojectgenerator.cpp b/source/vcxprojectgenerator.cpp index b5c42c5..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[] = { "x86-32", "x86-64", 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,26 +48,28 @@ 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(); - for(const char **i=platforms; *i; ++i) - for(vector::const_iterator j=build_types.begin(); j!=build_types.end(); ++j) + const string &toolchain = builder.get_current_arch().get_toolchain(); + for(const char *p: platforms) + for(const string &b: build_types) { - 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 --arch=%s --build-type=%s\n", argv0, *i, *j); - IO::print(out, "\t\t%s --arch=%s --build-type=%s -c\n", argv0, *i, *j); - IO::print(out, "\t\t%s --arch=%s --build-type=%s -B\n", argv0, *i, *j); + IO::print(out, "\t\t%s\n", base_cmd); + IO::print(out, "\t\t%s -c\n", base_cmd); + IO::print(out, "\t\t%s -B\n", base_cmd); if(exe) IO::print(out, "\t\t%s\n", exe->get_path()); IO::print(out, "\t\n"); @@ -84,13 +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; - for(BuildGraph::TargetMap::const_iterator i=targets.begin(); i!=targets.end(); ++i) - if(i->second->get_package()==&spkg && !i->second->is_buildable()) - if(const FileTarget *file = dynamic_cast(i->second)) + BuildInfo build_info; + for(const auto &kvp: builder.get_build_graph().get_targets()) + if(kvp.second->get_package()==&spkg) + { + if(kvp.second->is_buildable()) + { + BuildInfo tgt_binfo; + kvp.second->collect_build_info(tgt_binfo); + build_info.update_from(tgt_binfo, BuildInfo::CHAINED); + } + else if(const FileTarget *file = dynamic_cast(kvp.second)) { if(dynamic_cast(file)) { @@ -103,24 +103,35 @@ void VcxProjectGenerator::Worker::main() else others.push_back(file); } + } + + if(!build_info.incpath.empty()) + { + IO::print(out, "\t\n"); + string path_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; }