Exemple #1
0
void ImportProject::importSln(std::istream &istr, const std::string &path)
{
    std::map<std::string,std::string,cppcheck::stricmp> variables;
    variables["SolutionDir"] = path;

    std::string line;
    while (std::getline(istr,line)) {
        if (line.compare(0,8,"Project(")!=0)
            continue;
        const std::string::size_type pos = line.find(".vcxproj");
        if (pos == std::string::npos)
            continue;
        const std::string::size_type pos1 = line.rfind('\"',pos);
        if (pos1 == std::string::npos)
            continue;
        std::string vcxproj(line.substr(pos1+1, pos-pos1+7));
        if (!Path::isAbsolute(vcxproj))
            vcxproj = path + vcxproj;
        importVcxproj(Path::fromNativeSeparators(vcxproj), variables, emptyString);
    }
}
Exemple #2
0
bool vs2015::do_export(const config & cfg)
{
	std::string ind1 = "  ";
	std::string ind2 = "    ";
	std::string ind3 = "      ";

	std::ofstream vcxproj(cfg["%prj%"] + ".vcxproj");

	vcxproj.close();

	std::ofstream filters(cfg["%prj%"] + ".vcxproj.filters");
	filters << "<?xml version=\"1.0\" encoding=\"utf - 8\"?>" << std::endl;
	filters << "<Project ToolsVersion = \"4.0\" xmlns = \"http://schemas.microsoft.com/developer/msbuild/2003\">" << std::endl;

	stringvec collection;

	//filters
	collection = cfg.filters();
	filters << ind1 << "<ItemGroup>" << std::endl;
	for (auto & filter : collection)
	{
		filters << ind2 << "<Filter Include=\"" << filter << "\">" << std::endl;
		filters << ind2 << "</Filter>" << std::endl;
	}
	filters << ind1 << "</ItemGroup>" << std::endl;

	//sources
	collection = cfg.sources("win32");
	filters << ind1 << "<ItemGroup>" << std::endl;
	for (auto & src : collection)
	{
		filters << ind2 << "<ClCompile Include=\"" << cfg.srcdir() + src << "\">" << std::endl;
		filters << ind3 << "<Filter>" << src << "</Filter>";
		filters << ind2 << "</ClCompile>" << std::endl;
	}
	filters << ind1 << "</ItemGroup>" << std::endl;

	//headers
	collection = cfg.headers();
	filters << ind1 << "<ItemGroup>" << std::endl;
	for (auto & head : collection)
	{
		filters << ind2 << "<ClInclude Include=\"" << cfg.srcdir() + head << "\">" << std::endl;
		filters << ind3 << "<Filter>" << head << "</Filter>";
		filters << ind2 << "</ClInclude>" << std::endl;
	}
	filters << ind1 << "</ItemGroup>" << std::endl;

	//others
	collection = cfg.others();
	filters << ind1 << "<ItemGroup>" << std::endl;
	for (auto & file : collection)
	{
		if (common::ends_with(file, ".natvis"))
		{
			filters << ind2 << "<Natvis Include=\"" << cfg.srcdir() + file << "\">" << std::endl;
		}
		else
		{
			filters << ind2 << "<ClOther Include=\"" << cfg.srcdir() + file << "\">" << std::endl;
			filters << ind3 << "<Filter>" << file << "</Filter>";
			filters << ind2 << "</ClOther>" << std::endl;
		}
	}
	filters << ind1 << "</ItemGroup>" << std::endl;

	filters << "</Project>";
	filters.close();
}