void SBTarget::processDependencies() { const BuildSettings& projBS = m_parentProject.getBuildSettings(); const DependencyList& depsList = m_target->getDependencies(); for (unsigned i = 0; i < depsList.size(); i++) { String errStr = "Failed to process PBXTargetDependency (" + depsList[i]->getId() + ") for \"" + getName() + "\" target. "; const PBXTarget* target = depsList[i]->getTarget(); const PBXContainerItemProxy* targetProxy = depsList[i]->getTargetProxy(); SBProject* targetProject = NULL; SBTarget* depTarget = NULL; if (target) { targetProject = &m_parentProject; depTarget = targetProject->queueTarget(target); } else if (targetProxy) { String targetId = targetProxy->getRemoteId(); String projectPath = targetProxy->getPortalPath(); String absProjectPath = projBS.expand(projectPath, PathValue); targetProject = SBWorkspace::get()->openProject(absProjectPath); if (targetProject) depTarget = targetProject->queueTargetWithId(targetId); else SBLog::warning() << errStr << "Unable to open referenced project path: " << projectPath << std::endl; } else { SBLog::warning() << errStr << "Missing remote target info." << std::endl; } if (targetProject && !depTarget) SBLog::warning() << errStr << "Unable to create dependency target in \"" << targetProject->getName() << "\" project." << std::endl; addDependency(depTarget); } }
SBTarget* SBTarget::getPossibleTarget(const PBXBuildFile* buildFile) { static const char* const _productWildcards[] = {"lib*.a", "*.app", "*.framework"}; static StringVec productWildcards(_productWildcards, _productWildcards + sizeof(_productWildcards) / sizeof(char*)); sbAssert(buildFile); const PBXFile* file = buildFile->getFile(); String filePath, fileName; if (file) { filePath = file->getFullPath(); fileName = sb_basename(filePath); } SBTarget* depTarget = NULL; const PBXReferenceProxy* proxyFile = NULL; // We are interested in any potential Xcode build products if (!matchWildcardList(fileName, productWildcards)) { // Do nothing } else if ((proxyFile = dynamic_cast<const PBXReferenceProxy*>(file))) { // Construct base error string, to hopefully never be used String errStr = "Failed to process PBXBuildFile (" + buildFile->getId() + ") for " + getName() + " target. "; // Get remote proxy container const PBXContainerItemProxy* container = proxyFile->getContainer(); // Ignore build file, if necessary if (!container) { SBLog::warning() << errStr << "Unable to get the PBXContainerItemProxy."; return NULL; } // Get remote project and target identifier from the proxy const String& remoteId = container->getRemoteId(); String projectPath = container->getPortalPath(); // Expand the project path const BuildSettings& projBS = m_parentProject.getBuildSettings(); String absProjectPath = projBS.expand(projectPath, PathValue); // Try to open the remote project SBProject* remoteProject = SBWorkspace::get()->openProject(absProjectPath); // Try to queue up the target with the given product reference if (remoteProject) { depTarget = remoteProject->queueTargetWithProductReference(remoteId); if (!depTarget) SBLog::warning() << errStr << "Unable to create proxy target " << remoteId << " from the \"" << remoteProject->getName() << "\" project." << std::endl; } else { SBLog::warning() << errStr << "Unable to open referenced project path: " << projectPath << std::endl; } } else { // Look for target in current project first depTarget = m_parentProject.queueTargetWithProductName(fileName); // Look for target in workspace, if it hasn't been found already if (!depTarget) depTarget = SBWorkspace::get()->queueTargetWithProductName(fileName); } // Add the target to the dependency set addDependency(depTarget); // Indicate whether this was a dependency or not return depTarget; }