1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Projucer: Various fixes and improvements to PIPGenerator

This commit is contained in:
ed 2018-03-15 11:15:11 +00:00
parent 711e75bdc8
commit ef2d1fa9fd
12 changed files with 194 additions and 28 deletions

View file

@ -47,6 +47,8 @@ StoredSettings::StoredSettings()
{
updateOldProjectSettingsFiles();
reload();
checkJUCEPaths();
projectDefaults.addListener (this);
fallbackPaths.addListener (this);
}
@ -195,6 +197,34 @@ void StoredSettings::updateOldProjectSettingsFiles()
}
}
void StoredSettings::checkJUCEPaths()
{
auto moduleFolder = projectDefaults.getProperty (Ids::defaultJuceModulePath).toString();
auto juceFolder = projectDefaults.getProperty (Ids::jucePath).toString();
auto validModuleFolder = isGlobalPathValid ({}, Ids::defaultJuceModulePath, moduleFolder);
auto validJuceFolder = isGlobalPathValid ({}, Ids::jucePath, juceFolder);
if (validModuleFolder && ! validJuceFolder)
projectDefaults.getPropertyAsValue (Ids::jucePath, nullptr) = File (moduleFolder).getParentDirectory().getFullPathName();
else if (! validModuleFolder && validJuceFolder)
projectDefaults.getPropertyAsValue (Ids::defaultJuceModulePath, nullptr) = File (juceFolder).getChildFile ("modules").getFullPathName();
}
bool StoredSettings::shouldAskUserToSetJUCEPath() noexcept
{
if (! isGlobalPathValid ({}, Ids::jucePath, projectDefaults.getProperty (Ids::jucePath).toString())
&& getGlobalProperties().getValue ("dontAskAboutJUCEPath", {}).isEmpty())
return true;
return false;
}
void StoredSettings::setDontAskAboutJUCEPathAgain() noexcept
{
getGlobalProperties().setValue ("dontAskAboutJUCEPath", 1);
}
//==============================================================================
void StoredSettings::loadSwatchColours()
{
@ -271,7 +301,12 @@ Value StoredSettings::getFallbackPathForOS (const Identifier& key, DependencyPat
if (v.toString().isEmpty())
{
if (key == Ids::defaultJuceModulePath)
if (key == Ids::jucePath)
{
v = (os == TargetOS::windows ? "C:\\JUCE"
: "~/JUCE");
}
else if (key == Ids::defaultJuceModulePath)
{
v = (os == TargetOS::windows ? "C:\\JUCE\\modules"
: "~/JUCE/modules");
@ -334,13 +369,13 @@ Value StoredSettings::getFallbackPathForOS (const Identifier& key, DependencyPat
return v;
}
static bool doesSDKPathContainFile (const File& relativeTo, const String& path, const String& fileToCheckFor)
static bool doesSDKPathContainFile (const File& relativeTo, const String& path, const String& fileToCheckFor) noexcept
{
auto actualPath = path.replace ("${user.home}", File::getSpecialLocation (File::userHomeDirectory).getFullPathName());
return relativeTo.getChildFile (actualPath + "/" + fileToCheckFor).exists();
}
bool StoredSettings::isGlobalPathValid (const File& relativeTo, const Identifier& key, const String& path)
bool StoredSettings::isGlobalPathValid (const File& relativeTo, const Identifier& key, const String& path) const noexcept
{
String fileToCheckFor;
@ -390,6 +425,10 @@ bool StoredSettings::isGlobalPathValid (const File& relativeTo, const Identifier
fileToCheckFor = "../clion.sh";
#endif
}
else if (key == Ids::jucePath)
{
fileToCheckFor = "ChangeList.txt";
}
else
{
// didn't recognise the key provided!

View file

@ -70,7 +70,11 @@ public:
Value getStoredPath (const Identifier& key);
Value getFallbackPathForOS (const Identifier& key, DependencyPathOS);
bool isGlobalPathValid (const File& relativeTo, const Identifier& key, const String& path);
bool isGlobalPathValid (const File& relativeTo, const Identifier& key, const String& path) const noexcept;
//==============================================================================
bool shouldAskUserToSetJUCEPath() noexcept;
void setDontAskAboutJUCEPathAgain() noexcept;
private:
OwnedArray<PropertiesFile> propertyFiles;
@ -96,6 +100,7 @@ private:
void saveSwatchColours();
void updateOldProjectSettingsFiles();
void checkJUCEPaths();
//==============================================================================
void valueTreePropertyChanged (ValueTree& vt, const Identifier&) override { changed (vt == projectDefaults); }