From 24d02528e034641d1c48fe1ffe1a568d71aa3f72 Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 1 Mar 2017 18:41:57 +0000 Subject: [PATCH] Fixed an AAX bug where the Projucer's Xcode exporter would generate linker settings pointing to the wrong version of the AAXLibrary --- .../jucer_ProjectExport_XCode.h | 82 +++++++++++++------ 1 file changed, 58 insertions(+), 24 deletions(-) diff --git a/extras/Projucer/Source/Project Saving/jucer_ProjectExport_XCode.h b/extras/Projucer/Source/Project Saving/jucer_ProjectExport_XCode.h index 2f842b7944..b0602593b8 100644 --- a/extras/Projucer/Source/Project Saving/jucer_ProjectExport_XCode.h +++ b/extras/Projucer/Source/Project Saving/jucer_ProjectExport_XCode.h @@ -595,8 +595,6 @@ public: xcodeBundleExtension = ".aaxplugin"; xcodeProductType = "com.apple.product-type.bundle"; xcodeCopyToProductInstallPathAfterBuild = true; - - addExtraAAXTargetSettings(); break; case RTASPlugIn: @@ -867,23 +865,11 @@ public: } else { - const String sdk (config.osxSDKVersion.get()); - const String sdkCompat (config.osxDeploymentTarget.get()); - - // The AUv3 target always needs to be at least 10.11 - int oldestAllowedDeploymentTarget = (type == Target::AudioUnitv3PlugIn ? minimumAUv3SDKVersion - : oldestSDKVersion); + String sdkRoot; + s.add ("MACOSX_DEPLOYMENT_TARGET = " + getOSXDeploymentTarget(config, &sdkRoot)); - // if the user doesn't set it, then use the last known version that works well with JUCE - String deploymentTarget = "10.11"; - - for (int ver = oldestAllowedDeploymentTarget; ver <= currentSDKVersion; ++ver) - { - if (sdk == getSDKName (ver)) s.add ("SDKROOT = macosx10." + String (ver)); - if (sdkCompat == getSDKName (ver)) deploymentTarget = "10." + String (ver); - } - - s.add ("MACOSX_DEPLOYMENT_TARGET = " + deploymentTarget); + if (sdkRoot.isNotEmpty()) + s.add ("SDKROOT = " + sdkRoot); s.add ("MACOSX_DEPLOYMENT_TARGET_ppc = 10.4"); s.add ("SDKROOT_ppc = macosx10.5"); @@ -1005,8 +991,10 @@ public: if (getTargetFileType() == pluginBundle) flags.add (owner.isiOS() ? "-bitcode_bundle" : "-bundle"); - const Array& extraLibs = config.isDebug() ? xcodeExtraLibrariesDebug - : xcodeExtraLibrariesRelease; + Array extraLibs (config.isDebug() ? xcodeExtraLibrariesDebug + : xcodeExtraLibrariesRelease); + + addExtraLibsForTargetType (config, extraLibs); for (auto& lib : extraLibs) { @@ -1319,12 +1307,19 @@ public: xcodeExtraPListEntries.add (plistEntry); } - void addExtraAAXTargetSettings() + void addExtraLibsForTargetType (const BuildConfiguration& config, Array& extraLibs) const { - auto aaxLibsFolder = RelativePath (owner.getAAXPathValue().toString(), RelativePath::projectFolder).getChildFile ("Libs"); + if (type == AAXPlugIn) + { + auto aaxLibsFolder + = RelativePath (owner.getAAXPathValue().toString(), RelativePath::projectFolder) + .getChildFile ("Libs"); + + String libraryPath (config.isDebug() ? "Debug/libAAXLibrary" : "Release/libAAXLibrary"); + libraryPath += (isUsingClangCppLibrary (config) ? "_libcpp.a" : ".a"); - xcodeExtraLibrariesDebug.add (aaxLibsFolder.getChildFile ("Debug/libAAXLibrary.a")); - xcodeExtraLibrariesRelease.add (aaxLibsFolder.getChildFile ("Release/libAAXLibrary.a")); + extraLibs.add (aaxLibsFolder.getChildFile (libraryPath)); + } } StringArray getTargetExtraHeaderSearchPaths() const @@ -1383,6 +1378,45 @@ public: xcodeExtraLibrariesRelease.add (rtasFolder.getChildFile ("MacBag/Libs/Release/libPluginLibrary.a")); } + bool isUsingClangCppLibrary (const BuildConfiguration& config) const + { + if (auto xcodeConfig = dynamic_cast (&config)) + { + const String& configValue = xcodeConfig->cppStandardLibrary.get(); + + if (configValue.isNotEmpty()) + return (configValue == "libc++"); + + const int minorOSXDeploymentTarget + = getOSXDeploymentTarget (*xcodeConfig).fromLastOccurrenceOf (".", false, false).getIntValue(); + + return (minorOSXDeploymentTarget > 8); + } + + return false; + } + + String getOSXDeploymentTarget (const XcodeBuildConfiguration& config, String* sdkRoot = nullptr) const + { + const String sdk (config.osxSDKVersion.get()); + const String sdkCompat (config.osxDeploymentTarget.get()); + + // The AUv3 target always needs to be at least 10.11 + int oldestAllowedDeploymentTarget = (type == Target::AudioUnitv3PlugIn ? minimumAUv3SDKVersion + : oldestSDKVersion); + + // if the user doesn't set it, then use the last known version that works well with JUCE + String deploymentTarget = "10.11"; + + for (int ver = oldestAllowedDeploymentTarget; ver <= currentSDKVersion; ++ver) + { + if (sdk == getSDKName (ver) && sdkRoot != nullptr) *sdkRoot = String ("macosx10." + String (ver)); + if (sdkCompat == getSDKName (ver)) deploymentTarget = "10." + String (ver); + } + + return deploymentTarget; + } + //============================================================================== const XCodeProjectExporter& owner;