mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Projucer: Added an "add recommended warning flags" checkbox to the exporters
This commit is contained in:
parent
d4b7cceb32
commit
1fd9c2f282
7 changed files with 76 additions and 9 deletions
|
|
@ -288,6 +288,7 @@ protected:
|
|||
|
||||
void createConfigProperties (PropertyListBuilder& props) override
|
||||
{
|
||||
addRecommendedLLVMCompilerWarningsProperty (props);
|
||||
addGCCOptimisationProperty (props);
|
||||
|
||||
props.add (new TextPropertyComponent (androidArchitectures, "Architectures", 256, false),
|
||||
|
|
@ -634,11 +635,19 @@ private:
|
|||
if (getProject().getProjectType().isStaticLibrary())
|
||||
mo << " targets \"" << getNativeModuleBinaryName (cfg) << "\"" << newLine;
|
||||
|
||||
mo << " arguments \"-DJUCE_BUILD_CONFIGURATION=" << cfg.getProductFlavourCMakeIdentifier() << "\""
|
||||
<< ", \"-DCMAKE_CXX_FLAGS_" << (cfg.isDebug() ? "DEBUG" : "RELEASE")
|
||||
<< "=-O" << cfg.getGCCOptimisationFlag() << "\""
|
||||
<< ", \"-DCMAKE_C_FLAGS_" << (cfg.isDebug() ? "DEBUG" : "RELEASE")
|
||||
<< "=-O" << cfg.getGCCOptimisationFlag() << "\"" << newLine;
|
||||
mo << " arguments "
|
||||
<< "\"-DJUCE_BUILD_CONFIGURATION=" << cfg.getProductFlavourCMakeIdentifier() << "\"";
|
||||
|
||||
mo << ", \"-DCMAKE_CXX_FLAGS_" << (cfg.isDebug() ? "DEBUG" : "RELEASE")
|
||||
<< "=-O" << cfg.getGCCOptimisationFlag();
|
||||
|
||||
for (auto& flag : cfg.getRecommendedCompilerWarningFlags())
|
||||
mo << " " << flag;
|
||||
|
||||
mo << "\""
|
||||
<< ", \"-DCMAKE_C_FLAGS_" << (cfg.isDebug() ? "DEBUG" : "RELEASE")
|
||||
<< "=-O" << cfg.getGCCOptimisationFlag()
|
||||
<< "\"" << newLine;
|
||||
|
||||
mo << " }" << newLine;
|
||||
mo << " }" << newLine << newLine;
|
||||
|
|
|
|||
|
|
@ -209,6 +209,7 @@ private:
|
|||
|
||||
void createConfigProperties (PropertyListBuilder& props) override
|
||||
{
|
||||
addRecommendedLinuxCompilerWarningsProperty (props);
|
||||
addGCCOptimisationProperty (props);
|
||||
|
||||
props.add (new ChoicePropertyComponent (architectureTypeValue, "Architecture",
|
||||
|
|
@ -401,6 +402,9 @@ private:
|
|||
if (auto* codeBlocksConfig = dynamic_cast<const CodeBlocksBuildConfiguration*> (&config))
|
||||
flags.add (codeBlocksConfig->getArchitectureTypeString());
|
||||
|
||||
for (auto& recommended : config.getRecommendedCompilerWarningFlags())
|
||||
flags.add (recommended);
|
||||
|
||||
flags.add ("-O" + config.getGCCOptimisationFlag());
|
||||
|
||||
if (config.isLinkTimeOptimisationEnabled())
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ protected:
|
|||
|
||||
void createConfigProperties (PropertyListBuilder& props) override
|
||||
{
|
||||
addRecommendedLinuxCompilerWarningsProperty (props);
|
||||
addGCCOptimisationProperty (props);
|
||||
|
||||
props.add (new ChoicePropertyComponent (architectureTypeValue, "Architecture",
|
||||
|
|
@ -521,6 +522,9 @@ private:
|
|||
if (extra.isNotEmpty())
|
||||
result.add (extra);
|
||||
|
||||
for (auto& recommended : config.getRecommendedCompilerWarningFlags())
|
||||
result.add (recommended);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -631,6 +631,7 @@ protected:
|
|||
void createConfigProperties (PropertyListBuilder& props) override
|
||||
{
|
||||
addXcodePluginInstallPathProperties (props);
|
||||
addRecommendedLLVMCompilerWarningsProperty (props);
|
||||
addGCCOptimisationProperty (props);
|
||||
|
||||
if (iOS)
|
||||
|
|
@ -1244,10 +1245,11 @@ public:
|
|||
if (config.isFastMathEnabled())
|
||||
s.set ("GCC_FAST_MATH", "YES");
|
||||
|
||||
auto extraFlags = owner.replacePreprocessorTokens (config, owner.getExtraCompilerFlagsString()).trim();
|
||||
auto flags = (owner.replacePreprocessorTokens (config, owner.getExtraCompilerFlagsString())
|
||||
+ " " + config.getRecommendedCompilerWarningFlags().joinIntoString (" ")).trim();
|
||||
|
||||
if (extraFlags.isNotEmpty())
|
||||
s.set ("OTHER_CPLUSPLUSFLAGS", extraFlags.quoted());
|
||||
if (flags.isNotEmpty())
|
||||
s.set ("OTHER_CPLUSPLUSFLAGS", flags.quoted());
|
||||
|
||||
auto installPath = getInstallPathForConfiguration (config);
|
||||
|
||||
|
|
|
|||
|
|
@ -923,6 +923,7 @@ ProjectExporter::BuildConfiguration::BuildConfiguration (Project& p, const Value
|
|||
configNameValue (config, Ids::name, getUndoManager(), "Build Configuration"),
|
||||
targetNameValue (config, Ids::targetName, getUndoManager(), project.getProjectFilenameRootString()),
|
||||
targetBinaryPathValue (config, Ids::binaryPath, getUndoManager()),
|
||||
recommendedWarningsValue (config, Ids::recommendedWarnings, getUndoManager()),
|
||||
optimisationLevelValue (config, Ids::optimisation, getUndoManager()),
|
||||
linkTimeOptimisationValue (config, Ids::linkTimeOptimisation, getUndoManager(), ! isDebug()),
|
||||
ppDefinesValue (config, Ids::defines, getUndoManager()),
|
||||
|
|
@ -930,6 +931,18 @@ ProjectExporter::BuildConfiguration::BuildConfiguration (Project& p, const Value
|
|||
librarySearchPathValue (config, Ids::libraryPath, getUndoManager()),
|
||||
userNotesValue (config, Ids::userNotes, getUndoManager())
|
||||
{
|
||||
recommendedCompilerWarningFlags["LLVM"] = { "-Wall", "-Wshadow-all", "-Wshorten-64-to-32", "-Wstrict-aliasing", "-Wuninitialized", "-Wunused-parameter",
|
||||
"-Wconversion", "-Wsign-compare", "-Wint-conversion", "-Wconditional-uninitialized", "-Woverloaded-virtual",
|
||||
"-Wreorder", "-Wconstant-conversion", "-Wsign-conversion", "-Wunused-private-field", "-Wbool-conversion",
|
||||
"-Wextra-semi", "-Wunreachable-code", "-Wzero-as-null-pointer-constant", "-Wcast-align",
|
||||
"-Winconsistent-missing-destructor-override", "-Wshift-sign-overflow", "-Wnullable-to-nonnull-conversion",
|
||||
"-Wno-missing-field-initializers", "-Wno-ignored-qualifiers" };
|
||||
recommendedCompilerWarningFlags["GCC"] = { "-Wall", "-Wextra", "-Wstrict-aliasing", "-Wuninitialized", "-Wunused-parameter", "-Wsign-compare",
|
||||
"-Woverloaded-virtual", "-Wreorder", "-Wsign-conversion", "-Wunreachable-code",
|
||||
"-Wzero-as-null-pointer-constant", "-Wcast-align", "-Wno-implicit-fallthrough",
|
||||
"-Wno-maybe-uninitialized", "-Wno-missing-field-initializers", "-Wno-ignored-qualifiers" };
|
||||
recommendedCompilerWarningFlags["GCC-7"] = recommendedCompilerWarningFlags["GCC"];
|
||||
recommendedCompilerWarningFlags["GCC-7"].add ("-Wno-strict-overflow");
|
||||
}
|
||||
|
||||
ProjectExporter::BuildConfiguration::~BuildConfiguration()
|
||||
|
|
@ -961,6 +974,35 @@ void ProjectExporter::BuildConfiguration::addGCCOptimisationProperty (PropertyLi
|
|||
"The optimisation level for this configuration");
|
||||
}
|
||||
|
||||
void ProjectExporter::BuildConfiguration::addRecommendedLinuxCompilerWarningsProperty (PropertyListBuilder& props)
|
||||
{
|
||||
props.add (new ChoicePropertyComponent (recommendedWarningsValue, "Add Recommended Compiler Warning Flags",
|
||||
{ "GCC", "GCC 7 and below", "LLVM", "Disabled" },
|
||||
{ "GCC", "GCC-7", "LLVM", "" }),
|
||||
"Enable this to add a set of recommended compiler warning flags.");
|
||||
recommendedWarningsValue.setDefault ("");
|
||||
}
|
||||
|
||||
void ProjectExporter::BuildConfiguration::addRecommendedLLVMCompilerWarningsProperty (PropertyListBuilder& props)
|
||||
{
|
||||
props.add (new ChoicePropertyComponent (recommendedWarningsValue, "Add Recommended Compiler Warning Flags",
|
||||
{ "Enabled", "Disabled" },
|
||||
{ "LLVM", "" }),
|
||||
"Enable this to add a set of recommended compiler warning flags.");
|
||||
recommendedWarningsValue.setDefault ("");
|
||||
}
|
||||
|
||||
StringArray ProjectExporter::BuildConfiguration::getRecommendedCompilerWarningFlags() const
|
||||
{
|
||||
auto label = recommendedWarningsValue.get().toString();
|
||||
auto it = recommendedCompilerWarningFlags.find (label);
|
||||
|
||||
if (it != recommendedCompilerWarningFlags.end())
|
||||
return it->second;
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void ProjectExporter::BuildConfiguration::createPropertyEditors (PropertyListBuilder& props)
|
||||
{
|
||||
if (exporter.supportsUserDefinedConfigurations())
|
||||
|
|
|
|||
|
|
@ -272,6 +272,9 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
void createPropertyEditors (PropertyListBuilder&);
|
||||
void addRecommendedLinuxCompilerWarningsProperty (PropertyListBuilder&);
|
||||
void addRecommendedLLVMCompilerWarningsProperty (PropertyListBuilder&);
|
||||
StringArray getRecommendedCompilerWarningFlags() const;
|
||||
void addGCCOptimisationProperty (PropertyListBuilder&);
|
||||
void removeFromExporter();
|
||||
|
||||
|
|
@ -281,10 +284,12 @@ public:
|
|||
const ProjectExporter& exporter;
|
||||
|
||||
protected:
|
||||
ValueWithDefault isDebugValue, configNameValue, targetNameValue, targetBinaryPathValue, optimisationLevelValue,
|
||||
ValueWithDefault isDebugValue, configNameValue, targetNameValue, targetBinaryPathValue, recommendedWarningsValue, optimisationLevelValue,
|
||||
linkTimeOptimisationValue, ppDefinesValue, headerSearchPathValue, librarySearchPathValue, userNotesValue;
|
||||
|
||||
private:
|
||||
std::map<String, StringArray> recommendedCompilerWarningFlags;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BuildConfiguration)
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ namespace Ids
|
|||
DECLARE_ID (alwaysGenerateDebugSymbols);
|
||||
DECLARE_ID (targetName);
|
||||
DECLARE_ID (binaryPath);
|
||||
DECLARE_ID (recommendedWarnings);
|
||||
DECLARE_ID (optimisation);
|
||||
DECLARE_ID (defines);
|
||||
DECLARE_ID (headerPath);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue