2022-05-13 20:22:16 +08:00
|
|
|
#ifndef COMPILERINFO_H
|
|
|
|
#define COMPILERINFO_H
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QMap>
|
|
|
|
#include <memory>
|
|
|
|
#include <QMutex>
|
|
|
|
#define COMPILER_CLANG "Clang"
|
|
|
|
#define COMPILER_GCC "GCC"
|
2022-07-21 15:28:07 +08:00
|
|
|
#define COMPILER_GCC_UTF8 "GCC_UTF8"
|
2022-05-13 20:22:16 +08:00
|
|
|
|
2022-10-24 19:23:43 +08:00
|
|
|
#define C_CMD_OPT_STD "c_cmd_opt_std"
|
|
|
|
|
2022-05-13 20:22:16 +08:00
|
|
|
#define CC_CMD_OPT_ANSI "cc_cmd_opt_ansi"
|
|
|
|
#define CC_CMD_OPT_NO_ASM "cc_cmd_opt_no_asm"
|
|
|
|
#define CC_CMD_OPT_TRADITIONAL_CPP "cc_cmd_opt_traditional_cpp"
|
|
|
|
|
|
|
|
#define CC_CMD_OPT_ARCH "cc_cmd_opt_arch"
|
|
|
|
#define CC_CMD_OPT_TUNE "cc_cmd_opt_tune"
|
|
|
|
#define CC_CMD_OPT_INSTRUCTION "cc_cmd_opt_instruction"
|
|
|
|
#define CC_CMD_OPT_OPTIMIZE "cc_cmd_opt_optimize"
|
|
|
|
#define CC_CMD_OPT_POINTER_SIZE "cc_cmd_opt_pointer_size"
|
|
|
|
#define CC_CMD_OPT_STD "cc_cmd_opt_std"
|
|
|
|
|
|
|
|
#define CC_CMD_OPT_INHIBIT_ALL_WARNING "cc_cmd_opt_inhibit_all_warning"
|
|
|
|
#define CC_CMD_OPT_WARNING_ALL "cc_cmd_opt_warning_all"
|
|
|
|
#define CC_CMD_OPT_WARNING_EXTRA "cc_cmd_opt_warning_extra"
|
|
|
|
#define CC_CMD_OPT_CHECK_ISO_CONFORMANCE "cc_cmd_opt_check_iso_conformance"
|
|
|
|
#define CC_CMD_OPT_SYNTAX_ONLY "cc_cmd_opt_syntax_only"
|
|
|
|
#define CC_CMD_OPT_WARNING_AS_ERROR "cc_cmd_opt_warning_as_error"
|
|
|
|
#define CC_CMD_OPT_ABORT_ON_ERROR "cc_cmd_opt_abort_on_error"
|
|
|
|
|
|
|
|
#define CC_CMD_OPT_PROFILE_INFO "cc_cmd_opt_profile_info"
|
|
|
|
|
|
|
|
#define LINK_CMD_OPT_LINK_OBJC "link_cmd_opt_link_objc"
|
|
|
|
#define LINK_CMD_OPT_NO_LINK_STDLIB "link_cmd_opt_no_link_stdlib"
|
|
|
|
#define LINK_CMD_OPT_NO_CONSOLE "link_cmd_opt_no_console"
|
|
|
|
#define LINK_CMD_OPT_STRIP_EXE "link_cmd_opt_strip_exe"
|
|
|
|
#define CC_CMD_OPT_DEBUG_INFO "cc_cmd_opt_debug_info"
|
|
|
|
|
|
|
|
#define CC_CMD_OPT_VERBOSE_ASM "cc_cmd_opt_verbose_asm"
|
|
|
|
#define CC_CMD_OPT_ONLY_GEN_ASM_CODE "cc_cmd_opt_only_gen_asm_code"
|
2022-05-14 16:43:59 +08:00
|
|
|
#define CC_CMD_OPT_STOP_AFTER_PREPROCESSING "cc_cmd_opt_stop_after_preprocessing"
|
2022-05-13 20:22:16 +08:00
|
|
|
#define CC_CMD_OPT_USE_PIPE "cc_cmd_opt_use_pipe"
|
|
|
|
|
|
|
|
#define COMPILER_OPTION_ON "on"
|
|
|
|
|
2022-10-30 11:58:42 +08:00
|
|
|
enum class CompilerSetType {
|
|
|
|
RELEASE,
|
|
|
|
DEBUG,
|
|
|
|
PROFILING
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class CompilerType {
|
|
|
|
GCC,
|
|
|
|
GCC_UTF8,
|
2022-12-13 15:58:27 +08:00
|
|
|
Clang,
|
|
|
|
Unknown
|
2022-10-30 11:58:42 +08:00
|
|
|
};
|
|
|
|
|
2022-05-13 20:22:16 +08:00
|
|
|
using CompileOptionChoiceList = QList<QPair<QString,QString>>;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
QString key;
|
|
|
|
QString name; // "Generate debugging info"
|
|
|
|
QString section; // "C options"
|
|
|
|
bool isC;
|
|
|
|
bool isCpp; // True (C++ option?) - can be both C and C++ option...
|
|
|
|
bool isLinker; // Is it a linker param
|
|
|
|
QString setting; // "-g3"
|
|
|
|
CompileOptionChoiceList choices; // replaces "Yes/No" standard choices (max 30 different choices)
|
|
|
|
} CompilerOption;
|
|
|
|
|
|
|
|
using PCompilerOption = std::shared_ptr<CompilerOption>;
|
|
|
|
|
2022-05-14 11:21:59 +08:00
|
|
|
using CompilerOptionMap=QMap<QString,PCompilerOption>;
|
2022-05-13 20:22:16 +08:00
|
|
|
|
|
|
|
class CompilerInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CompilerInfo(const QString& name);
|
2022-05-14 11:21:59 +08:00
|
|
|
const QList<PCompilerOption> &compilerOptions() const;
|
2022-05-13 20:22:16 +08:00
|
|
|
const QString &name() const;
|
|
|
|
PCompilerOption getCompilerOption(const QString& key) const;
|
2022-05-14 11:21:59 +08:00
|
|
|
bool hasCompilerOption(const QString& key) const;
|
2022-05-13 20:22:16 +08:00
|
|
|
|
|
|
|
virtual bool supportConvertingCharset()=0;
|
2022-05-15 17:14:22 +08:00
|
|
|
virtual bool forceUTF8InDebugger()=0;
|
2022-10-30 11:58:42 +08:00
|
|
|
virtual bool forceUTF8InMakefile()=0;
|
2022-05-13 20:22:16 +08:00
|
|
|
protected:
|
|
|
|
void addOption(const QString& key,
|
|
|
|
const QString& name,
|
|
|
|
const QString section,
|
|
|
|
bool isC,
|
|
|
|
bool isCpp,
|
|
|
|
bool isLinker,
|
|
|
|
const QString& setting,
|
|
|
|
const CompileOptionChoiceList& choices = CompileOptionChoiceList());
|
2022-05-14 11:21:59 +08:00
|
|
|
void init();
|
2022-05-13 20:22:16 +08:00
|
|
|
virtual void prepareCompilerOptions();
|
|
|
|
protected:
|
|
|
|
CompilerOptionMap mCompilerOptions;
|
2022-05-14 11:21:59 +08:00
|
|
|
QList<PCompilerOption> mCompilerOptionList;
|
2022-05-13 20:22:16 +08:00
|
|
|
QString mName;
|
|
|
|
};
|
|
|
|
|
|
|
|
using PCompilerInfo = std::shared_ptr<CompilerInfo>;
|
|
|
|
|
|
|
|
class CompilerInfoManager;
|
|
|
|
using PCompilerInfoManager = std::shared_ptr<CompilerInfoManager>;
|
|
|
|
|
|
|
|
class CompilerInfoManager {
|
|
|
|
public:
|
2022-05-14 11:21:59 +08:00
|
|
|
CompilerInfoManager();
|
2022-10-30 11:58:42 +08:00
|
|
|
static PCompilerInfo getInfo(CompilerType compilerType);
|
|
|
|
static bool hasCompilerOption(CompilerType compilerType, const QString& optKey);
|
|
|
|
static PCompilerOption getCompilerOption(CompilerType compilerType, const QString& optKey);
|
|
|
|
static QList<PCompilerOption> getCompilerOptions(CompilerType compilerType);
|
|
|
|
static bool supportCovertingCharset(CompilerType compilerType);
|
|
|
|
static bool forceUTF8InDebugger(CompilerType compilerType);
|
2022-05-13 20:22:16 +08:00
|
|
|
static PCompilerInfoManager getInstance();
|
2022-10-30 11:58:42 +08:00
|
|
|
static void addInfo(CompilerType compilerType, PCompilerInfo info);
|
2022-05-13 20:22:16 +08:00
|
|
|
private:
|
|
|
|
static PCompilerInfoManager instance;
|
2022-10-30 11:58:42 +08:00
|
|
|
QMap<CompilerType,PCompilerInfo> mInfos;
|
2022-05-13 20:22:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class ClangCompilerInfo: public CompilerInfo{
|
|
|
|
public:
|
|
|
|
ClangCompilerInfo();
|
2022-05-14 11:21:59 +08:00
|
|
|
bool supportConvertingCharset() override;
|
2022-05-15 17:14:22 +08:00
|
|
|
bool forceUTF8InDebugger() override;
|
2022-10-30 11:58:42 +08:00
|
|
|
bool forceUTF8InMakefile() override;
|
2022-05-13 20:22:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class GCCCompilerInfo: public CompilerInfo{
|
|
|
|
public:
|
|
|
|
GCCCompilerInfo();
|
2022-05-14 11:21:59 +08:00
|
|
|
bool supportConvertingCharset() override;
|
2022-05-15 17:14:22 +08:00
|
|
|
bool forceUTF8InDebugger() override;
|
2022-10-30 11:58:42 +08:00
|
|
|
bool forceUTF8InMakefile() override;
|
2022-05-13 20:22:16 +08:00
|
|
|
};
|
|
|
|
|
2022-07-21 15:28:07 +08:00
|
|
|
class GCCUTF8CompilerInfo: public CompilerInfo{
|
|
|
|
public:
|
|
|
|
GCCUTF8CompilerInfo();
|
|
|
|
bool supportConvertingCharset() override;
|
|
|
|
bool forceUTF8InDebugger() override;
|
2022-10-30 11:58:42 +08:00
|
|
|
bool forceUTF8InMakefile() override;
|
2022-07-21 15:28:07 +08:00
|
|
|
};
|
|
|
|
|
2022-05-13 20:22:16 +08:00
|
|
|
|
|
|
|
|
|
|
|
#endif // COMPILERINFO_H
|