Пример #1
0
void SBWorkspace::getAllTargets(PotentialTargetsVec& targets) const {
    for (auto projectKV : m_openProjects) {
        SBProject* sbProject = projectKV.second;
        const PBXProject* pbxProject = sbProject->getPBXProject();
        const PBXTargetList& projectTargets = pbxProject->getTargets();
        std::transform(projectTargets.begin(), projectTargets.end(), back_inserter(targets), [sbProject](const PBXTarget* target) {
            return std::make_pair(target, sbProject);
        });
    }
}
Пример #2
0
SBWorkspace::TargetProjectPair SBWorkspace::findTargetWithName(const String& targetName) const {
    for (auto project : m_openProjects) {
        SBProject* sbProject = project.second;
        const PBXTarget* target = sbProject->getPBXProject()->getTargetWithName(targetName);
        if (target) {
            return make_pair(target, sbProject);
        }
    }

    SBLog::warning() << "Failed to find \"" << targetName << "\" target in workspace." << std::endl;
    return { NULL, NULL };
}
Пример #3
0
void SBWorkspace::queueSchemes(const StringSet& schemeNames, const StringSet& configNames) {
    BuildSettings bs(NULL);
    bool isInteractive = bs.getValue("VSIMPORTER_INTERACTIVE") == "YES";

    // Get the specified schemes
    SchemeVec schemePtrs;
    if (schemeNames.empty()) {
        // Queue up all schemes
        schemePtrs.insert(schemePtrs.end(), m_schemes.begin(), m_schemes.end());
    } else {
        getSchemes(schemeNames, schemePtrs);
    }

    // Process all schemes
    for (auto scheme : schemePtrs) {
        // Process all build references in the scheme
        for (auto buildRef : scheme->getTargets()) {
            // Construct a path to the project specified by the BuildRef
            String projectPath = joinPaths(scheme->getContainerParentDir(), buildRef.container);

            // Find or create the project
            SBProject* targetProj = openProject(projectPath);

            // Create the target
            SBTarget* target = NULL;
            if (targetProj) {
                target = targetProj->queueTargetWithId(buildRef.id, &configNames);
            } else {
                SBLog::warning() << "Failed to open \"" << buildRef.container << "\" project referenced by \"" << scheme->getName()
                                 << "\" scheme. "
                                 << "Ignoring \"" << buildRef.targetName << "\" target." << std::endl;
            }

            // Mark target as having been explicitly queued up
            if (target) {
                target->markExplicit();
            }
        }
    }
}
Пример #4
0
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);
  }
}
Пример #5
0
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;
}