diff options
author | Brad King <brad.king@kitware.com> | 2017-03-24 12:32:32 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-03-24 12:32:41 (GMT) |
commit | 5bded841b4d66bea70c932184eac0a44b82d03fe (patch) | |
tree | daa118230f7fe587550d1e4e300eed92242010ba /Source | |
parent | 0f4420e0a80993ccd6ce7d51eeb96e904b8bd9f8 (diff) | |
parent | b5189fda244112f47e71c820bf1498d500026cd0 (diff) | |
download | CMake-5bded841b4d66bea70c932184eac0a44b82d03fe.zip CMake-5bded841b4d66bea70c932184eac0a44b82d03fe.tar.gz CMake-5bded841b4d66bea70c932184eac0a44b82d03fe.tar.bz2 |
Merge topic '16680-ios-bundle-resources'
b5189fda Apple: Add test for bundle resource layout
c51c2cfa Apple: Fix Resources location for all generators
060be58c Xcode: Properly handle Bundle Resources with more than one hierarchy level
484ccb0c Xcode: Properly handle non-resource Bundle files on iOS
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !613
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 12 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 4 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 5 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.h | 4 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 53 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.h | 2 |
6 files changed, 76 insertions, 4 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e27424f..f78a933 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3315,8 +3315,18 @@ cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const // were not listed in one of the other lists. if (const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION")) { flags.MacFolder = location; + const bool stripResources = + this->GlobalGenerator->ShouldStripResourcePath(this->Makefile); if (strcmp(location, "Resources") == 0) { flags.Type = cmGeneratorTarget::SourceFileTypeResource; + if (stripResources) { + flags.MacFolder = ""; + } + } else if (cmSystemTools::StringStartsWith(location, "Resources/")) { + flags.Type = cmGeneratorTarget::SourceFileTypeDeepResource; + if (stripResources) { + flags.MacFolder += strlen("Resources/"); + } } else { flags.Type = cmGeneratorTarget::SourceFileTypeMacContent; } @@ -3370,7 +3380,7 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const if (cmSourceFile* sf = this->Makefile->GetSource(*it)) { SourceFileFlags& flags = this->SourceFlagsMap[sf]; flags.MacFolder = ""; - if (!this->Makefile->PlatformIsAppleIos()) { + if (!this->GlobalGenerator->ShouldStripResourcePath(this->Makefile)) { flags.MacFolder = "Resources"; } flags.Type = cmGeneratorTarget::SourceFileTypeResource; 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/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 0d53bf7..851290a 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2487,6 +2487,11 @@ std::string cmGlobalGenerator::GenerateRuleFile( return ruleFile; } +bool cmGlobalGenerator::ShouldStripResourcePath(cmMakefile* mf) const +{ + return mf->PlatformIsAppleIos(); +} + std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage( std::string const& l) const { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index b3cb41f..2558fee 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -337,6 +337,10 @@ public: relevant for mixed macOS and iOS builds. */ virtual bool UseEffectivePlatformName(cmMakefile*) const { return false; } + /** Return whether the "Resources" folder prefix should be stripped from + MacFolder. */ + virtual bool ShouldStripResourcePath(cmMakefile*) const; + std::string GetSharedLibFlagsForLanguage(std::string const& lang) const; /** Generate an <output>.rule file path for a given command output. */ diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 77f3408..39f7b8f 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1154,8 +1154,12 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets( // dstPath in frameworks is relative to Versions/<version> ostr << mit->first; } else if (mit->first != "MacOS") { - // dstPath in bundles is relative to Contents/MacOS - ostr << "../" << mit->first.c_str(); + if (gtgt->Target->GetMakefile()->PlatformIsAppleIos()) { + ostr << mit->first; + } else { + // dstPath in bundles is relative to Contents/MacOS + ostr << "../" << mit->first; + } } copyFilesBuildPhase->AddAttribute("dstPath", this->CreateString(ostr.str())); @@ -1173,6 +1177,45 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets( } } + // create vector of "resource content file" build phases - only for + // framework or bundle targets + if (isFrameworkTarget || isBundleTarget || isCFBundleTarget) { + typedef std::map<std::string, std::vector<cmSourceFile*> > + mapOfVectorOfSourceFiles; + mapOfVectorOfSourceFiles bundleFiles; + for (std::vector<cmSourceFile*>::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")); + copyFilesBuildPhase->AddAttribute("dstPath", + this->CreateString(mit->first)); + copyFilesBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", + this->CreateString("0")); + buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); + copyFilesBuildPhase->AddAttribute("files", buildFiles); + std::vector<cmSourceFile*>::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()) { @@ -3657,6 +3700,12 @@ bool cmGlobalXCodeGenerator::UseEffectivePlatformName(cmMakefile* mf) const return cmSystemTools::IsOn(epnValue); } +bool cmGlobalXCodeGenerator::ShouldStripResourcePath(cmMakefile*) const +{ + // Xcode determines Resource location itself + return true; +} + void cmGlobalXCodeGenerator::ComputeTargetObjectDirectory( cmGeneratorTarget* gt) const { diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 9eacdef..172e414 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -88,6 +88,8 @@ public: bool UseEffectivePlatformName(cmMakefile* mf) const CM_OVERRIDE; + bool ShouldStripResourcePath(cmMakefile*) const CM_OVERRIDE; + bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf) CM_OVERRIDE; void AppendFlag(std::string& flags, std::string const& flag); |