X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fvssolutiongenerator.cpp;h=5fd8e4dff2a10d0371227f9f76c136ef0d04ba4b;hb=d1eb133ab529cdae131be7b150209f03189248f3;hp=90adc693ebdedd7a51b0cffb41929343aac792be;hpb=eabb3f5b9b0d32adda71d4dd7e56796f7ea3bdd2;p=builder.git diff --git a/source/vssolutiongenerator.cpp b/source/vssolutiongenerator.cpp index 90adc69..5fd8e4d 100644 --- a/source/vssolutiongenerator.cpp +++ b/source/vssolutiongenerator.cpp @@ -1,5 +1,8 @@ +#include #include #include +#include "builder.h" +#include "internaltask.h" #include "sourcepackage.h" #include "vcxprojectfile.h" #include "vssolutionfile.h" @@ -8,11 +11,7 @@ using namespace std; using namespace Msp; -VsSolutionGenerator::VsSolutionGenerator(Builder &b): - Tool(b, "VSSG") -{ } - -Target *VsSolutionGenerator::create_target(const list &, const string &) +Target *VsSolutionGenerator::create_target(const vector &, const string &) { throw logic_error("Not implemented"); } @@ -20,29 +19,51 @@ Target *VsSolutionGenerator::create_target(const list &, const string Task *VsSolutionGenerator::run(const Target &target) const { const VsSolutionFile &solution = dynamic_cast(target); - Worker *worker = new Worker(solution); - return new InternalTask(worker); + return new InternalTask([&solution]{ return _run(solution); }); } - -VsSolutionGenerator::Worker::Worker(const VsSolutionFile &t): - target(t) -{ } - -void VsSolutionGenerator::Worker::main() +bool VsSolutionGenerator::_run(const VsSolutionFile &solution) { - IO::BufferedFile out(target.get_path().str(), IO::M_WRITE); + const SourcePackage &spkg = *solution.get_package(); + Builder &builder = spkg.get_builder(); + + IO::BufferedFile out(solution.get_path().str(), IO::M_WRITE); IO::print(out, "Microsoft Visual Studio Solution File, Format Version 12.00\n"); IO::print(out, "MinimumVisualStudioVersion = 10.0.40219.1\n"); - const Target::Dependencies &deps = target.get_dependencies(); - for(Target::Dependencies::const_iterator i=deps.begin(); i!=deps.end(); ++i) - if(const VcxProjectFile *project = dynamic_cast(*i)) - { - const SourcePackage *pkg = project->get_package(); - IO::print(out, "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"%s\", \"%s\", \"{%s}\"\nEndProject\n", - pkg->get_name(), project->get_path(), project->get_guid()); - } + vector projects; + for(const Target *t: solution.get_dependencies()) + if(const VcxProjectFile *project = dynamic_cast(t)) + projects.push_back(project); + + for(const VcxProjectFile *p: projects) + { + const SourcePackage *pkg = p->get_package(); + IO::print(out, "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"%s\", \"%s\", \"{%s}\"\nEndProject\n", + pkg->get_name(), p->get_path(), p->get_guid()); + } + + vector build_types = builder.get_build_types(); + const char *platforms[] = { "x86", "x64" }; + + IO::print(out, "Global\n"); + IO::print(out, "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n"); + for(const string &t: build_types) + for(const char *p: platforms) + IO::print(out, "\t\t%s|%s = %s|%s\n", t, p, t, p); + IO::print(out, "\tEndGlobalSection\n"); + IO::print(out, "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n"); + for(const VcxProjectFile *p: projects) + for(const string &t: build_types) + for(const char *f: platforms) + { + const char *project_platform = (!strcmp(f, "x86") ? "Win32" : f); + IO::print(out, "\t\t{%s}.%s|%s.ActiveCfg = %s|%s\n", p->get_guid(), t, f, t, project_platform); + if(p->get_package()==&spkg) + IO::print(out, "\t\t{%s}.%s|%s.Build.0 = %s|%s\n", p->get_guid(), t, f, t, project_platform); + } + IO::print(out, "\tEndGlobalSection\n"); + IO::print(out, "EndGlobal\n"); - status = Task::SUCCESS; + return true; }