X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=plugins%2Fmsvc%2Fvcxprojectgenerator.cpp;fp=plugins%2Fmsvc%2Fvcxprojectgenerator.cpp;h=7cb9faf13a38c97fb4196d40185282e9b457d3db;hb=1dc209f3b40259a5ff2ebdc3081e533b9fbc7b52;hp=0000000000000000000000000000000000000000;hpb=3d4ef1b93e8cfd8467efd132cb80ad4bd368f33a;p=builder.git diff --git a/plugins/msvc/vcxprojectgenerator.cpp b/plugins/msvc/vcxprojectgenerator.cpp new file mode 100644 index 0000000..7cb9faf --- /dev/null +++ b/plugins/msvc/vcxprojectgenerator.cpp @@ -0,0 +1,136 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include "vcxprojectfile.h" +#include "vcxprojectgenerator.h" + +using namespace std; +using namespace Msp; + +VcxProjectGenerator::VcxProjectGenerator(Builder &b): + Tool(b, "VCXG") +{ + set_run_internal(_run); +} + +Target *VcxProjectGenerator::create_target(const vector &, const string &) +{ + throw logic_error("Not implemented"); +} + +bool VcxProjectGenerator::_run(const VcxProjectFile &project) +{ + const SourcePackage &spkg = *project.get_package(); + Builder &builder = spkg.get_builder(); + + 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[] = { "Win32", "x64" }; + for(const char *p: platforms) + for(const string &b: build_types) + { + 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"); + + 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 Executable *exe = 0; + 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(); + const string &toolchain = builder.get_current_arch().get_toolchain(); + for(const char *p: platforms) + for(const string &b: build_types) + { + 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\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"); + } + + IO::print(out, "\t\n"); + + vector sources; + vector includes; + vector others; + 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)) + { + string ext = tolower(FS::extpart(FS::basename(file->get_path()))); + if(ext==".h" || ext==".hpp") + includes.push_back(file); + else + sources.push_back(file); + } + 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(const FileTarget *s: sources) + IO::print(out, "\t\t\n", s->get_path()); + IO::print(out, "\t\n"); + + IO::print(out, "\t\n"); + 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(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"); + + return true; +}