mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Projucer: Fix an issue with per-file compiler flags not being respected
This commit is contained in:
parent
f2de0f12b0
commit
b0bd31b3c2
8 changed files with 36 additions and 12 deletions
|
|
@ -1723,7 +1723,8 @@ Value Project::Item::getShouldSkipPCHValue() { return state.getPr
|
||||||
bool Project::Item::shouldSkipPCH() const { return isModuleCode() || state [Ids::skipPCH]; }
|
bool Project::Item::shouldSkipPCH() const { return isModuleCode() || state [Ids::skipPCH]; }
|
||||||
|
|
||||||
Value Project::Item::getCompilerFlagSchemeValue() { return state.getPropertyAsValue (Ids::compilerFlagScheme, getUndoManager()); }
|
Value Project::Item::getCompilerFlagSchemeValue() { return state.getPropertyAsValue (Ids::compilerFlagScheme, getUndoManager()); }
|
||||||
String Project::Item::getCompilerFlagSchemeString() const { return state [Ids::compilerFlagScheme]; }
|
|
||||||
|
String Project::Item::getCompilerFlagSchemeString() const { return state[Ids::compilerFlagScheme]; }
|
||||||
|
|
||||||
void Project::Item::setCompilerFlagScheme (const String& scheme)
|
void Project::Item::setCompilerFlagScheme (const String& scheme)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1402,7 +1402,7 @@ private:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto extraFlags = compilerFlagSchemesMap[projectItem.getCompilerFlagSchemeString()].get().toString();
|
auto extraFlags = getCompilerFlagsForProjectItem (projectItem);
|
||||||
|
|
||||||
if (extraFlags.isNotEmpty())
|
if (extraFlags.isNotEmpty())
|
||||||
extraCompilerFlags.add ({ file, extraFlags });
|
extraCompilerFlags.add ({ file, extraFlags });
|
||||||
|
|
|
||||||
|
|
@ -761,7 +761,7 @@ private:
|
||||||
|
|
||||||
if (projectItem.shouldBeCompiled())
|
if (projectItem.shouldBeCompiled())
|
||||||
{
|
{
|
||||||
auto extraCompilerFlags = compilerFlagSchemesMap[projectItem.getCompilerFlagSchemeString()].get().toString();
|
auto extraCompilerFlags = getCompilerFlagsForProjectItem (projectItem);
|
||||||
|
|
||||||
if (extraCompilerFlags.isNotEmpty())
|
if (extraCompilerFlags.isNotEmpty())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -912,7 +912,7 @@ public:
|
||||||
|
|
||||||
if (projectItem.shouldBeCompiled())
|
if (projectItem.shouldBeCompiled())
|
||||||
{
|
{
|
||||||
auto extraCompilerFlags = owner.compilerFlagSchemesMap[projectItem.getCompilerFlagSchemeString()].get().toString();
|
auto extraCompilerFlags = getOwner().getCompilerFlagsForProjectItem (projectItem);
|
||||||
|
|
||||||
if (shouldAddBigobjFlag (path))
|
if (shouldAddBigobjFlag (path))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -933,7 +933,7 @@ private:
|
||||||
if (shouldFileBeCompiledByDefault (f))
|
if (shouldFileBeCompiledByDefault (f))
|
||||||
{
|
{
|
||||||
auto scheme = projectItem.getCompilerFlagSchemeString();
|
auto scheme = projectItem.getCompilerFlagSchemeString();
|
||||||
auto flags = compilerFlagSchemesMap[scheme].get().toString();
|
auto flags = getCompilerFlagsForProjectItem (projectItem);
|
||||||
|
|
||||||
if (scheme.isNotEmpty() && flags.isNotEmpty())
|
if (scheme.isNotEmpty() && flags.isNotEmpty())
|
||||||
results.emplace_back (f, scheme);
|
results.emplace_back (f, scheme);
|
||||||
|
|
|
||||||
|
|
@ -3213,7 +3213,7 @@ private:
|
||||||
xcodeTarget = getTargetOfType (project.getTargetTypeFromFilePath (projectItem.getFile(), false));
|
xcodeTarget = getTargetOfType (project.getTargetTypeFromFilePath (projectItem.getFile(), false));
|
||||||
|
|
||||||
return addFile (FileOptions().withRelativePath (path)
|
return addFile (FileOptions().withRelativePath (path)
|
||||||
.withCompilerFlags (compilerFlagSchemesMap[projectItem.getCompilerFlagSchemeString()].get())
|
.withCompilerFlags (getCompilerFlagsForProjectItem (projectItem))
|
||||||
.withCompilationEnabled (projectItem.shouldBeCompiled())
|
.withCompilationEnabled (projectItem.shouldBeCompiled())
|
||||||
.withAddToBinaryResourcesEnabled (projectItem.shouldBeAddedToBinaryResources())
|
.withAddToBinaryResourcesEnabled (projectItem.shouldBeAddedToBinaryResources())
|
||||||
.withAddToXcodeResourcesEnabled (projectItem.shouldBeAddedToXcodeResources())
|
.withAddToXcodeResourcesEnabled (projectItem.shouldBeAddedToXcodeResources())
|
||||||
|
|
|
||||||
|
|
@ -507,6 +507,14 @@ String ProjectExporter::replacePreprocessorTokens (const ProjectExporter::BuildC
|
||||||
sourceString);
|
sourceString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String ProjectExporter::getCompilerFlagsForProjectItem (const Project::Item& projectItem) const
|
||||||
|
{
|
||||||
|
if (auto buildConfigurationForFile = getBuildConfigurationWithName (projectItem.getCompilerFlagSchemeString()))
|
||||||
|
return buildConfigurationForFile->getAllCompilerFlagsString();
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
void ProjectExporter::copyMainGroupFromProject()
|
void ProjectExporter::copyMainGroupFromProject()
|
||||||
{
|
{
|
||||||
jassert (itemGroups.size() == 0);
|
jassert (itemGroups.size() == 0);
|
||||||
|
|
@ -761,14 +769,26 @@ ProjectExporter::BuildConfiguration::Ptr ProjectExporter::getConfiguration (int
|
||||||
return createBuildConfig (getConfigurations().getChild (index));
|
return createBuildConfig (getConfigurations().getChild (index));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProjectExporter::hasConfigurationNamed (const String& nameToFind) const
|
std::optional<ValueTree> ProjectExporter::getConfigurationWithName (const String& nameToFind) const
|
||||||
{
|
{
|
||||||
auto configs = getConfigurations();
|
auto configs = getConfigurations();
|
||||||
for (int i = configs.getNumChildren(); --i >= 0;)
|
for (int i = configs.getNumChildren(); --i >= 0;)
|
||||||
if (configs.getChild(i) [Ids::name].toString() == nameToFind)
|
{
|
||||||
return true;
|
auto config = configs.getChild (i);
|
||||||
|
|
||||||
return false;
|
if (config[Ids::name].toString() == nameToFind)
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
ProjectExporter::BuildConfiguration::Ptr ProjectExporter::getBuildConfigurationWithName (const String& nameToFind) const
|
||||||
|
{
|
||||||
|
if (auto config = getConfigurationWithName (nameToFind))
|
||||||
|
return createBuildConfig (*config);
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ProjectExporter::getUniqueConfigName (String nm) const
|
String ProjectExporter::getUniqueConfigName (String nm) const
|
||||||
|
|
@ -780,7 +800,7 @@ String ProjectExporter::getUniqueConfigName (String nm) const
|
||||||
nameRoot = nameRoot.trim();
|
nameRoot = nameRoot.trim();
|
||||||
|
|
||||||
int suffix = 2;
|
int suffix = 2;
|
||||||
while (hasConfigurationNamed (name))
|
while (getConfigurationWithName (name).has_value())
|
||||||
nm = nameRoot + " " + String (suffix++);
|
nm = nameRoot + " " + String (suffix++);
|
||||||
|
|
||||||
return nm;
|
return nm;
|
||||||
|
|
|
||||||
|
|
@ -319,7 +319,6 @@ public:
|
||||||
|
|
||||||
void addNewConfigurationFromExisting (const BuildConfiguration& configToCopy);
|
void addNewConfigurationFromExisting (const BuildConfiguration& configToCopy);
|
||||||
void addNewConfiguration (bool isDebugConfig);
|
void addNewConfiguration (bool isDebugConfig);
|
||||||
bool hasConfigurationNamed (const String& name) const;
|
|
||||||
String getUniqueConfigName (String name) const;
|
String getUniqueConfigName (String name) const;
|
||||||
|
|
||||||
String getExternalLibraryFlags (const BuildConfiguration& config) const;
|
String getExternalLibraryFlags (const BuildConfiguration& config) const;
|
||||||
|
|
@ -361,6 +360,8 @@ public:
|
||||||
|
|
||||||
int getNumConfigurations() const;
|
int getNumConfigurations() const;
|
||||||
BuildConfiguration::Ptr getConfiguration (int index) const;
|
BuildConfiguration::Ptr getConfiguration (int index) const;
|
||||||
|
std::optional<ValueTree> getConfigurationWithName (const String& nameToFind) const;
|
||||||
|
BuildConfiguration::Ptr getBuildConfigurationWithName (const String& nameToFind) const;
|
||||||
|
|
||||||
ValueTree getConfigurations() const;
|
ValueTree getConfigurations() const;
|
||||||
virtual void createDefaultConfigs();
|
virtual void createDefaultConfigs();
|
||||||
|
|
@ -401,6 +402,8 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getCompilerFlagsForProjectItem (const Project::Item& projectItem) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
String name;
|
String name;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue