2016-08-13 10:50:03 +02:00
|
|
|
/*
|
|
|
|
* Cppcheck - A tool for static C/C++ code analysis
|
2019-02-09 07:24:06 +01:00
|
|
|
* Copyright (C) 2007-2019 Cppcheck team.
|
2016-08-13 10:50:03 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
#ifndef importprojectH
|
|
|
|
#define importprojectH
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2016-12-06 20:02:43 +01:00
|
|
|
#include "config.h"
|
|
|
|
#include "platform.h"
|
2017-09-30 11:25:46 +02:00
|
|
|
#include "utils.h"
|
2017-05-27 04:33:47 +02:00
|
|
|
|
2016-08-13 10:50:03 +02:00
|
|
|
#include <list>
|
2016-11-11 16:22:14 +01:00
|
|
|
#include <map>
|
2016-08-13 10:50:03 +02:00
|
|
|
#include <set>
|
2017-05-27 04:33:47 +02:00
|
|
|
#include <string>
|
2016-08-13 10:50:03 +02:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
/// @addtogroup Core
|
|
|
|
/// @{
|
|
|
|
|
2017-09-24 22:36:20 +02:00
|
|
|
namespace cppcheck {
|
2017-09-24 22:57:24 +02:00
|
|
|
struct stricmp {
|
|
|
|
bool operator()(const std::string &lhs, const std::string &rhs) const {
|
2017-09-30 11:25:46 +02:00
|
|
|
return caseInsensitiveStringCompare(lhs,rhs) < 0;
|
2017-09-24 22:36:20 +02:00
|
|
|
}
|
2017-09-24 22:57:24 +02:00
|
|
|
};
|
2017-09-24 22:36:20 +02:00
|
|
|
}
|
|
|
|
|
2019-01-31 20:40:15 +01:00
|
|
|
class Settings;
|
|
|
|
|
2016-08-13 10:50:03 +02:00
|
|
|
/**
|
|
|
|
* @brief Importing project settings.
|
|
|
|
*/
|
|
|
|
class CPPCHECKLIB ImportProject {
|
|
|
|
public:
|
2019-01-31 20:40:15 +01:00
|
|
|
enum class Type {
|
2018-07-25 16:26:25 +02:00
|
|
|
UNKNOWN,
|
|
|
|
MISSING,
|
|
|
|
COMPILE_DB,
|
|
|
|
VS_SLN,
|
|
|
|
VS_VCXPROJ,
|
2019-01-31 20:40:15 +01:00
|
|
|
BORLAND,
|
|
|
|
CPPCHECK_GUI
|
2018-07-25 16:26:25 +02:00
|
|
|
};
|
|
|
|
|
2016-08-13 10:50:03 +02:00
|
|
|
/** File settings. Multiple configurations for a file is allowed. */
|
2017-11-11 11:13:18 +01:00
|
|
|
struct CPPCHECKLIB FileSettings {
|
2017-08-08 22:57:11 +02:00
|
|
|
FileSettings() : platformType(cppcheck::Platform::Unspecified), msc(false), useMfc(false) {}
|
2016-08-13 10:50:03 +02:00
|
|
|
std::string cfg;
|
|
|
|
std::string filename;
|
|
|
|
std::string defines;
|
2017-08-08 22:26:42 +02:00
|
|
|
std::string cppcheckDefines() const {
|
2017-08-08 22:57:11 +02:00
|
|
|
return defines + (msc ? ";_MSC_VER=1900" : "") + (useMfc ? ";__AFXWIN_H__=1" : "");
|
2017-08-08 22:26:42 +02:00
|
|
|
}
|
2016-08-13 10:50:03 +02:00
|
|
|
std::set<std::string> undefs;
|
|
|
|
std::list<std::string> includePaths;
|
2017-08-03 20:38:24 +02:00
|
|
|
std::list<std::string> systemIncludePaths;
|
|
|
|
std::string standard;
|
2016-08-13 10:50:03 +02:00
|
|
|
cppcheck::Platform::PlatformType platformType;
|
2017-08-08 22:57:11 +02:00
|
|
|
bool msc;
|
2017-08-08 22:26:42 +02:00
|
|
|
bool useMfc;
|
2016-08-13 10:50:03 +02:00
|
|
|
|
2019-01-05 17:45:07 +01:00
|
|
|
void parseCommand(const std::string &command);
|
2016-08-13 10:50:03 +02:00
|
|
|
void setDefines(std::string defs);
|
2017-09-24 22:36:20 +02:00
|
|
|
void setIncludePaths(const std::string &basepath, const std::list<std::string> &in, std::map<std::string, std::string, cppcheck::stricmp> &variables);
|
2016-08-13 10:50:03 +02:00
|
|
|
};
|
|
|
|
std::list<FileSettings> fileSettings;
|
|
|
|
|
2019-01-31 20:40:15 +01:00
|
|
|
// Cppcheck GUI output
|
|
|
|
struct {
|
|
|
|
std::vector<std::string> pathNames;
|
|
|
|
std::list<std::string> libraries;
|
2019-04-07 12:31:52 +02:00
|
|
|
std::list<std::string> excludedPaths;
|
2019-01-31 20:40:15 +01:00
|
|
|
std::string projectFile;
|
|
|
|
std::string platform;
|
|
|
|
} guiProject;
|
|
|
|
|
2016-12-06 20:02:43 +01:00
|
|
|
void ignorePaths(const std::vector<std::string> &ipaths);
|
2016-08-21 15:57:38 +02:00
|
|
|
void ignoreOtherConfigs(const std::string &cfg);
|
2016-08-20 13:47:25 +02:00
|
|
|
void ignoreOtherPlatforms(cppcheck::Platform::PlatformType platformType);
|
2016-08-13 10:50:03 +02:00
|
|
|
|
2019-01-31 23:52:48 +01:00
|
|
|
Type import(const std::string &filename, Settings *settings=nullptr);
|
2017-12-26 13:04:27 +01:00
|
|
|
protected:
|
2016-08-13 10:50:03 +02:00
|
|
|
void importCompileCommands(std::istream &istr);
|
2019-01-31 20:40:15 +01:00
|
|
|
bool importCppcheckGuiProject(std::istream &istr, Settings *settings);
|
2017-12-26 13:04:27 +01:00
|
|
|
private:
|
2016-08-13 10:50:03 +02:00
|
|
|
void importSln(std::istream &istr, const std::string &path);
|
2017-09-24 22:36:20 +02:00
|
|
|
void importVcxproj(const std::string &filename, std::map<std::string, std::string, cppcheck::stricmp> &variables, const std::string &additionalIncludeDirectories);
|
2018-05-20 18:19:20 +02:00
|
|
|
void importBcb6Prj(const std::string &projectFilename);
|
2016-08-13 10:50:03 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/// @}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
#endif // importprojectH
|