From e265be5a031a3ab8552502c00926c4b8d0cdba13 Mon Sep 17 00:00:00 2001 From: Tom Poole Date: Wed, 14 Feb 2024 14:39:18 +0000 Subject: [PATCH] Xcode: Fix a bug in paths with a tilde --- .../ProjectSaving/jucer_ProjectExport_Xcode.h | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Xcode.h b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Xcode.h index 8ce01ff2f2..b8c436b9e6 100644 --- a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Xcode.h +++ b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Xcode.h @@ -2081,12 +2081,17 @@ public: private: //============================================================================== + static String replaceHomeTildeInPath (const String& path) + { + return path.startsWithChar ('~') ? "$(HOME)" + path.substring (1) + : path; + } + static String expandPath (const String& path) { if (! build_tools::isAbsolutePath (path)) return "$(SRCROOT)/" + path; - if (path.startsWithChar ('~')) return "$(HOME)" + path.substring (1); - return path; + return replaceHomeTildeInPath (path); } static String addQuotesIfRequired (const String& s) @@ -2216,28 +2221,22 @@ private: target->addMainBuildProduct(); - if (target->type == XcodeTarget::LV2Helper - && project.getEnabledModules().isModuleEnabled ("juce_audio_plugin_client")) + if (project.getEnabledModules().isModuleEnabled ("juce_audio_plugin_client")) { - const auto path = rebaseFromProjectFolderToBuildTarget (getLV2HelperProgramSource()); - addFile (FileOptions().withRelativePath ({ path.toUnixStyle(), path.getRoot() }) - .withSkipPCHEnabled (true) - .withCompilationEnabled (true) - .withInhibitWarningsEnabled (true) - .withCompilerFlags ("-std=c++11") - .withXcodeTarget (target)); - } + auto getFileOptions = [this, target] (const build_tools::RelativePath& path) + { + const auto rebasedPath = rebaseFromProjectFolderToBuildTarget (path); + return FileOptions().withRelativePath ({ replaceHomeTildeInPath (rebasedPath.toUnixStyle()), rebasedPath.getRoot() }) + .withSkipPCHEnabled (true) + .withCompilationEnabled (true) + .withInhibitWarningsEnabled (true) + .withXcodeTarget (target); + }; - if (target->type == XcodeTarget::VST3Helper - && project.getEnabledModules().isModuleEnabled ("juce_audio_plugin_client")) - { - const auto path = rebaseFromProjectFolderToBuildTarget (getVST3HelperProgramSource()); - addFile (FileOptions().withRelativePath ({ path.toUnixStyle(), path.getRoot() }) - .withSkipPCHEnabled (true) - .withCompilationEnabled (true) - .withInhibitWarningsEnabled (true) - .withCompilerFlags ("-std=c++17 -fobjc-arc") - .withXcodeTarget (target)); + if (target->type == XcodeTarget::LV2Helper) + addFile (getFileOptions (getLV2HelperProgramSource())); + else if (target->type == XcodeTarget::VST3Helper) + addFile (getFileOptions (getVST3HelperProgramSource()).withCompilerFlags ("-fobjc-arc")); } auto targetName = String (target->getName());