From 991ff626e1aadb265bf6e73ea4726e70bb4799fa Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 22 May 2020 16:44:30 +0100 Subject: [PATCH] Projucer: Add all format-specific plug-in files in juce_audio_plugin_client to correct targets in Visual Studio --- .../Projucer/Source/Project/jucer_Project.cpp | 31 +++++++++---- .../ProjectSaving/jucer_ProjectExport_MSVC.h | 43 ++++++++----------- 2 files changed, 42 insertions(+), 32 deletions(-) diff --git a/extras/Projucer/Source/Project/jucer_Project.cpp b/extras/Projucer/Source/Project/jucer_Project.cpp index df978f7957..faa29bb7df 100644 --- a/extras/Projucer/Source/Project/jucer_Project.cpp +++ b/extras/Projucer/Source/Project/jucer_Project.cpp @@ -1184,16 +1184,31 @@ bool Project::shouldBuildTargetType (build_tools::ProjectType::Target::Type targ return true; } +static bool hasParentDirectory (File f, StringRef parentName) +{ + for (int depth = 0; depth < 2; ++depth) + { + auto parent = f.getParentDirectory(); + + if (parent.getFileName() == parentName) + return true; + + f = parent; + } + + return false; +} + build_tools::ProjectType::Target::Type Project::getTargetTypeFromFilePath (const File& file, bool returnSharedTargetIfNoValidSuffix) { - if (LibraryModule::CompileUnit::hasSuffix (file, "_AU")) return build_tools::ProjectType::Target::AudioUnitPlugIn; - else if (LibraryModule::CompileUnit::hasSuffix (file, "_AUv3")) return build_tools::ProjectType::Target::AudioUnitv3PlugIn; - else if (LibraryModule::CompileUnit::hasSuffix (file, "_AAX")) return build_tools::ProjectType::Target::AAXPlugIn; - else if (LibraryModule::CompileUnit::hasSuffix (file, "_RTAS")) return build_tools::ProjectType::Target::RTASPlugIn; - else if (LibraryModule::CompileUnit::hasSuffix (file, "_VST2")) return build_tools::ProjectType::Target::VSTPlugIn; - else if (LibraryModule::CompileUnit::hasSuffix (file, "_VST3")) return build_tools::ProjectType::Target::VST3PlugIn; - else if (LibraryModule::CompileUnit::hasSuffix (file, "_Standalone")) return build_tools::ProjectType::Target::StandalonePlugIn; - else if (LibraryModule::CompileUnit::hasSuffix (file, "_Unity")) return build_tools::ProjectType::Target::UnityPlugIn; + if (LibraryModule::CompileUnit::hasSuffix (file, "_AU") || hasParentDirectory (file, "AU")) return build_tools::ProjectType::Target::AudioUnitPlugIn; + else if (LibraryModule::CompileUnit::hasSuffix (file, "_AUv3") || hasParentDirectory (file, "AU")) return build_tools::ProjectType::Target::AudioUnitv3PlugIn; + else if (LibraryModule::CompileUnit::hasSuffix (file, "_AAX") || hasParentDirectory (file, "AAX")) return build_tools::ProjectType::Target::AAXPlugIn; + else if (LibraryModule::CompileUnit::hasSuffix (file, "_RTAS") || hasParentDirectory (file, "RTAS")) return build_tools::ProjectType::Target::RTASPlugIn; + else if (LibraryModule::CompileUnit::hasSuffix (file, "_VST2") || hasParentDirectory (file, "VST")) return build_tools::ProjectType::Target::VSTPlugIn; + else if (LibraryModule::CompileUnit::hasSuffix (file, "_VST3") || hasParentDirectory (file, "VST3")) return build_tools::ProjectType::Target::VST3PlugIn; + else if (LibraryModule::CompileUnit::hasSuffix (file, "_Standalone") || hasParentDirectory (file, "Standalone")) return build_tools::ProjectType::Target::StandalonePlugIn; + else if (LibraryModule::CompileUnit::hasSuffix (file, "_Unity") || hasParentDirectory (file, "Unity")) return build_tools::ProjectType::Target::UnityPlugIn; return (returnSharedTargetIfNoValidSuffix ? build_tools::ProjectType::Target::SharedCodeTarget : build_tools::ProjectType::Target::unspecified); } diff --git a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_MSVC.h b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_MSVC.h index 4e559dac18..6c8bc58d29 100644 --- a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_MSVC.h +++ b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_MSVC.h @@ -770,25 +770,22 @@ public: if (path.hasFileExtension (cOrCppFileExtensions) || path.hasFileExtension (asmFileExtensions)) { - if (targetType == SharedCodeTarget || projectItem.shouldBeCompiled()) + auto* e = cpps.createNewChildElement ("ClCompile"); + e->setAttribute ("Include", path.toWindowsStyle()); + + if (shouldUseStdCall (path)) + e->createNewChildElement ("CallingConvention")->addTextElement ("StdCall"); + + if (projectItem.shouldBeCompiled()) { - auto* e = cpps.createNewChildElement ("ClCompile"); - e->setAttribute ("Include", path.toWindowsStyle()); + auto extraCompilerFlags = owner.compilerFlagSchemesMap[projectItem.getCompilerFlagSchemeString()].get().toString(); - if (shouldUseStdCall (path)) - e->createNewChildElement ("CallingConvention")->addTextElement ("StdCall"); - - if (projectItem.shouldBeCompiled()) - { - auto extraCompilerFlags = owner.compilerFlagSchemesMap[projectItem.getCompilerFlagSchemeString()].get().toString(); - - if (extraCompilerFlags.isNotEmpty()) - e->createNewChildElement ("AdditionalOptions")->addTextElement (extraCompilerFlags + " %(AdditionalOptions)"); - } - else - { - e->createNewChildElement ("ExcludedFromBuild")->addTextElement ("true"); - } + if (extraCompilerFlags.isNotEmpty()) + e->createNewChildElement ("AdditionalOptions")->addTextElement (extraCompilerFlags + " %(AdditionalOptions)"); + } + else + { + e->createNewChildElement ("ExcludedFromBuild")->addTextElement ("true"); } } else if (path.hasFileExtension (headerFileExtensions)) @@ -853,7 +850,9 @@ public: return filesWereAdded; } - else if (projectItem.shouldBeAddedToTargetProject() && projectItem.shouldBeAddedToTargetExporter (getOwner())) + else if (projectItem.shouldBeAddedToTargetProject() + && projectItem.shouldBeAddedToTargetExporter (getOwner()) + && getOwner().getProject().getTargetTypeFromFilePath (projectItem.getFile(), true) == targetType) { build_tools::RelativePath relativePath (projectItem.getFile(), getOwner().getTargetFolder(), @@ -861,12 +860,8 @@ public: jassert (relativePath.getRoot() == build_tools::RelativePath::buildTargetFolder); - if (getOwner().getProject().getTargetTypeFromFilePath (projectItem.getFile(), true) == targetType - && (targetType == SharedCodeTarget || projectItem.shouldBeCompiled())) - { - addFileToFilter (relativePath, path.upToLastOccurrenceOf ("\\", false, false), cpps, headers, otherFiles); - return true; - } + addFileToFilter (relativePath, path.upToLastOccurrenceOf ("\\", false, false), cpps, headers, otherFiles); + return true; } return false;