From 060be58c6f9ffe11235341bc10c8f5d808e31b3d Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Sun, 26 Feb 2017 22:12:44 +0100 Subject: Xcode: Properly handle Bundle Resources with more than one hierarchy level Issue: #16680 --- Source/cmGeneratorTarget.cxx | 2 ++ Source/cmGeneratorTarget.h | 4 +++- Source/cmGlobalXCodeGenerator.cxx | 40 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e27424f..64b05c3 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3317,6 +3317,8 @@ cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const flags.MacFolder = location; if (strcmp(location, "Resources") == 0) { flags.Type = cmGeneratorTarget::SourceFileTypeResource; + } else if (cmSystemTools::StringStartsWith(location, "Resources/")) { + flags.Type = cmGeneratorTarget::SourceFileTypeDeepResource; } else { flags.Type = cmGeneratorTarget::SourceFileTypeMacContent; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 68d6ef8..d60ad24 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -422,7 +422,9 @@ public: SourceFileTypePublicHeader, // is in "PUBLIC_HEADER" target property SourceFileTypeResource, // is in "RESOURCE" target property *or* // has MACOSX_PACKAGE_LOCATION=="Resources" - SourceFileTypeMacContent // has MACOSX_PACKAGE_LOCATION!="Resources" + SourceFileTypeDeepResource, // MACOSX_PACKAGE_LOCATION starts with + // "Resources/" + SourceFileTypeMacContent // has MACOSX_PACKAGE_LOCATION!="Resources[/]" }; struct SourceFileFlags { diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 3f5dde7..bd0f55b 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1177,6 +1177,46 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets( } } + // create vector of "resource content file" build phases - only for + // framework or bundle targets + if (isFrameworkTarget || isBundleTarget || isCFBundleTarget) { + typedef std::map > + mapOfVectorOfSourceFiles; + mapOfVectorOfSourceFiles bundleFiles; + for (std::vector::const_iterator i = classes.begin(); + i != classes.end(); ++i) { + cmGeneratorTarget::SourceFileFlags tsFlags = + gtgt->GetTargetSourceFileFlags(*i); + if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeDeepResource) { + bundleFiles[tsFlags.MacFolder].push_back(*i); + } + } + mapOfVectorOfSourceFiles::iterator mit; + for (mit = bundleFiles.begin(); mit != bundleFiles.end(); ++mit) { + cmXCodeObject* copyFilesBuildPhase = + this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase); + copyFilesBuildPhase->SetComment("Copy files"); + copyFilesBuildPhase->AddAttribute("buildActionMask", + this->CreateString("2147483647")); + copyFilesBuildPhase->AddAttribute("dstSubfolderSpec", + this->CreateString("7")); + const std::string dstPath = mit->first.substr(strlen("Resources/")); + copyFilesBuildPhase->AddAttribute("dstPath", + this->CreateString(dstPath)); + copyFilesBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", + this->CreateString("0")); + buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); + copyFilesBuildPhase->AddAttribute("files", buildFiles); + std::vector::iterator sfIt; + for (sfIt = mit->second.begin(); sfIt != mit->second.end(); ++sfIt) { + cmXCodeObject* xsf = this->CreateXCodeSourceFile( + this->CurrentLocalGenerator, *sfIt, gtgt); + buildFiles->AddObject(xsf); + } + contentBuildPhases.push_back(copyFilesBuildPhase); + } + } + // create framework build phase cmXCodeObject* frameworkBuildPhase = 0; if (!externalObjFiles.empty()) { -- cgit v0.12