diff --git a/extras/Projucer/Source/Application/jucer_GlobalPreferences.cpp b/extras/Projucer/Source/Application/jucer_GlobalPreferences.cpp index 63ed876ecc..7624506e3c 100644 --- a/extras/Projucer/Source/Application/jucer_GlobalPreferences.cpp +++ b/extras/Projucer/Source/Application/jucer_GlobalPreferences.cpp @@ -60,7 +60,7 @@ void PathSettingsTab::textPropertyComponentChanged (TextPropertyComponent* textP { Identifier keyName = getKeyForPropertyComponent (textPropertyComponent); - Colour textColour = getAppSettings().isGlobalPathValid (keyName, textPropertyComponent->getText()) + Colour textColour = getAppSettings().isGlobalPathValid (File::getCurrentWorkingDirectory(), keyName, textPropertyComponent->getText()) ? Colours::black : Colours::red; diff --git a/extras/Projucer/Source/Project Saving/jucer_ProjectExport_AndroidBase.h b/extras/Projucer/Source/Project Saving/jucer_ProjectExport_AndroidBase.h index 123f140c89..aad706fb84 100644 --- a/extras/Projucer/Source/Project Saving/jucer_ProjectExport_AndroidBase.h +++ b/extras/Projucer/Source/Project Saving/jucer_ProjectExport_AndroidBase.h @@ -129,10 +129,10 @@ public: props.add (new TextWithDefaultPropertyComponent (androidVersionCode, "Android Version Code", 32), "An integer value that represents the version of the application code, relative to other versions."); - props.add (new DependencyPathPropertyComponent (sdkPath, "Android SDK Path"), + props.add (new DependencyPathPropertyComponent (project.getFile().getParentDirectory(), sdkPath, "Android SDK Path"), "The path to the Android SDK folder on the target build machine"); - props.add (new DependencyPathPropertyComponent (ndkPath, "Android NDK Path"), + props.add (new DependencyPathPropertyComponent (project.getFile().getParentDirectory(), ndkPath, "Android NDK Path"), "The path to the Android NDK folder on the target build machine"); props.add (new TextWithDefaultPropertyComponent (androidMinimumSDK, "Minimum SDK version", 32), diff --git a/extras/Projucer/Source/Project Saving/jucer_ProjectExporter.cpp b/extras/Projucer/Source/Project Saving/jucer_ProjectExporter.cpp index c43b44f2de..f0382e847d 100644 --- a/extras/Projucer/Source/Project Saving/jucer_ProjectExporter.cpp +++ b/extras/Projucer/Source/Project Saving/jucer_ProjectExporter.cpp @@ -244,19 +244,19 @@ void ProjectExporter::createDependencyPathProperties (PropertyListBuilder& props { if (supportsVST3() && (project.shouldBuildVST3().getValue() || project.isVST3PluginHost())) { - props.add (new DependencyPathPropertyComponent (getVST3PathValue(), "VST3 SDK Folder"), + props.add (new DependencyPathPropertyComponent (project.getFile().getParentDirectory(), getVST3PathValue(), "VST3 SDK Folder"), "If you're building a VST3 plugin or host, this must be the folder containing the VST3 SDK. This can be an absolute path, or a path relative to the Projucer project file."); } if (supportsAAX() && project.shouldBuildAAX().getValue()) { - props.add (new DependencyPathPropertyComponent (getAAXPathValue(), "AAX SDK Folder"), + props.add (new DependencyPathPropertyComponent (project.getFile().getParentDirectory(), getAAXPathValue(), "AAX SDK Folder"), "If you're building an AAX plugin, this must be the folder containing the AAX SDK. This can be an absolute path, or a path relative to the Projucer project file."); } if (supportsRTAS() && project.shouldBuildRTAS().getValue()) { - props.add (new DependencyPathPropertyComponent (getRTASPathValue(), "RTAS SDK Folder"), + props.add (new DependencyPathPropertyComponent (project.getFile().getParentDirectory(), getRTASPathValue(), "RTAS SDK Folder"), "If you're building an RTAS, this must be the folder containing the RTAS SDK. This can be an absolute path, or a path relative to the Projucer project file."); } } diff --git a/extras/Projucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp b/extras/Projucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp index 69d9e3f6b6..8b6956f3fa 100644 --- a/extras/Projucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp +++ b/extras/Projucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp @@ -40,20 +40,27 @@ DependencyPathValueSource::DependencyPathValueSource (const Value& projectSettin globalSettingsValue.addListener (this); } -bool DependencyPathValueSource::isValidPath() const +bool DependencyPathValueSource::isValidPath (const File& relativeTo) const { // if we are on another OS than the one which this path setting is for, // we have no way of knowing whether the path is valid - so just assume it is: if (! appliesToThisOS()) return true; - return getAppSettings().isGlobalPathValid (globalKey, getValue().toString()); + return getAppSettings().isGlobalPathValid (relativeTo, globalKey, getValue().toString()); +} + +bool DependencyPathValueSource::isValidPath() const +{ + return isValidPath (File::getCurrentWorkingDirectory()); } //============================================================================== -DependencyPathPropertyComponent::DependencyPathPropertyComponent (const Value& value, +DependencyPathPropertyComponent::DependencyPathPropertyComponent (const File& pathRelativeToUse, + const Value& value, const String& propertyName) try : TextPropertyComponent (propertyName, 1024, false), + pathRelativeTo (pathRelativeToUse), pathValue (value), pathValueSource (dynamic_cast (pathValue.getValueSource())) { @@ -100,11 +107,11 @@ void DependencyPathPropertyComponent::textWasEdited() Colour DependencyPathPropertyComponent::getTextColourToDisplay() const { if (! pathValueSource.isUsingProjectSettings()) - return pathValueSource.isValidPath() ? Colours::grey - : Colours::lightpink; + return pathValueSource.isValidPath (pathRelativeTo) ? Colours::grey + : Colours::lightpink; - return pathValueSource.isValidPath() ? Colours::black - : Colours::red; + return pathValueSource.isValidPath (pathRelativeTo) ? Colours::black + : Colours::red; } void DependencyPathPropertyComponent::labelTextChanged (Label*) diff --git a/extras/Projucer/Source/Project/jucer_DependencyPathPropertyComponent.h b/extras/Projucer/Source/Project/jucer_DependencyPathPropertyComponent.h index 36dd1f599f..582e7c8dd9 100644 --- a/extras/Projucer/Source/Project/jucer_DependencyPathPropertyComponent.h +++ b/extras/Projucer/Source/Project/jucer_DependencyPathPropertyComponent.h @@ -82,6 +82,8 @@ public: return os == TargetOS::getThisOS(); } + bool isValidPath (const File& relativeTo) const; + bool isValidPath() const; private: @@ -143,7 +145,8 @@ class DependencyPathPropertyComponent : public TextPropertyComponent, private Label::Listener { public: - DependencyPathPropertyComponent (const Value& value, + DependencyPathPropertyComponent (const File& pathRelativeToUse, + const Value& value, const String& propertyName); @@ -158,6 +161,10 @@ private: /** This function handles path changes because the global path changed. */ void valueChanged (Value& value) override; + /** If the dependency path is relative, relative to which directory should + we check if an object is available. */ + File pathRelativeTo; + /** the value that represents this dependency path setting. */ Value pathValue; diff --git a/extras/Projucer/Source/Utility/jucer_StoredSettings.cpp b/extras/Projucer/Source/Utility/jucer_StoredSettings.cpp index 4f5f2d688c..f4359176b5 100644 --- a/extras/Projucer/Source/Utility/jucer_StoredSettings.cpp +++ b/extras/Projucer/Source/Utility/jucer_StoredSettings.cpp @@ -218,10 +218,10 @@ void StoredSettings::ColourSelectorWithSwatches::setSwatchColour (int index, con } //============================================================================== -static bool doesSDKPathContainFile (const String& path, const String& fileToCheckFor) +static bool doesSDKPathContainFile (const File& relativeTo, const String& path, const String& fileToCheckFor) { String actualPath = path.replace ("${user.home}", File::getSpecialLocation (File::userHomeDirectory).getFullPathName()); - return File::getCurrentWorkingDirectory().getChildFile (actualPath + "/" + fileToCheckFor).existsAsFile(); + return relativeTo.getChildFile (actualPath + "/" + fileToCheckFor).existsAsFile(); } Value StoredSettings::getGlobalPath (const Identifier& key, DependencyPathOS os) @@ -271,7 +271,7 @@ String StoredSettings::getFallbackPath (const Identifier& key, DependencyPathOS return String(); } -bool StoredSettings::isGlobalPathValid (const Identifier& key, const String& path) +bool StoredSettings::isGlobalPathValid (const File& relativeTo, const Identifier& key, const String& path) { String fileToCheckFor; @@ -310,5 +310,5 @@ bool StoredSettings::isGlobalPathValid (const Identifier& key, const String& pat return false; } - return doesSDKPathContainFile (path, fileToCheckFor); + return doesSDKPathContainFile (relativeTo, path, fileToCheckFor); } diff --git a/extras/Projucer/Source/Utility/jucer_StoredSettings.h b/extras/Projucer/Source/Utility/jucer_StoredSettings.h index 136450a685..96ac576dbe 100644 --- a/extras/Projucer/Source/Utility/jucer_StoredSettings.h +++ b/extras/Projucer/Source/Utility/jucer_StoredSettings.h @@ -67,7 +67,8 @@ public: //============================================================================== Value getGlobalPath (const Identifier& key, DependencyPathOS); String getFallbackPath (const Identifier& key, DependencyPathOS); - bool isGlobalPathValid (const Identifier& key, const String& path); + + bool isGlobalPathValid (const File& relativeTo, const Identifier& key, const String& path); private: OwnedArray propertyFiles;