From 32ec28ad00bdb31eddce4dd5f91c414a35b7efa0 Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Wed, 29 Mar 2006 15:02:35 -0500 Subject: [PATCH] ENH: Add copy stages for bundle files --- Source/cmGlobalXCodeGenerator.cxx | 43 +++++++++++++++++++++++++++++++ Source/cmXCodeObject.cxx | 1 + Source/cmXCodeObject.h | 1 + 3 files changed, 45 insertions(+) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index cf7a96d79..250dc7d3c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -616,6 +616,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // add all the sources std::vector externalObjFiles; std::vector headerFiles; + std::vector specialBundleFiles; for(std::vector::iterator i = classes.begin(); i != classes.end(); ++i) { @@ -674,6 +675,48 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, headerBuildPhase, frameworkBuildPhase, cmtarget); targets.push_back(this->CreateXCodeTarget(l->second, buildPhases)); + + // copy files build phase + typedef std::map > + mapOfVectorOfSourceFiles; + mapOfVectorOfSourceFiles bundleFiles; + for(std::vector::iterator i = classes.begin(); + i != classes.end(); ++i) + { + const char* resLoc = (*i)->GetProperty("MACOSX_PACKAGE_LOCATION"); + if ( !resLoc ) + { + continue; + } + bundleFiles[resLoc].push_back(*i); + } + mapOfVectorOfSourceFiles::iterator mit; + for ( mit = bundleFiles.begin(); mit != bundleFiles.end(); ++ mit ) + { + cmXCodeObject* copyFilesBuildPhase + = this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase); + buildPhases->AddObject(copyFilesBuildPhase); + copyFilesBuildPhase->SetComment("Copy files"); + copyFilesBuildPhase->AddAttribute("buildActionMask", + this->CreateString("2147483647")); + copyFilesBuildPhase->AddAttribute("dstSubfolderSpec", + this->CreateString("6")); + copyFilesBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", + this->CreateString("0")); + cmOStringStream ostr; + ostr << "../" << mit->first.c_str(); + copyFilesBuildPhase->AddAttribute("dstPath", + this->CreateString(ostr.str().c_str())); + 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, cmtarget); + buildFiles->AddObject(xsf); + } + } } } diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index 6f9af356c..bd0d8d69d 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -10,6 +10,7 @@ const char* cmXCodeObject::PBXTypeNames[] = { "PBXExecutableFileReference", "PBXLibraryReference", "PBXToolTarget", "PBXLibraryTarget", "PBXAggregateTarget", "XCBuildConfiguration", "XCConfigurationList", + "PBXCopyFilesBuildPhase", "None" }; diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index 8db8f4597..04d1f93fe 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -16,6 +16,7 @@ public: PBXApplicationReference, PBXExecutableFileReference, PBXLibraryReference, PBXToolTarget, PBXLibraryTarget, PBXAggregateTarget,XCBuildConfiguration,XCConfigurationList, + PBXCopyFilesBuildPhase, None }; class StringVec: public std::vector {};