static std::unordered_map<pbxproj::PBX::BuildFile::shared_ptr, std::string> BuildFileDisambiguation(pbxproj::PBX::Target::shared_ptr const &target) { std::unordered_multimap<std::string, pbxproj::PBX::BuildFile::shared_ptr> buildFileUnambiguous; std::unordered_map<pbxproj::PBX::BuildFile::shared_ptr, std::string> buildFileDisambiguation; for (pbxproj::PBX::BuildPhase::shared_ptr const &buildPhase : target->buildPhases()) { if (buildPhase->type() != pbxproj::PBX::BuildPhase::Type::Sources) { continue; } for (pbxproj::PBX::BuildFile::shared_ptr const &buildFile : buildPhase->files()) { if (buildFile->fileRef() == nullptr) { continue; } std::string name = FSUtil::GetBaseNameWithoutExtension(buildFile->fileRef()->name()); /* Use a case-insensitive key to detect conflicts. */ std::string lower; std::transform(name.begin(), name.end(), std::back_inserter(lower), ::tolower); auto range = buildFileUnambiguous.equal_range(lower); if (range.first != buildFileUnambiguous.end()) { /* Conflicts with at least one other file, add a disambiguation. */ buildFileDisambiguation.insert({ buildFile, name + "-" + buildFile->blueprintIdentifier() }); /* Add disambiguations for all the conflicting files. */ for (auto it = range.first; it != range.second; ++it) { pbxproj::PBX::BuildFile::shared_ptr const &otherBuildFile = it->second; std::string otherName = FSUtil::GetBaseNameWithoutExtension(otherBuildFile->fileRef()->name()); buildFileDisambiguation.insert({ otherBuildFile, otherName + "-" + otherBuildFile->blueprintIdentifier() }); } } buildFileUnambiguous.insert({ lower, buildFile }); } } return buildFileDisambiguation; }
static std::vector<std::string> HeadermapSearchPaths(pbxspec::Manager::shared_ptr const &specManager, pbxsetting::Environment const &environment, pbxproj::PBX::Target::shared_ptr const &target, Tool::SearchPaths const &searchPaths, std::string const &workingDirectory) { std::unordered_set<std::string> allHeaderSearchPaths; std::vector<std::string> orderedHeaderSearchPaths; for (pbxproj::PBX::BuildPhase::shared_ptr const &buildPhase : target->buildPhases()) { if (buildPhase->type() != pbxproj::PBX::BuildPhase::Type::Sources) { continue; } for (pbxproj::PBX::BuildFile::shared_ptr const &buildFile : buildPhase->files()) { if (buildFile->fileRef() == nullptr) { continue; } std::string filePath = environment.expand(buildFile->fileRef()->resolve()); std::string fullPath = FSUtil::GetDirectoryName(filePath); if (allHeaderSearchPaths.insert(fullPath).second) { orderedHeaderSearchPaths.push_back(fullPath); } } } for (std::string const &path : searchPaths.userHeaderSearchPaths()) { std::string fullPath = FSUtil::ResolveRelativePath(path, workingDirectory); if (allHeaderSearchPaths.insert(fullPath).second) { orderedHeaderSearchPaths.push_back(fullPath); } } for (std::string const &path : searchPaths.headerSearchPaths()) { std::string fullPath = FSUtil::ResolveRelativePath(path, workingDirectory); if (allHeaderSearchPaths.insert(fullPath).second) { orderedHeaderSearchPaths.push_back(fullPath); } } return orderedHeaderSearchPaths; }