logic: vs compiler flags
Added compiler flags from VS solution and vs compatibility flags.
This commit is contained in:
@@ -26,6 +26,7 @@ public:
|
||||
virtual std::vector<std::string> getProjects() = 0;
|
||||
virtual std::vector<std::string> getProjectFiles() = 0;
|
||||
virtual std::vector<std::string> getProjectItems() = 0;
|
||||
virtual std::vector<std::string> getCompileFlags() = 0;
|
||||
|
||||
virtual ProjectSettings getProjectSettings(const std::string& solutionFilePath) = 0;
|
||||
|
||||
|
||||
@@ -167,6 +167,13 @@ std::vector<std::string> SolutionParserCodeBlocks::getIncludePaths()
|
||||
return includePaths;
|
||||
}
|
||||
|
||||
std::vector<std::string> SolutionParserCodeBlocks::getCompileFlags()
|
||||
{
|
||||
std::vector<std::string> compilerFlags;
|
||||
|
||||
return compilerFlags;
|
||||
}
|
||||
|
||||
ProjectSettings SolutionParserCodeBlocks::getProjectSettings(const std::string& solutionFilePath)
|
||||
{
|
||||
openSolutionFile(solutionFilePath);
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
virtual std::vector<std::string> getProjectFiles();
|
||||
virtual std::vector<std::string> getProjectItems();
|
||||
virtual std::vector<std::string> getIncludePaths();
|
||||
virtual std::vector<std::string> getCompileFlags();
|
||||
|
||||
virtual ProjectSettings getProjectSettings(const std::string& solutionFilePath);
|
||||
|
||||
|
||||
@@ -8,4 +8,4 @@ class SolutionParserEclipse
|
||||
|
||||
};
|
||||
|
||||
#endif // SOLUTION_PARSER_ECLIPSE_H
|
||||
#endif // SOLUTION_PARSER_ECLIPSE_H
|
||||
|
||||
@@ -12,8 +12,11 @@
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
SolutionParserVisualStudio::SolutionParserVisualStudio()
|
||||
: m_compatibilityFlags()
|
||||
{
|
||||
|
||||
m_compatibilityFlags.push_back("-fms-extensions");
|
||||
m_compatibilityFlags.push_back("-fms-compatibility");
|
||||
m_compatibilityFlags.push_back("-fms-compatibility-version=19.00");
|
||||
}
|
||||
|
||||
SolutionParserVisualStudio::~SolutionParserVisualStudio()
|
||||
@@ -107,6 +110,62 @@ std::vector<std::string> SolutionParserVisualStudio::getIncludePaths()
|
||||
return includePaths;
|
||||
}
|
||||
|
||||
std::vector<std::string> SolutionParserVisualStudio::getCompileFlags()
|
||||
{
|
||||
std::vector<std::string> compilerFlags;
|
||||
|
||||
std::vector<std::string> projectFiles = getProjectFiles();
|
||||
|
||||
std::vector<std::string> validExtensions;
|
||||
validExtensions.push_back(".c");
|
||||
validExtensions.push_back(".cpp");
|
||||
validExtensions.push_back(".h");
|
||||
validExtensions.push_back(".hpp");
|
||||
|
||||
for (unsigned int i = 0; i < projectFiles.size(); i++)
|
||||
{
|
||||
TiXmlDocument doc;
|
||||
doc.Parse(projectFiles[i].c_str(), 0, TIXML_ENCODING_UTF8);
|
||||
|
||||
std::string error = doc.ErrorDesc();
|
||||
|
||||
if (error.length() > 0)
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Failed to parse project file " << i << ": " << error);
|
||||
continue;
|
||||
}
|
||||
|
||||
std::vector<TiXmlElement*> nodes = SolutionParserUtility::getAllTagsByName(doc.RootElement(), "PreprocessorDefinitions");
|
||||
|
||||
for (unsigned int j = 0; j < nodes.size(); j++)
|
||||
{
|
||||
compilerFlags.push_back(std::string(nodes[j]->GetText()));
|
||||
}
|
||||
}
|
||||
|
||||
compilerFlags = seperateCompilerFlags(compilerFlags);
|
||||
|
||||
for (unsigned int i = 0; i < compilerFlags.size(); i++)
|
||||
{
|
||||
compilerFlags[i] = "-D " + compilerFlags[i];
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < m_compatibilityFlags.size(); i++)
|
||||
{
|
||||
compilerFlags.push_back(m_compatibilityFlags[i]);
|
||||
}
|
||||
|
||||
//for (unsigned int i = 0; i < compilerFlags.size(); i++)
|
||||
//{
|
||||
// LOG_INFO_STREAM(<< "flag: " << compilerFlags[i]);
|
||||
//}
|
||||
|
||||
std::set<std::string> s(compilerFlags.begin(), compilerFlags.end());
|
||||
compilerFlags.assign(s.begin(), s.end());
|
||||
|
||||
return compilerFlags;
|
||||
}
|
||||
|
||||
ProjectSettings SolutionParserVisualStudio::getProjectSettings(const std::string& solutionFilePath)
|
||||
{
|
||||
openSolutionFile(solutionFilePath);
|
||||
@@ -131,6 +190,9 @@ ProjectSettings SolutionParserVisualStudio::getProjectSettings(const std::string
|
||||
headerPaths.push_back(FilePath(p));
|
||||
}
|
||||
|
||||
std::vector<std::string> compilerFlags = getCompileFlags();
|
||||
settings.setCompilerFlags(compilerFlags);
|
||||
|
||||
settings.setSourcePaths(sourcePaths);
|
||||
settings.setHeaderSearchPaths(headerPaths);
|
||||
|
||||
@@ -462,3 +524,41 @@ std::vector<std::string> SolutionParserVisualStudio::seperateIncludePaths(const
|
||||
|
||||
return seperatedPaths;
|
||||
}
|
||||
|
||||
std::vector<std::string> SolutionParserVisualStudio::seperateCompilerFlags(const std::vector<std::string>& compilerFlags) const
|
||||
{
|
||||
std::vector<std::string> seperatedFlags;
|
||||
|
||||
for (unsigned int i = 0; i < compilerFlags.size(); i++)
|
||||
{
|
||||
std::vector<std::string> paths = seperateCompilerFlags(compilerFlags[i]);
|
||||
for (unsigned int j = 0; j < paths.size(); j++)
|
||||
{
|
||||
seperatedFlags.push_back(paths[j]);
|
||||
}
|
||||
}
|
||||
|
||||
return seperatedFlags;
|
||||
}
|
||||
|
||||
std::vector<std::string> SolutionParserVisualStudio::seperateCompilerFlags(const std::string& compilerFlags) const
|
||||
{
|
||||
std::string flags = compilerFlags;
|
||||
std::string seperator = ";";
|
||||
|
||||
std::vector<std::string> seperatedFlags;
|
||||
|
||||
size_t pos = flags.find(seperator);
|
||||
|
||||
while (pos != std::string::npos)
|
||||
{
|
||||
std::string flag = flags.substr(0, pos);
|
||||
flags = flags.substr(pos + 1);
|
||||
|
||||
seperatedFlags.push_back(flag);
|
||||
|
||||
pos = flags.find(seperator);
|
||||
}
|
||||
|
||||
return seperatedFlags;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
virtual std::vector<std::string> getProjectFiles();
|
||||
virtual std::vector<std::string> getProjectItems();
|
||||
virtual std::vector<std::string> getIncludePaths();
|
||||
virtual std::vector<std::string> getCompileFlags();
|
||||
|
||||
virtual ProjectSettings getProjectSettings(const std::string& solutionFilePath);
|
||||
|
||||
@@ -39,6 +40,11 @@ private:
|
||||
|
||||
std::vector<std::string> seperateIncludePaths(const std::vector<std::string>& includePaths) const;
|
||||
std::vector<std::string> seperateIncludePaths(const std::string& includePaths) const;
|
||||
|
||||
std::vector<std::string> seperateCompilerFlags(const std::vector<std::string>& compilerFlags) const;
|
||||
std::vector<std::string> seperateCompilerFlags(const std::string& compilerFlags) const;
|
||||
|
||||
std::vector<std::string> m_compatibilityFlags;
|
||||
};
|
||||
|
||||
#endif // SOLUTION_PARSER_VISUAL_STUDIO_H
|
||||
|
||||
@@ -37,8 +37,8 @@ QtProjectWizzard::QtProjectWizzard(QWidget* parent)
|
||||
m_parserManager = std::make_shared<SolutionParserManager>();
|
||||
|
||||
// wip
|
||||
/*m_parserManager->pushSolutionParser(std::make_shared<SolutionParserVisualStudio>());
|
||||
m_parserManager->pushSolutionParser(std::make_shared<SolutionParserCodeBlocks>());*/
|
||||
m_parserManager->pushSolutionParser(std::make_shared<SolutionParserVisualStudio>());
|
||||
m_parserManager->pushSolutionParser(std::make_shared<SolutionParserCodeBlocks>());
|
||||
}
|
||||
|
||||
void QtProjectWizzard::showWindow()
|
||||
|
||||
@@ -65,35 +65,36 @@ void QtProjectWizzardContentSelect::populateWindow(QGridLayout* layout)
|
||||
|
||||
QToolButton* a = createProjectButton(
|
||||
"empty project", (ResourcePaths::getGuiPath() + "icon/project_256_256.png").c_str());
|
||||
QToolButton* b = createProjectButton(
|
||||
"from Visual\nStudio Solution", (ResourcePaths::getGuiPath() + "icon/project_vs_256_256.png").c_str());
|
||||
QToolButton* c = createProjectButton(
|
||||
"from Compilation\nDatabase", (ResourcePaths::getGuiPath() + "icon/project_cdb_256_256.png").c_str());
|
||||
|
||||
/*QToolButton* b = createProjectButton(
|
||||
"from Visual\nStudio Solution", (ResourcePaths::getGuiPath() + "icon/project_vs_256_256.png").c_str());*/
|
||||
|
||||
|
||||
m_solutionDescription.push_back("Create a new Coati project by defining what files will be analyzed and header search paths.");
|
||||
m_solutionDescription.push_back("Create a new project from an existing Visual Studio Solution file.");
|
||||
m_solutionDescription.push_back("Create a project from an existing Compilation Database. Compilation Databases can be created from "
|
||||
"cmake projects. Have a look at the "
|
||||
"<a href=\"https://staging.coati.io/documentation/#CreateAProjectFromCompilationDatabase\">"
|
||||
"documentation</a> to find out more.");
|
||||
//m_solutionDescription.push_back("Create a new project from an existing Visual Studio Solution file.");
|
||||
|
||||
m_buttons = new QButtonGroup(this);
|
||||
m_buttons->addButton(a);
|
||||
m_buttons->addButton(b);
|
||||
m_buttons->addButton(c);
|
||||
//m_buttons->addButton(b);
|
||||
|
||||
m_buttons->setId(a, PROJECT_EMPTY);
|
||||
m_buttons->setId(b, PROJECT_VS);
|
||||
m_buttons->setId(c, PROJECT_CDB);
|
||||
//m_buttons->setId(b, PROJECT_VS);
|
||||
|
||||
QHBoxLayout* hlayout = new QHBoxLayout();
|
||||
|
||||
hlayout->addWidget(a);
|
||||
hlayout->addWidget(b);
|
||||
hlayout->addWidget(c);
|
||||
//hlayout->addWidget(b);
|
||||
|
||||
unsigned int runningId = 3;
|
||||
unsigned int runningId = 2;
|
||||
std::shared_ptr<SolutionParserManager> manager = m_solutionParserManager.lock();
|
||||
if (manager != NULL)
|
||||
{
|
||||
@@ -177,8 +178,8 @@ void QtProjectWizzardContentSelect::save()
|
||||
switch (m_buttons->checkedId())
|
||||
{
|
||||
case 0: type = PROJECT_EMPTY; break;
|
||||
case 1: type = PROJECT_VS; break;
|
||||
case 2: type = PROJECT_CDB; break;
|
||||
case 1: type = PROJECT_CDB; break;
|
||||
case 2: type = PROJECT_VS; break;
|
||||
default: type = PROJECT_VS; break; // use vs for "standard" solutions TODO: change name of enum to reflect this is the default type
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ public:
|
||||
enum ProjectType : int
|
||||
{
|
||||
PROJECT_EMPTY = 0,
|
||||
PROJECT_VS = 1,
|
||||
PROJECT_CDB = 2
|
||||
PROJECT_CDB = 1,
|
||||
PROJECT_VS = 2
|
||||
};
|
||||
|
||||
QtProjectWizzardContentSelect(ProjectSettings* settings, QtProjectWizzardWindow* window, std::weak_ptr<SolutionParserManager> solutionParserManager);
|
||||
|
||||
Reference in New Issue
Block a user