]> git.tdb.fi Git - builder.git/blobdiff - source/vssolutiongenerator.cpp
Add ability to generate Visual Studio solution files
[builder.git] / source / vssolutiongenerator.cpp
diff --git a/source/vssolutiongenerator.cpp b/source/vssolutiongenerator.cpp
new file mode 100644 (file)
index 0000000..90adc69
--- /dev/null
@@ -0,0 +1,48 @@
+#include <msp/io/file.h>
+#include <msp/io/print.h>
+#include "sourcepackage.h"
+#include "vcxprojectfile.h"
+#include "vssolutionfile.h"
+#include "vssolutiongenerator.h"
+
+using namespace std;
+using namespace Msp;
+
+VsSolutionGenerator::VsSolutionGenerator(Builder &b):
+       Tool(b, "VSSG")
+{ }
+
+Target *VsSolutionGenerator::create_target(const list<Target *> &, const string &)
+{
+       throw logic_error("Not implemented");
+}
+
+Task *VsSolutionGenerator::run(const Target &target) const
+{
+       const VsSolutionFile &solution = dynamic_cast<const VsSolutionFile &>(target);
+       Worker *worker = new Worker(solution);
+       return new InternalTask(worker);
+}
+
+
+VsSolutionGenerator::Worker::Worker(const VsSolutionFile &t):
+       target(t)
+{ }
+
+void VsSolutionGenerator::Worker::main()
+{
+       IO::BufferedFile out(target.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<const VcxProjectFile *>(*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());
+               }
+
+       status = Task::SUCCESS;
+}