From d9cd459032c367033bc47e60977e301447501a9a Mon Sep 17 00:00:00 2001 From: Timur Doumler Date: Thu, 13 Aug 2015 11:08:03 +0100 Subject: [PATCH 1/7] Moved dependency path key strings into better location (DependencyPath utility class) --- .../Application/jucer_GlobalPreferences.cpp | 54 +++++++++---------- .../Application/jucer_GlobalPreferences.h | 3 -- .../jucer_ProjectExport_Android.h | 4 +- .../Source/Project/jucer_AudioPluginModule.h | 6 +-- .../jucer_DependencyPathPropertyComponent.cpp | 7 +++ .../jucer_DependencyPathPropertyComponent.h | 6 ++- 6 files changed, 41 insertions(+), 39 deletions(-) diff --git a/extras/Introjucer/Source/Application/jucer_GlobalPreferences.cpp b/extras/Introjucer/Source/Application/jucer_GlobalPreferences.cpp index 6bfb7db16e..5948b27434 100644 --- a/extras/Introjucer/Source/Application/jucer_GlobalPreferences.cpp +++ b/extras/Introjucer/Source/Application/jucer_GlobalPreferences.cpp @@ -12,13 +12,7 @@ #include "jucer_GlobalPreferences.h" -//============================================================================== -const String PathSettingsTab::vst2KeyName = "vst2Path"; -const String PathSettingsTab::vst3KeyName = "vst3Path"; -const String PathSettingsTab::rtasKeyName = "rtasPath"; -const String PathSettingsTab::aaxKeyName = "aaxPath"; -const String PathSettingsTab::androidSdkKeyName = "androidSdkPath"; -const String PathSettingsTab::androidNdkKeyName = "androidNdkPath"; + //============================================================================== class AppearanceSettingsTab : public GlobalPreferencesTab, @@ -47,16 +41,16 @@ PathSettingsTab::PathSettingsTab (DependencyPathOS os) { const int maxChars = 1024; - vst2PathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (vst2KeyName, os), "VST SDK", maxChars, false)); - vst3PathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (vst3KeyName, os), "VST3 SDK", maxChars, false)); + vst2PathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (DependencyPath::vst2KeyName, os), "VST SDK", maxChars, false)); + vst3PathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (DependencyPath::vst3KeyName, os), "VST3 SDK", maxChars, false)); #if ! JUCE_LINUX - rtasPathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (rtasKeyName, os), "RTAS SDK", maxChars, false)); - aaxPathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (aaxKeyName, os), "AAX SDK", maxChars, false)); + rtasPathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (DependencyPath::rtasKeyName, os), "RTAS SDK", maxChars, false)); + aaxPathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (DependencyPath::aaxKeyName, os), "AAX SDK", maxChars, false)); #endif - androidSdkPathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (androidSdkKeyName, os), "Android SDK", maxChars, false)); - androidNdkPathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (androidNdkKeyName, os), "Android NDK", maxChars, false)); + androidSdkPathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (DependencyPath::androidSdkKeyName, os), "Android SDK", maxChars, false)); + androidNdkPathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (DependencyPath::androidNdkKeyName, os), "Android NDK", maxChars, false)); for (TextPropertyComponent** component = pathComponents.begin(); component != pathComponents.end(); ++component) { @@ -80,12 +74,12 @@ void PathSettingsTab::textPropertyComponentChanged (TextPropertyComponent* textP String PathSettingsTab::getKeyForPropertyComponent (TextPropertyComponent* component) const { - if (component == vst2PathComponent) return vst2KeyName; - if (component == vst3PathComponent) return vst3KeyName; - if (component == rtasPathComponent) return rtasKeyName; - if (component == aaxPathComponent) return aaxKeyName; - if (component == androidSdkPathComponent) return androidSdkKeyName; - if (component == androidNdkPathComponent) return androidNdkKeyName; + if (component == vst2PathComponent) return DependencyPath::vst2KeyName; + if (component == vst3PathComponent) return DependencyPath::vst3KeyName; + if (component == rtasPathComponent) return DependencyPath::rtasKeyName; + if (component == aaxPathComponent) return DependencyPath::aaxKeyName; + if (component == androidSdkPathComponent) return DependencyPath::androidSdkKeyName; + if (component == androidNdkPathComponent) return DependencyPath::androidNdkKeyName; // this property component does not have a key associated to it! jassertfalse; @@ -128,11 +122,11 @@ Value& PathSettingsTab::getPathByKey (const String& key, DependencyPathOS os) //============================================================================== String PathSettingsTab::getFallbackPathByKey (const String& key, DependencyPathOS os) { - if (key == vst2KeyName || key == vst3KeyName) + if (key == DependencyPath::vst2KeyName || key == DependencyPath::vst3KeyName) return os == DependencyPath::windows ? "c:\\SDKs\\VST3 SDK" : "~/SDKs/VST3 SDK"; - if (key == rtasKeyName) + if (key == DependencyPath::rtasKeyName) { if (os == DependencyPath::windows) return "c:\\SDKs\\PT_80_SDK"; if (os == DependencyPath::osx) return "~/SDKs/PT_80_SDK"; @@ -142,7 +136,7 @@ String PathSettingsTab::getFallbackPathByKey (const String& key, DependencyPathO return String(); } - if (key == aaxKeyName) + if (key == DependencyPath::aaxKeyName) { if (os == DependencyPath::windows) return "c:\\SDKs\\AAX"; if (os == DependencyPath::osx) return "~/SDKs/AAX" ; @@ -152,11 +146,11 @@ String PathSettingsTab::getFallbackPathByKey (const String& key, DependencyPathO return String(); } - if (key == androidSdkKeyName) + if (key == DependencyPath::androidSdkKeyName) return os == DependencyPath::windows ? "c:\\SDKs\\android-sdk" : "~/Library/Android/sdk"; - if (key == androidNdkKeyName) + if (key == DependencyPath::androidNdkKeyName) return os == DependencyPath::windows ? "c:\\SDKs\\android-ndk" : "~/Library/Android/ndk"; @@ -170,23 +164,23 @@ bool PathSettingsTab::checkPathByKey (const String& key, const String& path) { String fileToCheckFor; - if (key == vst2KeyName) + if (key == DependencyPath::vst2KeyName) { fileToCheckFor = "public.sdk/source/vst2.x/audioeffectx.h"; } - else if (key == vst3KeyName) + else if (key == DependencyPath::vst3KeyName) { fileToCheckFor = "base/source/baseiids.cpp"; } - else if (key == rtasKeyName) + else if (key == DependencyPath::rtasKeyName) { fileToCheckFor = "AlturaPorts/TDMPlugIns/PlugInLibrary/EffectClasses/CEffectProcessMIDI.cpp"; } - else if (key == aaxKeyName) + else if (key == DependencyPath::aaxKeyName) { fileToCheckFor = "Interfaces/AAX_Exports.cpp"; } - else if (key == androidSdkKeyName) + else if (key == DependencyPath::androidSdkKeyName) { #if JUCE_WINDOWS fileToCheckFor = "platform-tools/adb.exe"; @@ -194,7 +188,7 @@ bool PathSettingsTab::checkPathByKey (const String& key, const String& path) fileToCheckFor = "platform-tools/adb"; #endif } - else if (key == androidNdkKeyName) + else if (key == DependencyPath::androidNdkKeyName) { #if JUCE_WINDOWS fileToCheckFor = "ndk-depends.exe"; diff --git a/extras/Introjucer/Source/Application/jucer_GlobalPreferences.h b/extras/Introjucer/Source/Application/jucer_GlobalPreferences.h index d5a3a8330c..9e9f66714f 100644 --- a/extras/Introjucer/Source/Application/jucer_GlobalPreferences.h +++ b/extras/Introjucer/Source/Application/jucer_GlobalPreferences.h @@ -47,9 +47,6 @@ public: static String getFallbackPathByKey (const String& key, DependencyPathOS); static bool checkPathByKey (const String& key, const String& path); - const static String vst2KeyName, vst3KeyName, rtasKeyName, aaxKeyName, - androidSdkKeyName, androidNdkKeyName; - private: void textPropertyComponentChanged (TextPropertyComponent*) override; diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h index bc199430e6..52e1abe207 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h @@ -83,10 +83,10 @@ public: props.add (new TextPropertyComponent (getVersionCodeValue(), "Android Version Code", 32, false), "An integer value that represents the version of the application code, relative to other versions."); - props.add (new DependencyPathPropertyComponent (getSDKPathValue(), "Android SDK Path", PathSettingsTab::androidSdkKeyName), + props.add (new DependencyPathPropertyComponent (getSDKPathValue(), "Android SDK Path", DependencyPath::androidSdkKeyName), "The path to the Android SDK folder on the target build machine"); - props.add (new DependencyPathPropertyComponent (getNDKPathValue(), "Android NDK Path", PathSettingsTab::androidNdkKeyName), + props.add (new DependencyPathPropertyComponent (getNDKPathValue(), "Android NDK Path", DependencyPath::androidNdkKeyName), "The path to the Android NDK folder on the target build machine"); props.add (new TextPropertyComponent (getMinimumSDKVersionValue(), "Minimum SDK version", 32, false), diff --git a/extras/Introjucer/Source/Project/jucer_AudioPluginModule.h b/extras/Introjucer/Source/Project/jucer_AudioPluginModule.h index 66a3b9eca5..e581106d36 100644 --- a/extras/Introjucer/Source/Project/jucer_AudioPluginModule.h +++ b/extras/Introjucer/Source/Project/jucer_AudioPluginModule.h @@ -266,7 +266,7 @@ namespace VSTHelpers props.add (new DependencyPathPropertyComponent (getVSTFolder (exporter, isVST3), vstFormat + " Folder", - isVST3 ? PathSettingsTab::vst3KeyName : PathSettingsTab::vst2KeyName, + isVST3 ? DependencyPath::vst3KeyName : DependencyPath::vst2KeyName, getDependencyPathOS (exporter)), "If you're building a " + vstFormat + ", this must be the folder containing the " + vstFormat + " SDK. This should be an absolute path."); } @@ -476,7 +476,7 @@ namespace RTASHelpers props.add (new DependencyPathPropertyComponent (getRTASFolder (exporter), "RTAS Folder", - PathSettingsTab::rtasKeyName, + DependencyPath::rtasKeyName, getDependencyPathOS (exporter)), "If you're building an RTAS, this must be the folder containing the RTAS SDK. This should be an absolute path."); } @@ -663,7 +663,7 @@ namespace AAXHelpers props.add (new DependencyPathPropertyComponent (getAAXFolder (exporter), "AAX SDK Folder", - PathSettingsTab::aaxKeyName, + DependencyPath::aaxKeyName, getDependencyPathOS (exporter)), "If you're building an AAX, this must be the folder containing the AAX SDK. This should be an absolute path."); } diff --git a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp index 757affefb2..1295867c7d 100644 --- a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp +++ b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp @@ -12,6 +12,13 @@ #include "jucer_DependencyPathPropertyComponent.h" #include "../Application/jucer_GlobalPreferences.h" +//============================================================================== +const String DependencyPath::vst2KeyName = "vst2Path"; +const String DependencyPath::vst3KeyName = "vst3Path"; +const String DependencyPath::rtasKeyName = "rtasPath"; +const String DependencyPath::aaxKeyName = "aaxPath"; +const String DependencyPath::androidSdkKeyName = "androidSdkPath"; +const String DependencyPath::androidNdkKeyName = "androidNdkPath"; //============================================================================== DependencyPathPropertyComponent::DependencyPathPropertyComponent (const Value& value, diff --git a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h index cbe11ae324..62642c29e1 100644 --- a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h +++ b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h @@ -12,8 +12,9 @@ #define JUCER_DEPENDENCYPATHPROPERTYCOMPONENT_H_INCLUDED //============================================================================== -namespace DependencyPath +class DependencyPath { +public: enum OS { windows = 0, @@ -34,6 +35,9 @@ namespace DependencyPath return DependencyPath::unknown; #endif } + + const static String vst2KeyName, vst3KeyName, rtasKeyName, aaxKeyName, + androidSdkKeyName, androidNdkKeyName; }; typedef DependencyPath::OS DependencyPathOS; From af9762885bf2ec71d14138740c78eea3f8fa15c7 Mon Sep 17 00:00:00 2001 From: Timur Doumler Date: Thu, 13 Aug 2015 12:53:22 +0100 Subject: [PATCH 2/7] Refactoring: moved isValidPath() check to the DependencyPathValueSource, to make the DependencyPathPropertyComponent responsible for GUI only. --- .../jucer_DependencyPathPropertyComponent.cpp | 38 ++++++++++--------- .../jucer_DependencyPathPropertyComponent.h | 20 +++++----- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp index 1295867c7d..251546cdcf 100644 --- a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp +++ b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp @@ -20,16 +20,28 @@ const String DependencyPath::aaxKeyName = "aaxPath"; const String DependencyPath::androidSdkKeyName = "androidSdkPath"; const String DependencyPath::androidNdkKeyName = "androidNdkPath"; +//============================================================================== + +bool DependencyPathValueSource::isValidPath() 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 PathSettingsTab::checkPathByKey (globalKey, getValue().toString()); +} + //============================================================================== DependencyPathPropertyComponent::DependencyPathPropertyComponent (const Value& value, const String& propertyName, - const String& globalKeyName, + const String& globalKey, DependencyPathOS os) : TextPropertyComponent (propertyName, 1024, false), - globalKey (globalKeyName), pathValueSource (new DependencyPathValueSource (value, - PathSettingsTab::getPathByKey (globalKeyName, os), - PathSettingsTab::getFallbackPathByKey (globalKeyName, os), + PathSettingsTab::getPathByKey (globalKey, os), + PathSettingsTab::getFallbackPathByKey (globalKey, os), + globalKey, os)), pathValue (pathValueSource) { @@ -66,21 +78,11 @@ void DependencyPathPropertyComponent::textWasEdited() Colour DependencyPathPropertyComponent::getTextColourToDisplay() const { if (! pathValueSource->isUsingProjectSettings()) - return isValidPath() ? Colours::grey - : Colours::lightpink; + return pathValueSource->isValidPath() ? Colours::grey + : Colours::lightpink; - return isValidPath() ? Colours::black - : Colours::red; -} - -bool DependencyPathPropertyComponent::isValidPath() 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 (! pathValueSource->appliesToThisOS()) - return true; - - return PathSettingsTab::checkPathByKey (globalKey, getValue().toString()); + return pathValueSource->isValidPath() ? Colours::black + : Colours::red; } void DependencyPathPropertyComponent::labelTextChanged (Label*) diff --git a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h index 62642c29e1..bb6b124bd0 100644 --- a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h +++ b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h @@ -56,10 +56,12 @@ public: DependencyPathValueSource (const Value& projectSettingsPath, const Value& globalSettingsPath, const String& fallbackPath, + String globalSettingsKey, DependencyPathOS osThisSettingAppliesTo) : projectSettingsValue (projectSettingsPath), globalSettingsValue (globalSettingsPath), fallbackValue (fallbackPath), + globalKey (globalSettingsKey), os (osThisSettingAppliesTo) { globalSettingsValue.addListener (this); @@ -106,6 +108,8 @@ public: return os == DependencyPath::getThisOS(); } + bool isValidPath() const; + private: void valueChanged (Value& value) override { @@ -147,10 +151,14 @@ private: OS than the ome this machine is running. */ String fallbackValue; + /** the global key used in the application settings for the global setting value. + needed for checking whether the path is valid. */ + String globalKey; + /** on what operating system should this dependency path be used? - note that this is *not* the os that is targeted by the project, - but rather the os on which the project will be compiled - (= on which the path settings need to be set correctly). */ + note that this is *not* the os that is targeted by the project, + but rather the os on which the project will be compiled + (= on which the path settings need to be set correctly). */ DependencyPathOS os; }; @@ -178,12 +186,6 @@ private: /** This function handles path changes because the global path changed. */ void valueChanged (Value& value) override; - /** Check if the current value is a valid path. */ - bool isValidPath() const; - - /** the property key of the global property that this component is tracking. */ - String globalKey; - /** the value source of this dependency path setting. */ DependencyPathValueSource* pathValueSource; From f4c91eca99ee68723150dd201358fa38b01ebca0 Mon Sep 17 00:00:00 2001 From: Timur Doumler Date: Thu, 13 Aug 2015 14:47:24 +0100 Subject: [PATCH 3/7] Fixed exporting global/fallback path settings for Android exporter by moving Android SDK/NDK DependencyPathValueSource ownership into the project. --- .../jucer_ProjectExport_Android.h | 29 +++++++++--- .../jucer_DependencyPathPropertyComponent.cpp | 43 +++++++++++------- .../jucer_DependencyPathPropertyComponent.h | 44 +++++++------------ 3 files changed, 66 insertions(+), 50 deletions(-) diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h index 52e1abe207..fa54d1d05f 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h @@ -38,7 +38,8 @@ public: } //============================================================================== - AndroidProjectExporter (Project& p, const ValueTree& t) : ProjectExporter (p, t) + AndroidProjectExporter (Project& p, const ValueTree& t) + : ProjectExporter (p, t) { name = getNameAndroid(); @@ -62,6 +63,18 @@ public: if (getKeyAliasValue().getValue().isVoid()) getKeyAliasValue() = "androiddebugkey"; if (getKeyAliasPassValue().getValue().isVoid()) getKeyAliasPassValue() = "android"; if (getCPP11EnabledValue().getValue().isVoid()) getCPP11EnabledValue() = true; + + sdkPath = Value (new DependencyPathValueSource ( + getSetting (Ids::androidSDKPath), + DependencyPath::androidSdkKeyName, + DependencyPath::getThisOS() + )); + + ndkPath = Value (new DependencyPathValueSource ( + getSetting (Ids::androidNDKPath), + DependencyPath::androidNdkKeyName, + DependencyPath::getThisOS() + )); } //============================================================================== @@ -83,10 +96,10 @@ public: props.add (new TextPropertyComponent (getVersionCodeValue(), "Android Version Code", 32, false), "An integer value that represents the version of the application code, relative to other versions."); - props.add (new DependencyPathPropertyComponent (getSDKPathValue(), "Android SDK Path", DependencyPath::androidSdkKeyName), + props.add (new DependencyPathPropertyComponent (getSDKPathValue(), "Android SDK Path"), "The path to the Android SDK folder on the target build machine"); - props.add (new DependencyPathPropertyComponent (getNDKPathValue(), "Android NDK Path", DependencyPath::androidNdkKeyName), + props.add (new DependencyPathPropertyComponent (getNDKPathValue(), "Android NDK Path"), "The path to the Android NDK folder on the target build machine"); props.add (new TextPropertyComponent (getMinimumSDKVersionValue(), "Minimum SDK version", 32, false), @@ -132,10 +145,10 @@ public: String getActivitySubClassPath() const { return settings [Ids::androidActivitySubClassName]; } Value getVersionCodeValue() { return getSetting (Ids::androidVersionCode); } String getVersionCodeString() const { return settings [Ids::androidVersionCode]; } - Value getSDKPathValue() { return getSetting (Ids::androidSDKPath); } - String getSDKPathString() const { return settings [Ids::androidSDKPath]; } - Value getNDKPathValue() { return getSetting (Ids::androidNDKPath); } - String getNDKPathString() const { return settings [Ids::androidNDKPath]; } + Value getSDKPathValue() { return sdkPath; } + String getSDKPathString() const { return sdkPath.toString(); } + Value getNDKPathValue() { return ndkPath; } + String getNDKPathString() const { return ndkPath.toString(); } Value getNDKToolchainVersionValue() { return getSetting (Ids::toolset); } String getNDKToolchainVersionString() const { return settings [Ids::toolset]; } @@ -749,5 +762,7 @@ private: } //============================================================================== + Value sdkPath, ndkPath; + JUCE_DECLARE_NON_COPYABLE (AndroidProjectExporter) }; diff --git a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp index 251546cdcf..662a40b8cf 100644 --- a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp +++ b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp @@ -22,6 +22,18 @@ const String DependencyPath::androidNdkKeyName = "androidNdkPath"; //============================================================================== +DependencyPathValueSource::DependencyPathValueSource (const Value& projectSettingsPath, + String globalSettingsKey, + DependencyPathOS osThisSettingAppliesTo) + : projectSettingsValue (projectSettingsPath), + globalKey (globalSettingsKey), + os (osThisSettingAppliesTo), + globalSettingsValue (PathSettingsTab::getPathByKey (globalKey, os)), + fallbackValue (PathSettingsTab::getFallbackPathByKey (globalKey, os)) +{ + globalSettingsValue.addListener (this); +} + bool DependencyPathValueSource::isValidPath() const { // if we are on another OS than the one which this path setting is for, @@ -34,16 +46,10 @@ bool DependencyPathValueSource::isValidPath() const //============================================================================== DependencyPathPropertyComponent::DependencyPathPropertyComponent (const Value& value, - const String& propertyName, - const String& globalKey, - DependencyPathOS os) - : TextPropertyComponent (propertyName, 1024, false), - pathValueSource (new DependencyPathValueSource (value, - PathSettingsTab::getPathByKey (globalKey, os), - PathSettingsTab::getFallbackPathByKey (globalKey, os), - globalKey, - os)), - pathValue (pathValueSource) + const String& propertyName) +try : TextPropertyComponent (propertyName, 1024, false), + pathValue (value), + pathValueSource (dynamic_cast (pathValue.getValueSource())) { bool initialValueIsEmpty = value.toString().isEmpty(); @@ -60,12 +66,19 @@ DependencyPathPropertyComponent::DependencyPathPropertyComponent (const Value& v else jassertfalse; } +catch (const std::bad_cast&) +{ + // a DependencyPathPropertyComponent must be initialised with a Value + // that is referring to a DependencyPathValueSource! + jassertfalse; + throw; +} void DependencyPathPropertyComponent::valueChanged (Value& value) { // this callback handles the update of this setting in case // the user changed the global preferences. - if (value.refersToSameSourceAs (pathValue) && pathValueSource->isUsingGlobalSettings()) + if (value.refersToSameSourceAs (pathValue) && pathValueSource.isUsingGlobalSettings()) textWasEdited(); } @@ -77,11 +90,11 @@ void DependencyPathPropertyComponent::textWasEdited() Colour DependencyPathPropertyComponent::getTextColourToDisplay() const { - if (! pathValueSource->isUsingProjectSettings()) - return pathValueSource->isValidPath() ? Colours::grey + if (! pathValueSource.isUsingProjectSettings()) + return pathValueSource.isValidPath() ? Colours::grey : Colours::lightpink; - return pathValueSource->isValidPath() ? Colours::black + return pathValueSource.isValidPath() ? Colours::black : Colours::red; } @@ -91,7 +104,7 @@ void DependencyPathPropertyComponent::labelTextChanged (Label*) void DependencyPathPropertyComponent::editorShown (Label* /*label*/, TextEditor& editor) { - if (! pathValueSource->isUsingProjectSettings()) + if (! pathValueSource.isUsingProjectSettings()) editor.setText (String::empty, dontSendNotification); } diff --git a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h index bb6b124bd0..fd897a7c33 100644 --- a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h +++ b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h @@ -54,18 +54,8 @@ class DependencyPathValueSource : public Value::ValueSource, { public: DependencyPathValueSource (const Value& projectSettingsPath, - const Value& globalSettingsPath, - const String& fallbackPath, String globalSettingsKey, - DependencyPathOS osThisSettingAppliesTo) - : projectSettingsValue (projectSettingsPath), - globalSettingsValue (globalSettingsPath), - fallbackValue (fallbackPath), - globalKey (globalSettingsKey), - os (osThisSettingAppliesTo) - { - globalSettingsValue.addListener (this); - } + DependencyPathOS osThisSettingAppliesTo = DependencyPath::getThisOS()); /** This gets the currently used value, which may be either the project setting, the global setting, or the fallback value. */ @@ -142,6 +132,16 @@ private: /** the dependency path setting as set in this Introjucer project. */ Value projectSettingsValue; + /** the global key used in the application settings for the global setting value. + needed for checking whether the path is valid. */ + String globalKey; + + /** on what operating system should this dependency path be used? + note that this is *not* the os that is targeted by the project, + but rather the os on which the project will be compiled + (= on which the path settings need to be set correctly). */ + DependencyPathOS os; + /** the dependency path global setting on this machine. used when there value set for this project is invalid. */ Value globalSettingsValue; @@ -150,16 +150,6 @@ private: whenever the latter doesn't apply, e.g. the setting is for another OS than the ome this machine is running. */ String fallbackValue; - - /** the global key used in the application settings for the global setting value. - needed for checking whether the path is valid. */ - String globalKey; - - /** on what operating system should this dependency path be used? - note that this is *not* the os that is targeted by the project, - but rather the os on which the project will be compiled - (= on which the path settings need to be set correctly). */ - DependencyPathOS os; }; @@ -170,9 +160,7 @@ class DependencyPathPropertyComponent : public TextPropertyComponent, { public: DependencyPathPropertyComponent (const Value& value, - const String& propertyName, - const String& globalKey, - DependencyPathOS os = DependencyPath::getThisOS()); + const String& propertyName); private: @@ -186,12 +174,12 @@ private: /** This function handles path changes because the global path changed. */ void valueChanged (Value& value) override; - /** the value source of this dependency path setting. */ - DependencyPathValueSource* pathValueSource; - - /** the value object around the value source. */ + /** the value that represents this dependency path setting. */ Value pathValue; + /** a reference to the value source that this value refers to. */ + DependencyPathValueSource& pathValueSource; + // Label::Listener overrides: void labelTextChanged (Label* labelThatHasChanged) override; void editorShown (Label*, TextEditor&) override; From 7ea0ab19fde27fe938fe732ba9c456ba2015ec13 Mon Sep 17 00:00:00 2001 From: Timur Doumler Date: Thu, 13 Aug 2015 15:13:33 +0100 Subject: [PATCH 4/7] Refactoring: moved getVST/AAX/RTASFolder() into Exporter so it can use a DependencyPathValueSource instead of the project setting. --- .../Project Saving/jucer_ProjectExporter.h | 5 ++ .../Source/Project/jucer_AudioPluginModule.h | 58 +++++++++---------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h index 96ddd244a2..56e66d3aef 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h @@ -114,6 +114,10 @@ public: Value getUserNotes() { return getSetting (Ids::userNotes); } + Value getVSTPathValue (bool isVST3) const { return isVST3 ? vst3Path : vst2Path; } + Value getRTASPathValue() const { return rtasPath; } + Value getAAXPathValue() const { return aaxPath; } + // NB: this is the path to the parent "modules" folder that contains the named module, not the // module folder itself. Value getPathForModuleValue (const String& moduleID); @@ -329,6 +333,7 @@ protected: const ProjectType& projectType; const String projectName; const File projectFolder; + Value vst2Path, vst3Path, rtasPath, aaxPath; // these must be initialised in the specific exporter c'tors! mutable Array itemGroups; void initItemGroups() const; diff --git a/extras/Introjucer/Source/Project/jucer_AudioPluginModule.h b/extras/Introjucer/Source/Project/jucer_AudioPluginModule.h index e581106d36..8cbd3516a8 100644 --- a/extras/Introjucer/Source/Project/jucer_AudioPluginModule.h +++ b/extras/Introjucer/Source/Project/jucer_AudioPluginModule.h @@ -239,15 +239,9 @@ namespace //============================================================================== namespace VSTHelpers { - static Value getVSTFolder (ProjectExporter& exporter, bool isVST3) - { - return exporter.getSetting (isVST3 ? Ids::vst3Folder - : Ids::vstFolder); - } - static void addVSTFolderToPath (ProjectExporter& exporter, bool isVST3) { - const String vstFolder (getVSTFolder (exporter, isVST3).toString()); + const String vstFolder (exporter.getVSTPathValue (isVST3).toString()); if (vstFolder.isNotEmpty()) { @@ -264,10 +258,8 @@ namespace VSTHelpers { const String vstFormat (isVST3 ? "VST3" : "VST"); - props.add (new DependencyPathPropertyComponent (getVSTFolder (exporter, isVST3), - vstFormat + " Folder", - isVST3 ? DependencyPath::vst3KeyName : DependencyPath::vst2KeyName, - getDependencyPathOS (exporter)), + props.add (new DependencyPathPropertyComponent (exporter.getVSTPathValue (isVST3), + vstFormat + " Folder"), "If you're building a " + vstFormat + ", this must be the folder containing the " + vstFormat + " SDK. This should be an absolute path."); } @@ -326,15 +318,19 @@ namespace VSTHelpers //============================================================================== namespace RTASHelpers { - static Value getRTASFolder (ProjectExporter& exporter) { return exporter.getSetting (Ids::rtasFolder); } - static RelativePath getRTASFolderPath (ProjectExporter& exporter) { return RelativePath (exporter.getSettingString (Ids::rtasFolder), - RelativePath::projectFolder); } + static RelativePath getRTASRelativeFolderPath (ProjectExporter& exporter) + { + return RelativePath (exporter.getRTASPathValue().toString(), RelativePath::projectFolder); + } - static bool isExporterSupported (ProjectExporter& exporter) { return exporter.isVisualStudio() || exporter.isXcode(); } + static bool isExporterSupported (ProjectExporter& exporter) + { + return exporter.isVisualStudio() || exporter.isXcode(); + } static void addExtraSearchPaths (ProjectExporter& exporter) { - RelativePath rtasFolder (getRTASFolderPath (exporter)); + RelativePath rtasFolder (getRTASRelativeFolderPath (exporter)); if (exporter.isVisualStudio()) { @@ -419,7 +415,7 @@ namespace RTASHelpers { fixMissingXcodePostBuildScript (exporter); - const RelativePath rtasFolder (getRTASFolderPath (exporter)); + const RelativePath rtasFolder (getRTASRelativeFolderPath (exporter)); if (exporter.isVisualStudio()) { @@ -474,10 +470,8 @@ namespace RTASHelpers { fixMissingXcodePostBuildScript (exporter); - props.add (new DependencyPathPropertyComponent (getRTASFolder (exporter), - "RTAS Folder", - DependencyPath::rtasKeyName, - getDependencyPathOS (exporter)), + props.add (new DependencyPathPropertyComponent (exporter.getRTASPathValue(), + "RTAS Folder"), "If you're building an RTAS, this must be the folder containing the RTAS SDK. This should be an absolute path."); } } @@ -611,15 +605,19 @@ namespace AUHelpers //============================================================================== namespace AAXHelpers { - static Value getAAXFolder (ProjectExporter& exporter) { return exporter.getSetting (Ids::aaxFolder); } - static RelativePath getAAXFolderPath (ProjectExporter& exporter) { return RelativePath (exporter.getSettingString (Ids::aaxFolder), - RelativePath::projectFolder); } + static RelativePath getAAXRelativeFolderPath (ProjectExporter& exporter) + { + return RelativePath (exporter.getAAXPathValue().toString(), RelativePath::projectFolder); + } - static bool isExporterSupported (ProjectExporter& exporter) { return exporter.isVisualStudio() || exporter.isXcode(); } + static bool isExporterSupported (ProjectExporter& exporter) + { + return exporter.isVisualStudio() || exporter.isXcode(); + } static void addExtraSearchPaths (ProjectExporter& exporter) { - const RelativePath aaxFolder (getAAXFolderPath (exporter)); + const RelativePath aaxFolder (getAAXRelativeFolderPath (exporter)); exporter.addToExtraSearchPaths (aaxFolder); exporter.addToExtraSearchPaths (aaxFolder.getChildFile ("Interfaces")); @@ -632,7 +630,7 @@ namespace AAXHelpers { fixMissingXcodePostBuildScript (exporter); - const RelativePath aaxLibsFolder (getAAXFolderPath (exporter).getChildFile ("Libs")); + const RelativePath aaxLibsFolder (getAAXRelativeFolderPath (exporter).getChildFile ("Libs")); if (exporter.isVisualStudio()) { @@ -661,10 +659,8 @@ namespace AAXHelpers { fixMissingXcodePostBuildScript (exporter); - props.add (new DependencyPathPropertyComponent (getAAXFolder (exporter), - "AAX SDK Folder", - DependencyPath::aaxKeyName, - getDependencyPathOS (exporter)), + props.add (new DependencyPathPropertyComponent (exporter.getAAXPathValue(), + "AAX SDK Folder"), "If you're building an AAX, this must be the folder containing the AAX SDK. This should be an absolute path."); } } From a178731a95378dd06ab3dfa17fe6650cee06cade Mon Sep 17 00:00:00 2001 From: Timur Doumler Date: Thu, 13 Aug 2015 17:47:01 +0100 Subject: [PATCH 5/7] refactoring: put initialisation of dependency path values into the individual exporters, called from their constructors. --- .../jucer_ProjectExport_Android.h | 27 +++++++++------ .../jucer_ProjectExport_CodeBlocks.h | 34 +++++++++++++++++++ .../Project Saving/jucer_ProjectExport_MSVC.h | 29 ++++++++++++++++ .../Project Saving/jucer_ProjectExport_Make.h | 17 ++++++++++ .../jucer_ProjectExport_XCode.h | 29 ++++++++++++++++ .../Source/Project/jucer_AudioPluginModule.h | 11 ------ .../jucer_DependencyPathPropertyComponent.h | 2 +- 7 files changed, 126 insertions(+), 23 deletions(-) diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h index fa54d1d05f..b84dbbc2f1 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h @@ -64,17 +64,7 @@ public: if (getKeyAliasPassValue().getValue().isVoid()) getKeyAliasPassValue() = "android"; if (getCPP11EnabledValue().getValue().isVoid()) getCPP11EnabledValue() = true; - sdkPath = Value (new DependencyPathValueSource ( - getSetting (Ids::androidSDKPath), - DependencyPath::androidSdkKeyName, - DependencyPath::getThisOS() - )); - - ndkPath = Value (new DependencyPathValueSource ( - getSetting (Ids::androidNDKPath), - DependencyPath::androidNdkKeyName, - DependencyPath::getThisOS() - )); + initialiseDependencyPathValues(); } //============================================================================== @@ -761,6 +751,21 @@ private: writeXmlOrThrow (strings, file, "utf-8", 100); } + void initialiseDependencyPathValues() + { + sdkPath = Value (new DependencyPathValueSource ( + getSetting (Ids::androidSDKPath), + DependencyPath::androidSdkKeyName, + DependencyPath::getThisOS() + )); + + ndkPath = Value (new DependencyPathValueSource ( + getSetting (Ids::androidNDKPath), + DependencyPath::androidNdkKeyName, + DependencyPath::getThisOS() + )); + } + //============================================================================== Value sdkPath, ndkPath; diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_CodeBlocks.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_CodeBlocks.h index aee48437aa..615246be17 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_CodeBlocks.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_CodeBlocks.h @@ -89,6 +89,8 @@ public: if (getTargetLocationString().isEmpty()) getTargetLocationValue() = getDefaultBuildsRootFolder() + getTargetFolderName (os); + + initialiseDependencyPathValues(); } //============================================================================== @@ -401,6 +403,38 @@ private: xml.createNewChildElement ("Add")->setAttribute (nm, value); } + void initialiseDependencyPathValues() + { + DependencyPathOS pathOS = isLinux() ? DependencyPathOS::linux : DependencyPathOS::windows; + + vst2Path = Value (new DependencyPathValueSource ( + getSetting (Ids::vstFolder), + DependencyPath::vst2KeyName, + pathOS + )); + + vst3Path = Value (new DependencyPathValueSource ( + getSetting (Ids::vst3Folder), + DependencyPath::vst3KeyName, + pathOS + )); + + if (! isLinux()) + { + aaxPath = Value (new DependencyPathValueSource ( + getSetting (Ids::aaxFolder), + DependencyPath::aaxKeyName, + pathOS + )); + + rtasPath = Value (new DependencyPathValueSource ( + getSetting (Ids::rtasFolder), + DependencyPath::rtasKeyName, + pathOS + )); + } + } + CodeBlocksOS os; JUCE_DECLARE_NON_COPYABLE (CodeBlocksProjectExporter) diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h index 857b94cb35..84701428e5 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h @@ -33,6 +33,8 @@ public: projectGUID = createGUID (project.getProjectUID()); updateOldSettings(); + + initialiseDependencyPathValues(); } //============================================================================== @@ -555,6 +557,33 @@ protected: : (".\\" + filename); } + void initialiseDependencyPathValues() + { + vst2Path = Value (new DependencyPathValueSource ( + getSetting (Ids::vstFolder), + DependencyPath::vst2KeyName, + DependencyPathOS::windows + )); + + vst3Path = Value (new DependencyPathValueSource ( + getSetting (Ids::vst3Folder), + DependencyPath::vst3KeyName, + DependencyPathOS::windows + )); + + aaxPath = Value (new DependencyPathValueSource ( + getSetting (Ids::aaxFolder), + DependencyPath::aaxKeyName, + DependencyPathOS::windows + )); + + rtasPath = Value (new DependencyPathValueSource ( + getSetting (Ids::rtasFolder), + DependencyPath::rtasKeyName, + DependencyPathOS::windows + )); + } + JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterBase) }; diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h index 7f01e77088..80cb78068b 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h @@ -45,6 +45,8 @@ public: if (getTargetLocationString().isEmpty()) getTargetLocationValue() = getDefaultBuildsRootFolder() + "LinuxMakefile"; + + initialiseDependencyPathValues(); } //============================================================================== @@ -346,5 +348,20 @@ private: + "_" + String::toHexString (file.toUnixStyle().hashCode()) + ".o"; } + void initialiseDependencyPathValues() + { + vst2Path = Value (new DependencyPathValueSource ( + getSetting (Ids::vstFolder), + DependencyPath::vst2KeyName, + DependencyPathOS::linux + )); + + vst3Path = Value (new DependencyPathValueSource ( + getSetting (Ids::vst3Folder), + DependencyPath::vst3KeyName, + DependencyPathOS::linux + )); + } + JUCE_DECLARE_NON_COPYABLE (MakefileProjectExporter) }; diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h index 95b4de0900..a0d69fa050 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h @@ -53,6 +53,8 @@ public: if (getTargetLocationString().isEmpty()) getTargetLocationValue() = getDefaultBuildsRootFolder() + (iOS ? "iOS" : "MacOSX"); + + initialiseDependencyPathValues(); } static XCodeProjectExporter* createForSettings (Project& project, const ValueTree& settings) @@ -1499,4 +1501,31 @@ private: jassert (version >= 4); return "10." + String (version) + " SDK"; } + + void initialiseDependencyPathValues() + { + vst2Path = Value (new DependencyPathValueSource ( + getSetting (Ids::vstFolder), + DependencyPath::vst2KeyName, + DependencyPathOS::osx + )); + + vst3Path = Value (new DependencyPathValueSource ( + getSetting (Ids::vst3Folder), + DependencyPath::vst3KeyName, + DependencyPathOS::osx + )); + + aaxPath = Value (new DependencyPathValueSource ( + getSetting (Ids::aaxFolder), + DependencyPath::aaxKeyName, + DependencyPathOS::osx + )); + + rtasPath = Value (new DependencyPathValueSource ( + getSetting (Ids::rtasFolder), + DependencyPath::rtasKeyName, + DependencyPathOS::osx + )); + } }; diff --git a/extras/Introjucer/Source/Project/jucer_AudioPluginModule.h b/extras/Introjucer/Source/Project/jucer_AudioPluginModule.h index 8cbd3516a8..f03551f253 100644 --- a/extras/Introjucer/Source/Project/jucer_AudioPluginModule.h +++ b/extras/Introjucer/Source/Project/jucer_AudioPluginModule.h @@ -223,17 +223,6 @@ namespace exporter.rebaseFromProjectFolderToBuildTarget (path) .toWindowsStyle()); } - - DependencyPathOS getDependencyPathOS (const ProjectExporter& exporter) - { - if (exporter.isWindows()) return DependencyPath::windows; - if (exporter.isXcode()) return DependencyPath::osx; - if (exporter.isLinux()) return DependencyPath::linux; - - // cannot figure out which OS's dependency paths this exporter wants!! - jassertfalse; - return DependencyPath::unknown; - } } //============================================================================== diff --git a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h index fd897a7c33..70b5ecd390 100644 --- a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h +++ b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h @@ -55,7 +55,7 @@ class DependencyPathValueSource : public Value::ValueSource, public: DependencyPathValueSource (const Value& projectSettingsPath, String globalSettingsKey, - DependencyPathOS osThisSettingAppliesTo = DependencyPath::getThisOS()); + DependencyPathOS osThisSettingAppliesTo); /** This gets the currently used value, which may be either the project setting, the global setting, or the fallback value. */ From aefd5d3725bc77d0aed4c54638acb314c5ea9db8 Mon Sep 17 00:00:00 2001 From: Timur Doumler Date: Thu, 13 Aug 2015 20:42:15 +0100 Subject: [PATCH 6/7] Indentation. --- extras/Introjucer/Source/Project/jucer_AudioPluginModule.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras/Introjucer/Source/Project/jucer_AudioPluginModule.h b/extras/Introjucer/Source/Project/jucer_AudioPluginModule.h index f03551f253..ee342b99dd 100644 --- a/extras/Introjucer/Source/Project/jucer_AudioPluginModule.h +++ b/extras/Introjucer/Source/Project/jucer_AudioPluginModule.h @@ -248,7 +248,7 @@ namespace VSTHelpers const String vstFormat (isVST3 ? "VST3" : "VST"); props.add (new DependencyPathPropertyComponent (exporter.getVSTPathValue (isVST3), - vstFormat + " Folder"), + vstFormat + " Folder"), "If you're building a " + vstFormat + ", this must be the folder containing the " + vstFormat + " SDK. This should be an absolute path."); } From a362dbe6aa35b3c49b864e6bb5a406993899ec01 Mon Sep 17 00:00:00 2001 From: Timur Doumler Date: Thu, 13 Aug 2015 20:42:40 +0100 Subject: [PATCH 7/7] Fixed bug in project path settings where global values were erroneously set to project-specific values. --- .../Source/Project/jucer_DependencyPathPropertyComponent.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp index 662a40b8cf..4c7504b784 100644 --- a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp +++ b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp @@ -51,10 +51,13 @@ try : TextPropertyComponent (propertyName, 1024, false), pathValue (value), pathValueSource (dynamic_cast (pathValue.getValueSource())) { - bool initialValueIsEmpty = value.toString().isEmpty(); + bool initialValueIsEmpty = ! pathValueSource.isUsingProjectSettings(); getValue().referTo (pathValue); + // the following step is necessary because the above referTo() has internally called setValue(), + // which has set the project value to whatever is displayed in the label (this may be the + // global/fallback value). In this case we have to reset the project value to blank: if (initialValueIsEmpty) getValue().setValue (String::empty);