2 #include <msp/io/file.h>
3 #include <msp/io/print.h>
5 #include "sourcepackage.h"
6 #include "vcxprojectfile.h"
7 #include "vssolutionfile.h"
8 #include "vssolutiongenerator.h"
13 VsSolutionGenerator::VsSolutionGenerator(Builder &b):
17 Target *VsSolutionGenerator::create_target(const vector<Target *> &, const string &)
19 throw logic_error("Not implemented");
22 Task *VsSolutionGenerator::run(const Target &target) const
24 const VsSolutionFile &solution = dynamic_cast<const VsSolutionFile &>(target);
25 Worker *worker = new Worker(solution);
26 return new InternalTask(worker);
30 VsSolutionGenerator::Worker::Worker(const VsSolutionFile &t):
34 void VsSolutionGenerator::Worker::main()
36 const SourcePackage &spkg = *target.get_package();
37 Builder &builder = spkg.get_builder();
39 IO::BufferedFile out(target.get_path().str(), IO::M_WRITE);
40 IO::print(out, "Microsoft Visual Studio Solution File, Format Version 12.00\n");
41 IO::print(out, "MinimumVisualStudioVersion = 10.0.40219.1\n");
43 vector<const VcxProjectFile *> projects;
44 for(const Target *t: target.get_dependencies())
45 if(const VcxProjectFile *project = dynamic_cast<const VcxProjectFile *>(t))
46 projects.push_back(project);
48 for(const VcxProjectFile *p: projects)
50 const SourcePackage *pkg = p->get_package();
51 IO::print(out, "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"%s\", \"%s\", \"{%s}\"\nEndProject\n",
52 pkg->get_name(), p->get_path(), p->get_guid());
55 vector<string> build_types = builder.get_build_types();
56 const char *platforms[] = { "x86", "x64" };
58 IO::print(out, "Global\n");
59 IO::print(out, "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n");
60 for(const string &t: build_types)
61 for(const char *p: platforms)
62 IO::print(out, "\t\t%s|%s = %s|%s\n", t, p, t, p);
63 IO::print(out, "\tEndGlobalSection\n");
64 IO::print(out, "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n");
65 for(const VcxProjectFile *p: projects)
66 for(const string &t: build_types)
67 for(const char *f: platforms)
69 const char *project_platform = (!strcmp(f, "x86") ? "Win32" : f);
70 IO::print(out, "\t\t{%s}.%s|%s.ActiveCfg = %s|%s\n", p->get_guid(), t, f, t, project_platform);
71 if(p->get_package()==&spkg)
72 IO::print(out, "\t\t{%s}.%s|%s.Build.0 = %s|%s\n", p->get_guid(), t, f, t, project_platform);
74 IO::print(out, "\tEndGlobalSection\n");
75 IO::print(out, "EndGlobal\n");
77 status = Task::SUCCESS;