]> git.tdb.fi Git - builder.git/blob - source/vssolutiongenerator.cpp
Add ability to generate Visual Studio solution files
[builder.git] / source / vssolutiongenerator.cpp
1 #include <msp/io/file.h>
2 #include <msp/io/print.h>
3 #include "sourcepackage.h"
4 #include "vcxprojectfile.h"
5 #include "vssolutionfile.h"
6 #include "vssolutiongenerator.h"
7
8 using namespace std;
9 using namespace Msp;
10
11 VsSolutionGenerator::VsSolutionGenerator(Builder &b):
12         Tool(b, "VSSG")
13 { }
14
15 Target *VsSolutionGenerator::create_target(const list<Target *> &, const string &)
16 {
17         throw logic_error("Not implemented");
18 }
19
20 Task *VsSolutionGenerator::run(const Target &target) const
21 {
22         const VsSolutionFile &solution = dynamic_cast<const VsSolutionFile &>(target);
23         Worker *worker = new Worker(solution);
24         return new InternalTask(worker);
25 }
26
27
28 VsSolutionGenerator::Worker::Worker(const VsSolutionFile &t):
29         target(t)
30 { }
31
32 void VsSolutionGenerator::Worker::main()
33 {
34         IO::BufferedFile out(target.get_path().str(), IO::M_WRITE);
35         IO::print(out, "Microsoft Visual Studio Solution File, Format Version 12.00\n");
36         IO::print(out, "MinimumVisualStudioVersion = 10.0.40219.1\n");
37
38         const Target::Dependencies &deps = target.get_dependencies();
39         for(Target::Dependencies::const_iterator i=deps.begin(); i!=deps.end(); ++i)
40                 if(const VcxProjectFile *project = dynamic_cast<const VcxProjectFile *>(*i))
41                 {
42                         const SourcePackage *pkg = project->get_package();
43                         IO::print(out, "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"%s\", \"%s\", \"{%s}\"\nEndProject\n",
44                                 pkg->get_name(), project->get_path(), project->get_guid());
45                 }
46
47         status = Task::SUCCESS;
48 }