diff --git a/extras/Projucer/Source/Application/StartPage/jucer_ContentComponents.h b/extras/Projucer/Source/Application/StartPage/jucer_ContentComponents.h index d1525fea90..4a367c4871 100644 --- a/extras/Projucer/Source/Application/StartPage/jucer_ContentComponents.h +++ b/extras/Projucer/Source/Application/StartPage/jucer_ContentComponents.h @@ -179,7 +179,7 @@ private: ValueTreePropertyWithDefault projectNameValue { settingsTree, Ids::name, nullptr, "NewProject" }, modulesValue { settingsTree, Ids::dependencies_, nullptr, projectTemplate.requiredModules, "," }, - exportersValue { settingsTree, Ids::exporters, nullptr, StringArray (ProjectExporter::getCurrentPlatformExporterTypeInfo().identifier.toString()), "," }, + exportersValue { settingsTree, Ids::exporters, nullptr, StringArray { ProjectExporter::getBestPlatformExporterIdentifier() }, "," }, fileOptionsValue { settingsTree, Ids::file, nullptr, NewProjectTemplates::getVarForFileOption (projectTemplate.defaultFileOption) }; ValueTreePropertyWithDefaultWrapper modulePathValue; diff --git a/extras/Projucer/Source/Application/Windows/jucer_PIPCreatorWindowComponent.h b/extras/Projucer/Source/Application/Windows/jucer_PIPCreatorWindowComponent.h index da80ba216b..0bd17de61b 100644 --- a/extras/Projucer/Source/Application/Windows/jucer_PIPCreatorWindowComponent.h +++ b/extras/Projucer/Source/Application/Windows/jucer_PIPCreatorWindowComponent.h @@ -335,7 +335,7 @@ private: websiteValue { pipTree, Ids::website, nullptr }, descriptionValue { pipTree, Ids::description, nullptr }, dependenciesValue { pipTree, Ids::dependencies_, nullptr, getModulesRequiredForComponent(), "," }, - exportersValue { pipTree, Ids::exporters, nullptr, StringArray (ProjectExporter::getCurrentPlatformExporterTypeInfo().identifier.toString()), "," }, + exportersValue { pipTree, Ids::exporters, nullptr, StringArray { ProjectExporter::getBestPlatformExporterIdentifier() }, "," }, moduleFlagsValue { pipTree, Ids::moduleFlags, nullptr, "JUCE_STRICT_REFCOUNTEDPOINTER=1" }, definesValue { pipTree, Ids::defines, nullptr }, typeValue { pipTree, Ids::type, nullptr, "Component" }, diff --git a/extras/Projucer/Source/Project/UI/jucer_HeaderComponent.cpp b/extras/Projucer/Source/Project/UI/jucer_HeaderComponent.cpp index 7aea90bf9c..5b4127e197 100644 --- a/extras/Projucer/Source/Project/UI/jucer_HeaderComponent.cpp +++ b/extras/Projucer/Source/Project/UI/jucer_HeaderComponent.cpp @@ -127,39 +127,51 @@ void HeaderComponent::updateExporters() auto selectedExporter = getSelectedExporter(); exporterBox.clear(); - auto preferredExporterIndex = -1; int i = 0; + for (Project::ExporterIterator exporter (*project); exporter.next(); ++i) { - auto exporterName = exporter->getUniqueName(); - - exporterBox.addItem (exporterName, i + 1); + const auto exporterName = exporter->getUniqueName(); + const auto id = i + 1; + exporterBox.addItem (exporterName, id); if (selectedExporter != nullptr && exporterName == selectedExporter->getUniqueName()) - exporterBox.setSelectedId (i + 1); - - if (exporterName.contains (ProjectExporter::getCurrentPlatformExporterTypeInfo().displayName) && preferredExporterIndex == -1) - preferredExporterIndex = i; + exporterBox.setSelectedId (id); } - if (exporterBox.getSelectedItemIndex() == -1) + const auto preferredExporterIndex = std::invoke ([&] { - if (preferredExporterIndex == -1) + std::vector infos; + ProjectExporter::getCurrentPlatformExporterTypeInfos (infos); + + for (const auto& info : infos) { - i = 0; - for (Project::ExporterIterator exporter (*project); exporter.next(); ++i) + int index = 0; + + for (Project::ExporterIterator exporter (*project); exporter.next(); ++index) { - if (exporter->canLaunchProject()) - { - preferredExporterIndex = i; - break; - } + if (exporter->getUniqueName().contains (info.displayName)) + return index; } } + if (exporterBox.getSelectedItemIndex() == -1) + { + int index = 0; + + for (Project::ExporterIterator exporter (*project); exporter.next(); ++index) + { + if (exporter->canLaunchProject()) + return index; + } + } + + return -1; + }); + + if (exporterBox.getSelectedItemIndex() == -1) exporterBox.setSelectedItemIndex (preferredExporterIndex != -1 ? preferredExporterIndex : 0); - } updateExporterButton(); } diff --git a/extras/Projucer/Source/Project/jucer_Project.cpp b/extras/Projucer/Source/Project/jucer_Project.cpp index 5975cdca4e..68185ef121 100644 --- a/extras/Projucer/Source/Project/jucer_Project.cpp +++ b/extras/Projucer/Source/Project/jucer_Project.cpp @@ -2661,7 +2661,8 @@ void Project::addNewExporter (const Identifier& exporterIdentifier) void Project::createExporterForCurrentPlatform() { - addNewExporter (ProjectExporter::getCurrentPlatformExporterTypeInfo().identifier); + if (const auto identifier = ProjectExporter::getBestPlatformExporterIdentifier(); identifier.isNotEmpty()) + addNewExporter (identifier); } String Project::getUniqueTargetFolderSuffixForExporter (const Identifier& exporterIdentifier, const String& base) diff --git a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.cpp b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.cpp index 82e1667b6c..41b944e442 100644 --- a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.cpp +++ b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.cpp @@ -116,17 +116,24 @@ ProjectExporter::ExporterTypeInfo ProjectExporter::getTypeInfoForExporter (const return {}; } -ProjectExporter::ExporterTypeInfo ProjectExporter::getCurrentPlatformExporterTypeInfo() +void ProjectExporter::getCurrentPlatformExporterTypeInfos (std::vector& result) { - #if JUCE_MAC - return ProjectExporter::getTypeInfoForExporter (XcodeProjectExporter::getValueTreeTypeNameMac()); - #elif JUCE_WINDOWS - return ProjectExporter::getTypeInfoForExporter (MSVCProjectExporterVC2022::getValueTreeTypeName()); - #elif JUCE_LINUX || JUCE_BSD - return ProjectExporter::getTypeInfoForExporter (MakefileProjectExporter::getValueTreeTypeName()); - #else - #error "unknown platform!" - #endif + const auto typeNames = + #if JUCE_MAC + { XcodeProjectExporter::getValueTreeTypeNameMac(), + XcodeProjectExporter::getValueTreeTypeNameiOS() }; + #elif JUCE_WINDOWS + { MSVCProjectExporterVC2026::getValueTreeTypeName(), + MSVCProjectExporterVC2022::getValueTreeTypeName(), + MSVCProjectExporterVC2019::getValueTreeTypeName() }; + #elif JUCE_LINUX || JUCE_BSD + { MakefileProjectExporter::getValueTreeTypeName() }; + #else + #error "unknown platform!" + #endif + + for (const auto& typeName : typeNames) + result.push_back (getTypeInfoForExporter (typeName)); } std::unique_ptr ProjectExporter::createNewExporter (Project& project, const Identifier& exporterIdentifier) diff --git a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.h b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.h index e5540a54e8..33daed320f 100644 --- a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.h +++ b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExporter.h @@ -110,7 +110,20 @@ public: static std::vector getExporterTypeInfos(); static ExporterTypeInfo getTypeInfoForExporter (const Identifier& exporterIdentifier); - static ExporterTypeInfo getCurrentPlatformExporterTypeInfo(); + + /** Sorted by suitability, with the 'best' exporter for the current platform first. */ + static void getCurrentPlatformExporterTypeInfos (std::vector&); + + static String getBestPlatformExporterIdentifier() + { + std::vector infos; + getCurrentPlatformExporterTypeInfos (infos); + + if (infos.empty()) + return {}; + + return infos.front().identifier.toString(); + } static std::unique_ptr createNewExporter (Project&, const Identifier& exporterIdentifier); static std::unique_ptr createExporterFromSettings (Project&, const ValueTree& settings);