finish: redesign compiler command line arguments
This commit is contained in:
parent
58b7c55cd6
commit
086dfd0865
|
@ -385,7 +385,6 @@ FORMS += \
|
|||
settingsdialog/executorgeneralwidget.ui \
|
||||
settingsdialog/settingsdialog.ui \
|
||||
widgets/custommakefileinfodialog.ui \
|
||||
widgets/compileargumentswidget.ui \
|
||||
widgets/filepropertiesdialog.ui \
|
||||
widgets/infomessagebox.ui \
|
||||
widgets/newclassdialog.ui \
|
||||
|
@ -456,40 +455,40 @@ RESOURCES += \
|
|||
RC_ICONS = images/devcpp.ico images/associations/c.ico images/associations/cpp.ico images/associations/dev.ico images/associations/c.ico images/associations/cpp.ico images/associations/h.ico images/associations/hpp.ico
|
||||
|
||||
# fixed lrelease.prf
|
||||
#qtPrepareTool(QMAKE_LRELEASE, lrelease)
|
||||
qtPrepareTool(QMAKE_LRELEASE, lrelease)
|
||||
|
||||
#isEmpty(LRELEASE_DIR): LRELEASE_DIR = .qm
|
||||
#isEmpty(QM_FILES_RESOURCE_PREFIX): QM_FILES_RESOURCE_PREFIX = i18n
|
||||
isEmpty(LRELEASE_DIR): LRELEASE_DIR = .qm
|
||||
isEmpty(QM_FILES_RESOURCE_PREFIX): QM_FILES_RESOURCE_PREFIX = i18n
|
||||
|
||||
#lrelease.name = lrelease
|
||||
#lrelease.input = TRANSLATIONS EXTRA_TRANSLATIONS
|
||||
#lrelease.output = $$LRELEASE_DIR/${QMAKE_FILE_IN_BASE}.qm
|
||||
#lrelease.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} $$QMAKE_LRELEASE_FLAGS -qm ${QMAKE_FILE_OUT}
|
||||
#silent: lrelease.commands = @echo lrelease ${QMAKE_FILE_IN} && $$lrelease.commands
|
||||
#lrelease.CONFIG = no_link target_predeps
|
||||
#QMAKE_EXTRA_COMPILERS += lrelease
|
||||
lrelease.name = lrelease
|
||||
lrelease.input = TRANSLATIONS EXTRA_TRANSLATIONS
|
||||
lrelease.output = $$LRELEASE_DIR/${QMAKE_FILE_IN_BASE}.qm
|
||||
lrelease.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} $$QMAKE_LRELEASE_FLAGS -qm ${QMAKE_FILE_OUT}
|
||||
silent: lrelease.commands = @echo lrelease ${QMAKE_FILE_IN} && $$lrelease.commands
|
||||
lrelease.CONFIG = no_link target_predeps
|
||||
QMAKE_EXTRA_COMPILERS += lrelease
|
||||
|
||||
#all_translations = $$TRANSLATIONS $$EXTRA_TRANSLATIONS
|
||||
#for (translation, all_translations) {
|
||||
# # mirrors $$LRELEASE_DIR/${QMAKE_FILE_IN_BASE}.qm above
|
||||
# translation = $$basename(translation)
|
||||
# QM_FILES += $$OUT_PWD/$$LRELEASE_DIR/$$replace(translation, \\..*$, .qm)
|
||||
#}
|
||||
all_translations = $$TRANSLATIONS $$EXTRA_TRANSLATIONS
|
||||
for (translation, all_translations) {
|
||||
# mirrors $$LRELEASE_DIR/${QMAKE_FILE_IN_BASE}.qm above
|
||||
translation = $$basename(translation)
|
||||
QM_FILES += $$OUT_PWD/$$LRELEASE_DIR/$$replace(translation, \\..*$, .qm)
|
||||
}
|
||||
|
||||
#qmake_qm_files.files = $$QM_FILES
|
||||
#qmake_qm_files.base = $$OUT_PWD/$$LRELEASE_DIR
|
||||
#qmake_qm_files.prefix = $$QM_FILES_RESOURCE_PREFIX
|
||||
qmake_qm_files.files = $$QM_FILES
|
||||
qmake_qm_files.base = $$OUT_PWD/$$LRELEASE_DIR
|
||||
qmake_qm_files.prefix = $$QM_FILES_RESOURCE_PREFIX
|
||||
|
||||
#iconsets_files.files += $$files(resources/iconsets/*.svg, true)
|
||||
#iconsets_files.files += $$files(resources/iconsets/*.json, true)
|
||||
iconsets_files.files += $$files(resources/iconsets/*.svg, true)
|
||||
iconsets_files.files += $$files(resources/iconsets/*.json, true)
|
||||
|
||||
#theme_files.files += $$files(themes/*.json, false)
|
||||
#theme_files.files += $$files(themes/*.png, false)
|
||||
theme_files.files += $$files(themes/*.json, false)
|
||||
theme_files.files += $$files(themes/*.png, false)
|
||||
|
||||
#colorscheme_files.files += $$files(colorschemes/*.scheme, false)
|
||||
#colorscheme_files.prefix = /colorschemes
|
||||
colorscheme_files.files += $$files(colorschemes/*.scheme, false)
|
||||
colorscheme_files.prefix = /colorschemes
|
||||
|
||||
#RESOURCES += qmake_qm_files
|
||||
#RESOURCES += iconsets_files
|
||||
#RESOURCES += theme_files
|
||||
#RESOURCES += colorscheme_files
|
||||
RESOURCES += qmake_qm_files
|
||||
RESOURCES += iconsets_files
|
||||
RESOURCES += theme_files
|
||||
RESOURCES += colorscheme_files
|
||||
|
|
|
@ -341,15 +341,20 @@ QString Compiler::getCCompileArguments(bool checkSyntax)
|
|||
}
|
||||
|
||||
QMap<QString, QString> compileOptions;
|
||||
if (mProject) {
|
||||
if (mProject && !mProject->options().compilerOptions.isEmpty()) {
|
||||
compileOptions = mProject->options().compilerOptions;
|
||||
} else {
|
||||
compileOptions = compilerSet()->compileOptions();
|
||||
}
|
||||
foreach (const QString& key, compilerSet()->compileOptions()) {
|
||||
PCompilerOption pOption = CompilerInfoManager::getCompilerOption(compilerSet()->CCompiler(), key);
|
||||
foreach (const QString& key, compileOptions.keys()) {
|
||||
if (compileOptions[key]=="")
|
||||
continue;
|
||||
PCompilerOption pOption = CompilerInfoManager::getCompilerOption(compilerSet()->compilerType(), key);
|
||||
if (pOption && pOption->isC && !pOption->isLinker) {
|
||||
result += " " + pOption->setting + compilerSet()->getCompileOptionValue(key);
|
||||
if (pOption->choices.isEmpty())
|
||||
result += " " + pOption->setting;
|
||||
else
|
||||
result += " " + pOption->setting + compilerSet()->getCompileOptionValue(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -374,18 +379,22 @@ QString Compiler::getCppCompileArguments(bool checkSyntax)
|
|||
result += " -fsyntax-only";
|
||||
}
|
||||
QMap<QString, QString> compileOptions;
|
||||
if (mProject) {
|
||||
if (mProject && !mProject->options().compilerOptions.isEmpty()) {
|
||||
compileOptions = mProject->options().compilerOptions;
|
||||
} else {
|
||||
compileOptions = compilerSet()->compileOptions();
|
||||
}
|
||||
foreach (const QString& key, compilerSet()->compileOptions()) {
|
||||
PCompilerOption pOption = CompilerInfoManager::getCompilerOption(compilerSet()->CCompiler(), key);
|
||||
foreach (const QString& key, compileOptions.keys()) {
|
||||
if (compileOptions[key]=="")
|
||||
continue;
|
||||
PCompilerOption pOption = CompilerInfoManager::getCompilerOption(compilerSet()->compilerType(), key);
|
||||
if (pOption && pOption->isCpp && !pOption->isLinker) {
|
||||
result += " " + pOption->setting + compilerSet()->getCompileOptionValue(key);
|
||||
if (pOption->choices.isEmpty())
|
||||
result += " " + pOption->setting;
|
||||
else
|
||||
result += " " + pOption->setting + compilerSet()->getCompileOptionValue(key);
|
||||
}
|
||||
}
|
||||
|
||||
if (compilerSet()->useCustomCompileParams() && !compilerSet()->customCompileParams().isEmpty()) {
|
||||
result += " "+ parseMacros(compilerSet()->customCompileParams());
|
||||
}
|
||||
|
@ -478,18 +487,24 @@ QString Compiler::getLibraryArguments(FileType fileType)
|
|||
//add compiler set link options
|
||||
//options like "-static" must be added after "-lxxx"
|
||||
QMap<QString, QString> compileOptions;
|
||||
if (mProject) {
|
||||
if (mProject && !mProject->options().compilerOptions.isEmpty()) {
|
||||
compileOptions = mProject->options().compilerOptions;
|
||||
} else {
|
||||
compileOptions = compilerSet()->compileOptions();
|
||||
}
|
||||
foreach (const QString& key, compilerSet()->compileOptions()) {
|
||||
PCompilerOption pOption = CompilerInfoManager::getCompilerOption(compilerSet()->CCompiler(), key);
|
||||
if (pOption->isLinker) {
|
||||
result += " " + pOption->setting + compilerSet()->getCompileOptionValue(key);
|
||||
foreach (const QString& key, compileOptions.keys()) {
|
||||
if (compileOptions[key]=="")
|
||||
continue;
|
||||
PCompilerOption pOption = CompilerInfoManager::getCompilerOption(compilerSet()->compilerType(), key);
|
||||
if (pOption && pOption->isLinker) {
|
||||
if (pOption->choices.isEmpty())
|
||||
result += " " + pOption->setting;
|
||||
else
|
||||
result += " " + pOption->setting + compilerSet()->getCompileOptionValue(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add global compiler linker extras
|
||||
if (compilerSet()->useCustomLinkParams() && !compilerSet()->customLinkParams().isEmpty()) {
|
||||
result += " "+compilerSet()->customLinkParams();
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
CompilerInfo::CompilerInfo(const QString &name):
|
||||
mName(name)
|
||||
{
|
||||
prepareCompilerOptions();
|
||||
init();
|
||||
}
|
||||
|
||||
const CompilerOptionMap &CompilerInfo::compilerOptions() const
|
||||
const QList<PCompilerOption> &CompilerInfo::compilerOptions() const
|
||||
{
|
||||
return mCompilerOptions;
|
||||
return mCompilerOptionList;
|
||||
}
|
||||
|
||||
const QString &CompilerInfo::name() const
|
||||
|
@ -22,6 +22,11 @@ PCompilerOption CompilerInfo::getCompilerOption(const QString &key) const
|
|||
return mCompilerOptions.value(key,PCompilerOption());
|
||||
}
|
||||
|
||||
bool CompilerInfo::hasCompilerOption(const QString &key) const
|
||||
{
|
||||
return mCompilerOptions.contains(key);
|
||||
}
|
||||
|
||||
void CompilerInfo::addOption(const QString &key, const QString &name, const QString section, bool isC, bool isCpp, bool isLinker, const QString &setting, const CompileOptionChoiceList &choices)
|
||||
{
|
||||
PCompilerOption pOption = std::make_shared<CompilerOption>();
|
||||
|
@ -34,6 +39,12 @@ void CompilerInfo::addOption(const QString &key, const QString &name, const QStr
|
|||
pOption->setting= setting;
|
||||
pOption->choices = choices;
|
||||
mCompilerOptions.insert(key,pOption);
|
||||
mCompilerOptionList.append(pOption);
|
||||
}
|
||||
|
||||
void CompilerInfo::init()
|
||||
{
|
||||
prepareCompilerOptions();
|
||||
}
|
||||
|
||||
void CompilerInfo::prepareCompilerOptions()
|
||||
|
@ -73,8 +84,8 @@ void CompilerInfo::prepareCompilerOptions()
|
|||
sl.append(QPair<QString,QString>("K8 Rev.E","k8-sse3"));
|
||||
sl.append(QPair<QString,QString>("K10","barcelona"));
|
||||
sl.append(QPair<QString,QString>("Bulldozer","bdver1"));
|
||||
addOption("gcc_cmd_opt_arch", QObject::tr("Optimize for the following machine (-march)"), groupName, true, true, false, "-march=", sl);
|
||||
addOption("gcc_cmd_opt_tune", QObject::tr("Optimize less, while maintaining full compatibility (-tune)"), groupName, true, true, false, "-mtune=", sl);
|
||||
addOption(CC_CMD_OPT_ARCH, QObject::tr("Optimize for the following machine (-march)"), groupName, true, true, false, "-march=", sl);
|
||||
addOption(CC_CMD_OPT_TUNE, QObject::tr("Optimize less, while maintaining full compatibility (-tune)"), groupName, true, true, false, "-mtune=", sl);
|
||||
|
||||
// Enable use of the specific instructions
|
||||
sl.clear();
|
||||
|
@ -93,7 +104,7 @@ void CompilerInfo::prepareCompilerOptions()
|
|||
sl.append(QPair<QString,QString>("FMA4","fma4"));
|
||||
sl.append(QPair<QString,QString>("XOP","xop"));
|
||||
sl.append(QPair<QString,QString>("AES","aes"));
|
||||
addOption("gcc_cmd_opt_instruction",QObject::tr("Enable use of specific instructions (-mx)"), groupName, true, true, false, "-m", sl);
|
||||
addOption(CC_CMD_OPT_INSTRUCTION,QObject::tr("Enable use of specific instructions (-mx)"), groupName, true, true, false, "-m", sl);
|
||||
|
||||
// Optimization
|
||||
sl.clear();
|
||||
|
@ -103,13 +114,13 @@ void CompilerInfo::prepareCompilerOptions()
|
|||
sl.append(QPair<QString,QString>("Highest (fast)","fast"));
|
||||
sl.append(QPair<QString,QString>("Size (s)","s"));
|
||||
sl.append(QPair<QString,QString>("Debug (g)","g"));
|
||||
addOption("gcc_cmd_opt_optimize", QObject::tr("Optimization level (-Ox)"), groupName, true, true, false, "-O", sl);
|
||||
addOption(CC_CMD_OPT_OPTIMIZE, QObject::tr("Optimization level (-Ox)"), groupName, true, true, false, "-O", sl);
|
||||
|
||||
// 32bit/64bit
|
||||
sl.clear();
|
||||
sl.append(QPair<QString,QString>("32bit","32"));
|
||||
sl.append(QPair<QString,QString>("64bit","64"));
|
||||
addOption("gcc_cmd_opt_pointer_size", QObject::tr("Compile with the following pointer size (-mx)"), groupName, true, true, true, "-m", sl);
|
||||
addOption(CC_CMD_OPT_POINTER_SIZE, QObject::tr("Compile with the following pointer size (-mx)"), groupName, true, true, true, "-m", sl);
|
||||
|
||||
// Language Standards
|
||||
sl.clear();
|
||||
|
@ -131,38 +142,44 @@ void CompilerInfo::prepareCompilerOptions()
|
|||
sl.append(QPair<QString,QString>("GNU C++14","gnu++14"));
|
||||
sl.append(QPair<QString,QString>("GNU C++17","gnu++17"));
|
||||
sl.append(QPair<QString,QString>("GNU C++20","gnu++2a"));
|
||||
addOption("gcc_cmd_opt_std", QObject::tr("Language standard (-std)"), groupName, true, true, false, "-std=", sl);
|
||||
addOption(CC_CMD_OPT_STD, QObject::tr("Language standard (-std)"), groupName, true, true, false, "-std=", sl);
|
||||
|
||||
// Warnings
|
||||
groupName = QObject::tr("Warnings");
|
||||
addOption("gcc_cmd_opt_inhibit_all_warning", QObject::tr("Inhibit all warning messages (-w)"), groupName, true, true, false, "-w");
|
||||
addOption("gcc_cmd_opt_warning_all",QObject::tr("Show most warnings (-Wall)"), groupName, true, true, false, "-Wall");
|
||||
addOption("gcc_cmd_opt_warning_extra",QObject::tr("Show some more warnings (-Wextra)"), groupName, true, true, false, "-Wextra");
|
||||
addOption("gcc_cmd_opt_check_iso_conformance", QObject::tr("Check ISO C/C++/C++0x conformance (-pedantic)"), groupName, true, true, false, "-pedantic");
|
||||
addOption("gcc_cmd_opt_syntax_only", QObject::tr("Only check the code for syntax errors (-fsyntax-only)"), groupName, true, true, false, "-fsyntax-only");
|
||||
addOption("gcc_cmd_opt_warning_as_error", QObject::tr("Make all warnings into errors (-Werror)"), groupName, true, true, false, "-Werror");
|
||||
addOption("gcc_cmd_opt_abort_on_error", QObject::tr("Abort compilation on first error (-Wfatal-errors)"), groupName, true, true, false, "-Wfatal-errors");
|
||||
addOption(CC_CMD_OPT_INHIBIT_ALL_WARNING, QObject::tr("Inhibit all warning messages (-w)"), groupName, true, true, false, "-w");
|
||||
addOption(CC_CMD_OPT_WARNING_ALL,QObject::tr("Show most warnings (-Wall)"), groupName, true, true, false, "-Wall");
|
||||
addOption(CC_CMD_OPT_WARNING_EXTRA,QObject::tr("Show some more warnings (-Wextra)"), groupName, true, true, false, "-Wextra");
|
||||
addOption(CC_CMD_OPT_CHECK_ISO_CONFORMANCE, QObject::tr("Check ISO C/C++/C++0x conformance (-pedantic)"), groupName, true, true, false, "-pedantic");
|
||||
addOption(CC_CMD_OPT_SYNTAX_ONLY, QObject::tr("Only check the code for syntax errors (-fsyntax-only)"), groupName, true, true, false, "-fsyntax-only");
|
||||
addOption(CC_CMD_OPT_WARNING_AS_ERROR, QObject::tr("Make all warnings into errors (-Werror)"), groupName, true, true, false, "-Werror");
|
||||
addOption(CC_CMD_OPT_ABORT_ON_ERROR , QObject::tr("Abort compilation on first error (-Wfatal-errors)"), groupName, true, true, false, "-Wfatal-errors");
|
||||
|
||||
// Profile
|
||||
groupName = QObject::tr("Profile");
|
||||
addOption("gcc_cmd_opt_profile_info",QObject::tr("Generate profiling info for analysis (-pg)"), groupName, true, true, true, "-pg");
|
||||
addOption(CC_CMD_OPT_PROFILE_INFO, QObject::tr("Generate profiling info for analysis (-pg)"), groupName, true, true, true, "-pg");
|
||||
|
||||
// Linker
|
||||
groupName = QObject::tr("Linker");
|
||||
addOption("linker_cmd_opt_link_objc", QObject::tr("Link an Objective C program (-lobjc)"), groupName, false, false, true, "-lobjc");
|
||||
addOption("linker_cmd_opt_no_link_stdlib",QObject::tr("Do not use standard system libraries (-nostdlib)"), groupName, false, false, true, "-nostdlib");
|
||||
addOption("linker_cmd_opt_no_console", QObject::tr("Do not create a console window (-mwindows)"), groupName,false, false, true, "-mwindows");
|
||||
addOption("linker_cmd_opt_strip_exe", QObject::tr("Strip executable (-s)"), groupName, false, false, true, "-s");
|
||||
addOption("cc_cmd_opt_debug_info", QObject::tr("Generate debugging information (-g3)"), groupName, true, true, false, "-g3");
|
||||
addOption(LINK_CMD_OPT_LINK_OBJC, QObject::tr("Link an Objective C program (-lobjc)"), groupName, false, false, true, "-lobjc");
|
||||
addOption(LINK_CMD_OPT_NO_LINK_STDLIB,QObject::tr("Do not use standard system libraries (-nostdlib)"), groupName, false, false, true, "-nostdlib");
|
||||
addOption(LINK_CMD_OPT_NO_CONSOLE, QObject::tr("Do not create a console window (-mwindows)"), groupName,false, false, true, "-mwindows");
|
||||
addOption(LINK_CMD_OPT_STRIP_EXE, QObject::tr("Strip executable (-s)"), groupName, false, false, true, "-s");
|
||||
addOption(CC_CMD_OPT_DEBUG_INFO, QObject::tr("Generate debugging information (-g3)"), groupName, true, true, false, "-g3");
|
||||
|
||||
// Output
|
||||
groupName = QObject::tr("Output");
|
||||
addOption("cc_cmd_opt_verbose_asm", QObject::tr("Put comments in generated assembly code (-fverbose-asm)"), groupName, true, true, false, "-fverbose-asm");
|
||||
addOption("cc_cmd_opt_only_gen_asm_code", QObject::tr("Do not assemble, compile and generate the assemble code (-S)"), groupName, true, true, false, "-S");
|
||||
addOption("cc_cmd_opt_use_pipe", QObject::tr("Use pipes instead of temporary files during compilation (-pipe)"), groupName, true, true, false, "-pipe");
|
||||
addOption(CC_CMD_OPT_VERBOSE_ASM, QObject::tr("Put comments in generated assembly code (-fverbose-asm)"), groupName, true, true, false, "-fverbose-asm");
|
||||
addOption(CC_CMD_OPT_ONLY_GEN_ASM_CODE, QObject::tr("Do not assemble, compile and generate the assemble code (-S)"), groupName, true, true, false, "-S");
|
||||
addOption(CC_CMD_OPT_USE_PIPE, QObject::tr("Use pipes instead of temporary files during compilation (-pipe)"), groupName, true, true, false, "-pipe");
|
||||
|
||||
}
|
||||
|
||||
CompilerInfoManager::CompilerInfoManager()
|
||||
{
|
||||
mInfos.insert(COMPILER_CLANG, std::make_shared<ClangCompilerInfo>());
|
||||
mInfos.insert(COMPILER_GCC, std::make_shared<GCCCompilerInfo>());
|
||||
}
|
||||
|
||||
PCompilerInfo CompilerInfoManager::getInfo(const QString &compilerType)
|
||||
{
|
||||
return getInstance()->mInfos.value(compilerType,PCompilerInfo());
|
||||
|
@ -173,7 +190,7 @@ bool CompilerInfoManager::hasCompilerOption(const QString &compilerType, const Q
|
|||
PCompilerInfo pInfo = getInfo(compilerType);
|
||||
if (!pInfo)
|
||||
return false;
|
||||
return pInfo->compilerOptions().contains(optKey);
|
||||
return pInfo->hasCompilerOption(optKey);
|
||||
}
|
||||
|
||||
PCompilerOption CompilerInfoManager::getCompilerOption(const QString &compilerType, const QString &optKey)
|
||||
|
@ -181,14 +198,14 @@ PCompilerOption CompilerInfoManager::getCompilerOption(const QString &compilerTy
|
|||
PCompilerInfo pInfo = getInfo(compilerType);
|
||||
if (!pInfo)
|
||||
return PCompilerOption();
|
||||
return pInfo->compilerOptions().value(optKey,PCompilerOption());
|
||||
return pInfo->getCompilerOption(optKey);
|
||||
}
|
||||
|
||||
CompilerOptionMap CompilerInfoManager::getCompilerOptions(const QString &compilerType)
|
||||
QList<PCompilerOption> CompilerInfoManager::getCompilerOptions(const QString &compilerType)
|
||||
{
|
||||
PCompilerInfo pInfo = getInfo(compilerType);
|
||||
if (!pInfo)
|
||||
return CompilerOptionMap();
|
||||
return QList<PCompilerOption>();
|
||||
return pInfo->compilerOptions();
|
||||
}
|
||||
|
||||
|
@ -200,6 +217,8 @@ bool CompilerInfoManager::supportCovertingCharset(const QString &compilerType)
|
|||
return pInfo->supportConvertingCharset();
|
||||
}
|
||||
|
||||
PCompilerInfoManager CompilerInfoManager::instance;
|
||||
|
||||
PCompilerInfoManager CompilerInfoManager::getInstance()
|
||||
{
|
||||
if (!instance) {
|
||||
|
@ -215,7 +234,6 @@ void CompilerInfoManager::addInfo(const QString &name, PCompilerInfo info)
|
|||
|
||||
ClangCompilerInfo::ClangCompilerInfo():CompilerInfo(COMPILER_CLANG)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool ClangCompilerInfo::supportConvertingCharset()
|
||||
|
@ -225,7 +243,6 @@ bool ClangCompilerInfo::supportConvertingCharset()
|
|||
|
||||
GCCCompilerInfo::GCCCompilerInfo():CompilerInfo(COMPILER_GCC)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool GCCCompilerInfo::supportConvertingCharset()
|
||||
|
|
|
@ -56,15 +56,16 @@ typedef struct {
|
|||
|
||||
using PCompilerOption = std::shared_ptr<CompilerOption>;
|
||||
|
||||
using CompilerOptionMap=QMap<QString,std::shared_ptr<CompilerOption>>;
|
||||
using CompilerOptionMap=QMap<QString,PCompilerOption>;
|
||||
|
||||
class CompilerInfo
|
||||
{
|
||||
public:
|
||||
CompilerInfo(const QString& name);
|
||||
const CompilerOptionMap &compilerOptions() const;
|
||||
const QList<PCompilerOption> &compilerOptions() const;
|
||||
const QString &name() const;
|
||||
PCompilerOption getCompilerOption(const QString& key) const;
|
||||
bool hasCompilerOption(const QString& key) const;
|
||||
|
||||
virtual bool supportConvertingCharset()=0;
|
||||
protected:
|
||||
|
@ -76,10 +77,11 @@ protected:
|
|||
bool isLinker,
|
||||
const QString& setting,
|
||||
const CompileOptionChoiceList& choices = CompileOptionChoiceList());
|
||||
|
||||
void init();
|
||||
virtual void prepareCompilerOptions();
|
||||
protected:
|
||||
CompilerOptionMap mCompilerOptions;
|
||||
QList<PCompilerOption> mCompilerOptionList;
|
||||
QString mName;
|
||||
};
|
||||
|
||||
|
@ -90,15 +92,15 @@ using PCompilerInfoManager = std::shared_ptr<CompilerInfoManager>;
|
|||
|
||||
class CompilerInfoManager {
|
||||
public:
|
||||
CompilerInfoManager();
|
||||
static PCompilerInfo getInfo(const QString& compilerType);
|
||||
static bool hasCompilerOption(const QString& compilerType, const QString& optKey);
|
||||
static PCompilerOption getCompilerOption(const QString& compilerType, const QString& optKey);
|
||||
static CompilerOptionMap getCompilerOptions(const QString& compilerType);
|
||||
static QList<PCompilerOption> getCompilerOptions(const QString& compilerType);
|
||||
static bool supportCovertingCharset(const QString& compilerType);
|
||||
static PCompilerInfoManager getInstance();
|
||||
static void addInfo(const QString& name, PCompilerInfo info);
|
||||
private:
|
||||
CompilerInfoManager();
|
||||
static PCompilerInfoManager instance;
|
||||
QMap<QString,PCompilerInfo> mInfos;
|
||||
};
|
||||
|
@ -108,21 +110,13 @@ extern PCompilerInfoManager pCompilerInfoManager;
|
|||
class ClangCompilerInfo: public CompilerInfo{
|
||||
public:
|
||||
ClangCompilerInfo();
|
||||
|
||||
// CompilerInfo interface
|
||||
protected:
|
||||
void prepareCompilerOptions() Q_DECL_OVERRIDE;
|
||||
bool supportConvertingCharset() Q_DECL_OVERRIDE;
|
||||
bool supportConvertingCharset() override;
|
||||
};
|
||||
|
||||
class GCCCompilerInfo: public CompilerInfo{
|
||||
public:
|
||||
GCCCompilerInfo();
|
||||
|
||||
// CompilerInfo interface
|
||||
protected:
|
||||
void prepareCompilerOptions() Q_DECL_OVERRIDE;
|
||||
bool supportConvertingCharset() Q_DECL_OVERRIDE;
|
||||
bool supportConvertingCharset() override;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1649,8 +1649,8 @@ void MainWindow::debug()
|
|||
switch(getCompileTarget()) {
|
||||
case CompileTarget::Project:
|
||||
// Check if we enabled proper options
|
||||
debugEnabled = mProject->getCompilerOption("-g3")!='0';
|
||||
stripEnabled = mProject->getCompilerOption("-s")!='0';
|
||||
debugEnabled = mProject->getCompileOption(CC_CMD_OPT_DEBUG_INFO) == COMPILER_OPTION_ON;
|
||||
stripEnabled = mProject->getCompileOption(LINK_CMD_OPT_STRIP_EXE) == COMPILER_OPTION_ON;
|
||||
// Ask the user if he wants to enable debugging...
|
||||
if (((!debugEnabled) || stripEnabled) &&
|
||||
(QMessageBox::question(this,
|
||||
|
@ -1658,8 +1658,8 @@ void MainWindow::debug()
|
|||
tr("You have not enabled debugging info (-g3) and/or stripped it from the executable (-s) in Compiler Options.<BR /><BR />Do you want to correct this now?")
|
||||
) == QMessageBox::Yes)) {
|
||||
// Enable debugging, disable stripping
|
||||
mProject->setCompilerOption("-g3",'1');
|
||||
mProject->setCompilerOption("-s",'0');
|
||||
mProject->setCompileOption(CC_CMD_OPT_DEBUG_INFO,COMPILER_OPTION_ON);
|
||||
mProject->setCompileOption(LINK_CMD_OPT_STRIP_EXE,"");
|
||||
|
||||
// Save changes to compiler set
|
||||
mProject->saveOptions();
|
||||
|
@ -1739,8 +1739,8 @@ void MainWindow::debug()
|
|||
break;
|
||||
case CompileTarget::File: {
|
||||
// Check if we enabled proper options
|
||||
debugEnabled = compilerSet->getOptionValue("-g3")!='0';
|
||||
stripEnabled = compilerSet->getOptionValue("-s")!='0';
|
||||
debugEnabled = compilerSet->getCompileOptionValue(CC_CMD_OPT_DEBUG_INFO) == COMPILER_OPTION_ON;
|
||||
stripEnabled = compilerSet->getCompileOptionValue(LINK_CMD_OPT_STRIP_EXE) == COMPILER_OPTION_ON;
|
||||
// Ask the user if he wants to enable debugging...
|
||||
if (((!debugEnabled) || stripEnabled) &&
|
||||
(QMessageBox::question(this,
|
||||
|
@ -1748,8 +1748,8 @@ void MainWindow::debug()
|
|||
tr("You have not enabled debugging info (-g3) and/or stripped it from the executable (-s) in Compiler Options.<BR /><BR />Do you want to correct this now?")
|
||||
) == QMessageBox::Yes)) {
|
||||
// Enable debugging, disable stripping
|
||||
compilerSet->setOption("-g3",'1');
|
||||
compilerSet->setOption("-s",'0');
|
||||
compilerSet->setCompileOption(CC_CMD_OPT_DEBUG_INFO,COMPILER_OPTION_ON);
|
||||
compilerSet->unsetCompileOption(LINK_CMD_OPT_STRIP_EXE);
|
||||
|
||||
// Save changes to compiler set
|
||||
pSettings->compilerSets().saveSet(pSettings->compilerSets().defaultIndex());
|
||||
|
|
|
@ -726,6 +726,11 @@ bool Project::setCompileOption(const QString &key, const QString &value)
|
|||
return true;
|
||||
}
|
||||
|
||||
QString Project::getCompileOption(const QString &key) const
|
||||
{
|
||||
return mOptions.compilerOptions.value(key,"");
|
||||
}
|
||||
|
||||
void Project::updateFolders()
|
||||
{
|
||||
mFolders.clear();
|
||||
|
|
|
@ -212,6 +212,7 @@ public:
|
|||
void associateEditorToUnit(Editor* editor, PProjectUnit unit);
|
||||
// bool setCompileOption(const QString &key, int valIndex);
|
||||
bool setCompileOption(const QString &key, const QString &value);
|
||||
QString getCompileOption(const QString &key) const;
|
||||
|
||||
void updateFolders();
|
||||
void updateNodeIndexes();
|
||||
|
|
|
@ -1527,6 +1527,11 @@ void Settings::CompilerSet::unsetCompileOption(const QString &key)
|
|||
mCompileOptions.remove(key);
|
||||
}
|
||||
|
||||
void Settings::CompilerSet::setCompileOptions(const QMap<QString, QString> options)
|
||||
{
|
||||
mCompileOptions=options;
|
||||
}
|
||||
|
||||
QString Settings::CompilerSet::getCompileOptionValue(const QString &key)
|
||||
{
|
||||
return mCompileOptions.value(key,QString());
|
||||
|
@ -2721,19 +2726,15 @@ Settings::PCompilerSet Settings::CompilerSets::loadSet(int index)
|
|||
pSet->setResourceCompiler(loadPath("windres"));
|
||||
pSet->setProfiler(loadPath("profiler"));
|
||||
|
||||
// Save option string
|
||||
QByteArray iniOptions = mSettings->mSettings.value("Options","").toByteArray();
|
||||
if (!iniOptions.isEmpty())
|
||||
pSet->setIniOptions(iniOptions);
|
||||
else {
|
||||
foreach (const QString &optionKey, mSettings->mSettings.allKeys()) {
|
||||
if (CompilerInfoManager::hasCompilerOption(pSet->compilerType(),optionKey)) {
|
||||
pSet->setCompileOption(optionKey, mSettings->mSettings.value(optionKey).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
pSet->setDumpMachine(mSettings->mSettings.value("DumpMachine").toString());
|
||||
pSet->setVersion(mSettings->mSettings.value("Version").toString());
|
||||
pSet->setType(mSettings->mSettings.value("Type").toString());
|
||||
pSet->setName(mSettings->mSettings.value("Name").toString());
|
||||
pSet->setTarget(mSettings->mSettings.value("Target").toString());
|
||||
pSet->setCompilerType(mSettings->mSettings.value("CompilerType").toString());
|
||||
pSet->setCompilerSetType(mSettings->mSettings.value("CompilerSetType").toInt());
|
||||
|
||||
// Save extra 'general' options
|
||||
// Load extra 'general' options
|
||||
pSet->setUseCustomCompileParams(mSettings->mSettings.value("useCustomCompileParams", false).toBool());
|
||||
pSet->setCustomCompileParams(mSettings->mSettings.value("customCompileParams").toString());
|
||||
pSet->setUseCustomLinkParams(mSettings->mSettings.value("useCustomLinkParams", false).toBool());
|
||||
|
@ -2745,13 +2746,17 @@ Settings::PCompilerSet Settings::CompilerSets::loadSet(int index)
|
|||
pSet->setExecCharset(ENCODING_SYSTEM_DEFAULT);
|
||||
}
|
||||
|
||||
pSet->setDumpMachine(mSettings->mSettings.value("DumpMachine").toString());
|
||||
pSet->setVersion(mSettings->mSettings.value("Version").toString());
|
||||
pSet->setType(mSettings->mSettings.value("Type").toString());
|
||||
pSet->setName(mSettings->mSettings.value("Name").toString());
|
||||
pSet->setTarget(mSettings->mSettings.value("Target").toString());
|
||||
pSet->setCompilerType(mSettings->mSettings.value("CompilerType").toString());
|
||||
pSet->setCompilerSetType(mSettings->mSettings.value("CompilerSetType").toInt());
|
||||
// Load options
|
||||
QByteArray iniOptions = mSettings->mSettings.value("Options","").toByteArray();
|
||||
if (!iniOptions.isEmpty())
|
||||
pSet->setIniOptions(iniOptions);
|
||||
else {
|
||||
foreach (const QString &optionKey, mSettings->mSettings.allKeys()) {
|
||||
if (CompilerInfoManager::hasCompilerOption(pSet->compilerType(),optionKey)) {
|
||||
pSet->setCompileOption(optionKey, mSettings->mSettings.value(optionKey).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Paths
|
||||
loadPathList("Bins",pSet->binDirs());
|
||||
|
@ -2773,37 +2778,36 @@ void Settings::CompilerSets::prepareCompatibleIndex()
|
|||
{
|
||||
|
||||
//old settings compatibility, don't reorder, add or remove items
|
||||
mCompilerCompatibleIndex.append("gcc_cmd_opt_ansi");
|
||||
mCompilerCompatibleIndex.append("gcc_cmd_opt_no_asm");
|
||||
mCompilerCompatibleIndex.append("gcc_cmd_opt_traditional_cpp");
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_ANSI);
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_NO_ASM "gcc_cmd_opt_no_asm");
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_TRADITIONAL_CPP);
|
||||
|
||||
mCompilerCompatibleIndex.append("gcc_cmd_opt_arch");
|
||||
mCompilerCompatibleIndex.append("gcc_cmd_opt_tune");
|
||||
mCompilerCompatibleIndex.append("gcc_cmd_opt_instruction");
|
||||
mCompilerCompatibleIndex.append("gcc_cmd_opt_optimize");
|
||||
mCompilerCompatibleIndex.append("gcc_cmd_opt_pointer_size");
|
||||
mCompilerCompatibleIndex.append("gcc_cmd_opt_std");
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_ARCH);
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_TUNE);
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_INSTRUCTION);
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_OPTIMIZE);
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_POINTER_SIZE);
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_STD);
|
||||
|
||||
mCompilerCompatibleIndex.append("gcc_cmd_opt_inhibit_all_warning");
|
||||
mCompilerCompatibleIndex.append("gcc_cmd_opt_warning_all");
|
||||
mCompilerCompatibleIndex.append("gcc_cmd_opt_warning_extra");
|
||||
mCompilerCompatibleIndex.append("gcc_cmd_opt_check_iso_conformance");
|
||||
mCompilerCompatibleIndex.append("gcc_cmd_opt_syntax_only");
|
||||
mCompilerCompatibleIndex.append("gcc_cmd_opt_warning_as_error");
|
||||
mCompilerCompatibleIndex.append("gcc_cmd_opt_abort_on_error");
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_INHIBIT_ALL_WARNING);
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_WARNING_ALL);
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_WARNING_EXTRA);
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_CHECK_ISO_CONFORMANCE);
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_SYNTAX_ONLY);
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_WARNING_AS_ERROR);
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_ABORT_ON_ERROR);
|
||||
|
||||
mCompilerCompatibleIndex.append("gcc_cmd_opt_profile_info");
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_PROFILE_INFO);
|
||||
|
||||
mCompilerCompatibleIndex.append("linker_cmd_opt_link_objc");
|
||||
mCompilerCompatibleIndex.append("linker_cmd_opt_no_link_stdlib");
|
||||
mCompilerCompatibleIndex.append("linker_cmd_opt_no_console");
|
||||
mCompilerCompatibleIndex.append("linker_cmd_opt_strip_exe");
|
||||
mCompilerCompatibleIndex.append("cc_cmd_opt_debug_info");
|
||||
|
||||
mCompilerCompatibleIndex.append("cc_cmd_opt_verbose_asm");
|
||||
mCompilerCompatibleIndex.append("cc_cmd_opt_only_gen_asm_code");
|
||||
mCompilerCompatibleIndex.append("cc_cmd_opt_use_pipe");
|
||||
mCompilerCompatibleIndex.append(LINK_CMD_OPT_LINK_OBJC);
|
||||
mCompilerCompatibleIndex.append(LINK_CMD_OPT_NO_LINK_STDLIB);
|
||||
mCompilerCompatibleIndex.append(LINK_CMD_OPT_NO_CONSOLE);
|
||||
mCompilerCompatibleIndex.append(LINK_CMD_OPT_STRIP_EXE);
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_DEBUG_INFO);
|
||||
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_VERBOSE_ASM);
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_ONLY_GEN_ASM_CODE);
|
||||
mCompilerCompatibleIndex.append(CC_CMD_OPT_USE_PIPE);
|
||||
}
|
||||
|
||||
QString Settings::CompilerSets::getKeyFromCompilerCompatibleIndex(int idx) const
|
||||
|
|
|
@ -1164,6 +1164,7 @@ public:
|
|||
bool setCompileOption(const QString& key, int valIndex);
|
||||
bool setCompileOption(const QString& key, const QString& value);
|
||||
void unsetCompileOption(const QString& key);
|
||||
void setCompileOptions(const QMap<QString, QString> options);
|
||||
|
||||
QString getCompileOptionValue(const QString& key);
|
||||
|
||||
|
@ -1220,7 +1221,7 @@ public:
|
|||
bool autoAddCharsetParams() const;
|
||||
void setAutoAddCharsetParams(bool value);
|
||||
|
||||
//Converts options to and from memory format
|
||||
//Converts options to and from memory format ( for old settings compatibility)
|
||||
void setIniOptions(const QByteArray& value);
|
||||
|
||||
//load hard defines
|
||||
|
|
|
@ -69,61 +69,6 @@ void CompilerSetOptionWidget::init()
|
|||
SettingsWidget::init();
|
||||
}
|
||||
|
||||
void resetOptionTabs(Settings::PCompilerSet pSet,QTabWidget* pTab)
|
||||
{
|
||||
while (pTab->count()>0) {
|
||||
QWidget* p=pTab->widget(0);
|
||||
if (p!=nullptr) {
|
||||
pTab->removeTab(0);
|
||||
p->setParent(nullptr);
|
||||
delete p;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (PCompilerOption pOption, pSettings->compilerSets().compilerOptions().values()) {
|
||||
QWidget* pWidget = nullptr;
|
||||
for (int i=0;i<pTab->count();i++) {
|
||||
if (pOption->section == pTab->tabText(i)) {
|
||||
pWidget = pTab->widget(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pWidget == nullptr) {
|
||||
pWidget = new QWidget();
|
||||
pTab->addTab(pWidget,pOption->section);
|
||||
pWidget->setLayout(new QGridLayout());
|
||||
}
|
||||
QGridLayout *pLayout = static_cast<QGridLayout*>(pWidget->layout());
|
||||
int row = pLayout->rowCount();
|
||||
QLabel* keyLabel = new QLabel(pOption->key,pWidget);
|
||||
keyLabel->setVisible(false);
|
||||
pLayout->addWidget(keyLabel,row,0);
|
||||
if (pOption->choices.isEmpty()) {
|
||||
QCheckBox* pCheckbox = new QCheckBox(pWidget);
|
||||
pCheckbox->setText(pOption->name);
|
||||
pCheckbox->setChecked(!pSet->getCompileOptionValue(pOption->key).isEmpty());
|
||||
pLayout->addWidget(pCheckbox,row,1);
|
||||
} else {
|
||||
pLayout->addWidget(new QLabel(pOption->name,pWidget),row,1);
|
||||
QComboBox* pCombo = new QComboBox(pWidget);
|
||||
pCombo->addItem("","");
|
||||
for (int i=0;i<pOption->choices.length();i++) {
|
||||
const QPair<QString,QString> &choice = pOption->choices[i];
|
||||
pCombo->addItem(choice.first,choice.second);
|
||||
if (pSet->getCompileOptionValue(pOption->key) == choice.second)
|
||||
pCombo->setCurrentIndex(i);
|
||||
}
|
||||
pLayout->addWidget(pCombo,row,2);
|
||||
}
|
||||
}
|
||||
for (int i=0;i<pTab->count();i++) {
|
||||
QWidget* pWidget = pTab->widget(i);
|
||||
QGridLayout *pLayout = static_cast<QGridLayout*>(pWidget->layout());
|
||||
int row = pLayout->rowCount();
|
||||
QSpacerItem* horizontalSpacer = new QSpacerItem(10, 100, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
pLayout->addItem(horizontalSpacer,row,0);
|
||||
}
|
||||
}
|
||||
|
||||
static void loadCompilerSetSettings(Settings::PCompilerSet pSet, Ui::CompilerSetOptionWidget* ui) {
|
||||
ui->chkAutoAddCharset->setEnabled(pSet->compilerType() != COMPILER_CLANG);
|
||||
|
@ -142,7 +87,8 @@ static void loadCompilerSetSettings(Settings::PCompilerSet pSet, Ui::CompilerSet
|
|||
ui->chkAutoAddCharset->setChecked(pSet->autoAddCharsetParams());
|
||||
ui->chkStaticLink->setChecked(pSet->staticLink());
|
||||
//rest tabs in the options widget
|
||||
resetOptionTabs(pSet,ui->optionTabs);
|
||||
|
||||
ui->optionTabs->resetUI(pSet,pSet->compileOptions());
|
||||
|
||||
ui->txtCCompiler->setText(pSet->CCompiler());
|
||||
ui->txtCppCompiler->setText(pSet->cppCompiler());
|
||||
|
@ -260,35 +206,8 @@ void CompilerSetOptionWidget::saveCurrentCompilerSet()
|
|||
}
|
||||
|
||||
//read values in the options widget
|
||||
QTabWidget* pTab = ui->optionTabs;
|
||||
for (int i=0;i<pTab->count();i++) {
|
||||
QString section = pTab->tabText(i);
|
||||
QWidget* pWidget = pTab->widget(i);
|
||||
QGridLayout* pLayout = static_cast<QGridLayout*>(pWidget->layout());
|
||||
if (pLayout != nullptr) {
|
||||
for (int j=1;j<pLayout->rowCount()-1;j++) {
|
||||
QString key = static_cast<QLabel *>(pLayout->itemAtPosition(j,0)->widget())->text();
|
||||
PCompilerOption pOption = pSettings->compilerSets().getCompilerOption(key);
|
||||
if (!pOption)
|
||||
continue;
|
||||
if (pOption->choices.isEmpty()) {
|
||||
QCheckBox* pCheckbox = static_cast<QCheckBox *>(pLayout->itemAtPosition(j,1)->widget());
|
||||
if (pCheckbox->isChecked()) {
|
||||
pSet->setCompileOption(key,"");
|
||||
} else {
|
||||
pSet->unsetCompileOption(key);
|
||||
}
|
||||
} else {
|
||||
QComboBox* pCombo = static_cast<QComboBox *>(pLayout->itemAtPosition(j,2)->widget());
|
||||
if (!pCombo->currentData().toString().isEmpty()) {
|
||||
pSet->setCompileOption(key,pCombo->currentData().toString());
|
||||
} else {
|
||||
pSet->unsetCompileOption(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pSet->setCompileOptions(ui->optionTabs->arguments(false));
|
||||
|
||||
}
|
||||
|
||||
void CompilerSetOptionWidget::on_btnFindCompilers_pressed()
|
||||
|
|
|
@ -198,7 +198,7 @@
|
|||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="optionTabs">
|
||||
<widget class="CompileArgumentsWidget" name="optionTabs">
|
||||
<property name="documentMode">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
@ -455,6 +455,14 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>CompileArgumentsWidget</class>
|
||||
<extends>QTabWidget</extends>
|
||||
<header location="global">widgets/compileargumentswidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../icons.qrc"/>
|
||||
</resources>
|
||||
|
|
|
@ -39,67 +39,11 @@ void ProjectCompilerWidget::refreshOptions()
|
|||
return;
|
||||
ui->chkAddCharset->setVisible(pSet->compilerType()!=COMPILER_CLANG);
|
||||
ui->chkAddCharset->setEnabled(pSet->compilerType()!=COMPILER_CLANG);
|
||||
mOptions = pMainWindow->project().options().compilerOptions;
|
||||
mOptions = pMainWindow->project()->options().compilerOptions;
|
||||
if (mOptions.isEmpty())
|
||||
mOptions = pSet->compileOptions();
|
||||
QTabWidget* pTab = ui->tabOptions;
|
||||
while (pTab->count()>0) {
|
||||
QWidget* p=pTab->widget(0);
|
||||
if (p!=nullptr) {
|
||||
pTab->removeTab(0);
|
||||
p->setParent(nullptr);
|
||||
delete p;
|
||||
}
|
||||
}
|
||||
|
||||
for (int index=0; index< pSet->options().count();index++){
|
||||
PCompilerOption pOption =pSet->options()[index];
|
||||
QWidget* pWidget = nullptr;
|
||||
for (int i=0;i<pTab->count();i++) {
|
||||
if (pOption->section == pTab->tabText(i)) {
|
||||
pWidget = pTab->widget(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pWidget == nullptr) {
|
||||
pWidget = new QWidget();
|
||||
pTab->addTab(pWidget,pOption->section);
|
||||
pWidget->setLayout(new QGridLayout());
|
||||
}
|
||||
QGridLayout *pLayout = static_cast<QGridLayout*>(pWidget->layout());
|
||||
int row = pLayout->rowCount();
|
||||
pLayout->addWidget(new QLabel(pOption->name),row,0);
|
||||
QComboBox* pCombo = new QComboBox();
|
||||
if (pOption->choices.count()>0) {
|
||||
for (int i=0;i<pOption->choices.count();i++) {
|
||||
QString choice = pOption->choices[i];
|
||||
QStringList valueName=choice.split("=");
|
||||
if (valueName.length()<2) {
|
||||
pCombo->addItem("");
|
||||
} else {
|
||||
pCombo->addItem(valueName[0]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pCombo->addItem(QObject::tr("No"));
|
||||
pCombo->addItem(QObject::tr("Yes"));
|
||||
}
|
||||
int value;
|
||||
if (index<mOptions.length()) {
|
||||
value = pSet->charToValue(mOptions[index]);
|
||||
} else {
|
||||
value = pOption->value;
|
||||
}
|
||||
pCombo->setCurrentIndex(value);
|
||||
pLayout->addWidget(pCombo,row,1);
|
||||
}
|
||||
for (int i=0;i<pTab->count();i++) {
|
||||
QWidget* pWidget = pTab->widget(i);
|
||||
QGridLayout *pLayout = static_cast<QGridLayout*>(pWidget->layout());
|
||||
int row = pLayout->rowCount();
|
||||
QSpacerItem* horizontalSpacer = new QSpacerItem(10, 100, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
pLayout->addItem(horizontalSpacer,row,0);
|
||||
}
|
||||
ui->tabOptions->resetUI(pSet,mOptions);
|
||||
|
||||
ui->chkStaticLink->setChecked(pSet->staticLink());
|
||||
}
|
||||
|
@ -118,29 +62,9 @@ void ProjectCompilerWidget::doSave()
|
|||
Settings::PCompilerSet pSet = pSettings->compilerSets().getSet(ui->cbCompilerSet->currentIndex());
|
||||
if (!pSet)
|
||||
return;
|
||||
//read values in the options widget
|
||||
QTabWidget* pTab = ui->tabOptions;
|
||||
mOptions.clear();
|
||||
for (int i=0;i<pTab->count();i++) {
|
||||
QString section = pTab->tabText(i);
|
||||
QWidget* pWidget = pTab->widget(i);
|
||||
QGridLayout* pLayout = static_cast<QGridLayout*>(pWidget->layout());
|
||||
if (pLayout != nullptr) {
|
||||
for (int j=1;j<pLayout->rowCount()-1;j++) {
|
||||
QString name = static_cast<QLabel *>(pLayout->itemAtPosition(j,0)->widget())->text();
|
||||
QComboBox* pCombo = static_cast<QComboBox *>(pLayout->itemAtPosition(j,1)->widget());
|
||||
for (int index=0;index<pSet->options().count();index++) {
|
||||
PCompilerOption pOption = pSet->options()[index];
|
||||
if (pOption->section == section && pOption->name == name) {
|
||||
char val = pSet->valueToChar( pCombo->currentIndex());
|
||||
mOptions.append(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pMainWindow->project()->setCompilerSet(ui->cbCompilerSet->currentIndex());
|
||||
pMainWindow->project()->options().compilerOptions = mOptions;
|
||||
pMainWindow->project()->options().compilerOptions = ui->tabOptions->arguments(true);
|
||||
if (pSet->compilerType()!=COMPILER_CLANG)
|
||||
pMainWindow->project()->options().addCharset = ui->chkAddCharset->isChecked();
|
||||
pMainWindow->project()->options().staticLink = ui->chkStaticLink->isChecked();
|
||||
|
|
|
@ -14,9 +14,6 @@
|
|||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="6" column="0" colspan="3">
|
||||
<widget class="QWidget" name="widget" native="true"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
|
@ -30,21 +27,17 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="3">
|
||||
<widget class="QWidget" name="widget" native="true"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="cbCompilerSet"/>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="QTabWidget" name="tabOptions">
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Tab 1</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Tab 2</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QCheckBox" name="chkStaticLink">
|
||||
<property name="text">
|
||||
<string>Statically link libraries</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
|
@ -54,20 +47,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Customize (apply to this project only):</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QCheckBox" name="chkStaticLink">
|
||||
<property name="text">
|
||||
<string>Statically link libraries</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="chkAddCharset">
|
||||
<property name="text">
|
||||
|
@ -75,8 +54,30 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Customize (apply to this project only):</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="CompileArgumentsWidget" name="tabOptions">
|
||||
<property name="documentMode">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>CompileArgumentsWidget</class>
|
||||
<extends>QTabWidget</extends>
|
||||
<header location="global">widgets/compileargumentswidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -1,26 +1,24 @@
|
|||
#include "compileargumentswidget.h"
|
||||
#include "ui_compileargumentswidget.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
|
||||
CompileArgumentsWidget::CompileArgumentsWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::CompileArgumentsWidget)
|
||||
QTabWidget(parent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
}
|
||||
|
||||
CompileArgumentsWidget::~CompileArgumentsWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QMap<QString, QString> CompileArgumentsWidget::options() const
|
||||
QMap<QString, QString> CompileArgumentsWidget::arguments( bool includeUnset) const
|
||||
{
|
||||
QMap
|
||||
QTabWidget* pTab = ui->tabArguments;
|
||||
QMap<QString, QString> args;
|
||||
const QTabWidget* pTab = this;
|
||||
for (int i=0;i<pTab->count();i++) {
|
||||
QString section = pTab->tabText(i);
|
||||
QWidget* pWidget = pTab->widget(i);
|
||||
|
@ -34,27 +32,33 @@ QMap<QString, QString> CompileArgumentsWidget::options() const
|
|||
if (pOption->choices.isEmpty()) {
|
||||
QCheckBox* pCheckbox = static_cast<QCheckBox *>(pLayout->itemAtPosition(j,1)->widget());
|
||||
if (pCheckbox->isChecked()) {
|
||||
|
||||
pSet->setCompileOption(key,"");
|
||||
args.insert(key,COMPILER_OPTION_ON);
|
||||
} else {
|
||||
pSet->unsetCompileOption(key);
|
||||
if (includeUnset)
|
||||
args.insert(key,"");
|
||||
else
|
||||
args.remove(key);
|
||||
}
|
||||
} else {
|
||||
QComboBox* pCombo = static_cast<QComboBox *>(pLayout->itemAtPosition(j,2)->widget());
|
||||
if (!pCombo->currentData().toString().isEmpty()) {
|
||||
pSet->setCompileOption(key,pCombo->currentData().toString());
|
||||
args.insert(key,pCombo->currentData().toString());
|
||||
} else {
|
||||
pSet->unsetCompileOption(key);
|
||||
if (includeUnset)
|
||||
args.insert(key,"");
|
||||
else
|
||||
args.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
void CompileArgumentsWidget::resetUI(Settings::PCompilerSet pSet, const QMap<QString,QString>& options)
|
||||
{
|
||||
QTabWidget* pTab = ui->tabArguments;
|
||||
QTabWidget* pTab = this;
|
||||
while (pTab->count()>0) {
|
||||
QWidget* p=pTab->widget(0);
|
||||
if (p!=nullptr) {
|
||||
|
@ -67,7 +71,7 @@ void CompileArgumentsWidget::resetUI(Settings::PCompilerSet pSet, const QMap<QSt
|
|||
return;
|
||||
mCompilerType = pSet->compilerType();
|
||||
|
||||
foreach (PCompilerOption pOption, CompilerInfoManager::getCompilerOptions(mCompilerType).values()) {
|
||||
foreach (PCompilerOption pOption, CompilerInfoManager::getCompilerOptions(mCompilerType)) {
|
||||
QWidget* pWidget = nullptr;
|
||||
for (int i=0;i<pTab->count();i++) {
|
||||
if (pOption->section == pTab->tabText(i)) {
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
#define COMPILEARGUMENTSWIDGET_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QWidget>
|
||||
#include <QTabWidget>
|
||||
#include "../settings.h"
|
||||
|
||||
namespace Ui {
|
||||
class CompileArgumentsWidget;
|
||||
}
|
||||
|
||||
class CompileArgumentsWidget : public QWidget
|
||||
class CompileArgumentsWidget : public QTabWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -17,12 +17,11 @@ public:
|
|||
explicit CompileArgumentsWidget(QWidget *parent = nullptr);
|
||||
~CompileArgumentsWidget();
|
||||
|
||||
QMap<QString, QString> options() const;
|
||||
QMap<QString, QString> arguments(bool includeUnset) const;
|
||||
|
||||
void resetUI(Settings::PCompilerSet pSet, const QMap<QString,QString>& options);
|
||||
|
||||
private:
|
||||
Ui::CompileArgumentsWidget *ui;
|
||||
QString mCompilerType;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CompileArgumentsWidget</class>
|
||||
<widget class="QWidget" name="CompileArgumentsWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabArguments">
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Tab 1</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Tab 2</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue