src/com/facebook/buck/features/apple/projectV2/WorkspaceAndProjectGenerator.java
/**
   * Generates a workspace and all projects
   *
   * @return A result indicating the output of the generation
   * @throws IOException
   */
Generates a workspace and all projects
@return A result indicating the output of the generation
@throws IOException
Generates a workspace and all projects @return A result indicating the output of the generation @throws IOException
public Result generateWorkspaceAndDependentProjects() throws IOException {
    LOG.debug("Generating workspace for target %s", workspaceBuildTarget);
    String workspaceName =
        XcodeWorkspaceConfigDescription.getWorkspaceNameFromArg(workspaceArguments);
    Path outputDirectory = workspaceBuildTarget.getBasePath();
    WorkspaceGenerator workspaceGenerator =
        new WorkspaceGenerator(rootCell.getFilesystem(), workspaceName, outputDirectory);
    ImmutableMap.Builder<String, XcodeWorkspaceConfigDescriptionArg> schemeConfigsBuilder =
        ImmutableMap.builder();
    ImmutableSetMultimap.Builder<String, Optional<TargetNode<?>>> schemeNameToSrcTargetNodeBuilder =
        ImmutableSetMultimap.builder();
    ImmutableSetMultimap.Builder<String, TargetNode<?>> buildForTestNodesBuilder =
        ImmutableSetMultimap.builder();
    ImmutableSetMultimap.Builder<String, TargetNode<AppleTestDescriptionArg>> testsBuilder =
        ImmutableSetMultimap.builder();
    buildWorkspaceSchemes(
        projectGraph,
        projectGeneratorOptions.shouldIncludeTests(),
        projectGeneratorOptions.shouldIncludeDependenciesTests(),
        workspaceName,
        workspaceArguments,
        schemeConfigsBuilder,
        schemeNameToSrcTargetNodeBuilder,
        buildForTestNodesBuilder,
        testsBuilder);
    ImmutableMap<String, XcodeWorkspaceConfigDescriptionArg> schemeConfigs =
        schemeConfigsBuilder.build();
    ImmutableSetMultimap<String, Optional<TargetNode<?>>> schemeNameToSrcTargetNode =
        schemeNameToSrcTargetNodeBuilder.build();
    ImmutableSetMultimap<String, TargetNode<?>> buildForTestNodes =
        buildForTestNodesBuilder.build();
    ImmutableSetMultimap<String, TargetNode<AppleTestDescriptionArg>> tests = testsBuilder.build();
    ImmutableSet<BuildTarget> targetsInRequiredProjects =
        Stream.concat(
                schemeNameToSrcTargetNode.values().stream().flatMap(RichStream::from),
                buildForTestNodes.values().stream())
            .map(TargetNode::getBuildTarget)
            .collect(ImmutableSet.toImmutableSet());
    ImmutableMap.Builder<BuildTarget, PBXTarget> buildTargetToPbxTargetMapBuilder =
        ImmutableMap.builder();
    ImmutableSetMultimap.Builder<PBXProject, PBXTarget> generatedProjectToPbxTargetsBuilder =
        ImmutableSetMultimap.builder();
    ImmutableMap.Builder<PBXTarget, Path> targetToProjectPathMapBuilder = ImmutableMap.builder();
    XcodeProjectWriteOptions xcodeProjectWriteOptions =
        XcodeProjectWriteOptions.of(new PBXProject(workspaceName), outputDirectory);
    generateProject(
        xcodeProjectWriteOptions,
        workspaceGenerator,
        targetsInRequiredProjects,
        generatedProjectToPbxTargetsBuilder,
        buildTargetToPbxTargetMapBuilder,
        targetToProjectPathMapBuilder);
    writeWorkspaceMetaData(outputDirectory, workspaceName);
    ImmutableMap<BuildTarget, PBXTarget> buildTargetToPBXTarget =
        buildTargetToPbxTargetMapBuilder.build();
    ImmutableMap<PBXTarget, Path> targetToProjectPathMap = targetToProjectPathMapBuilder.build();
    ImmutableSetMultimap<PBXProject, PBXTarget> generatedProjectToPbxTargets =
        generatedProjectToPbxTargetsBuilder.build();
    ImmutableSetMultimap<String, PBXTarget> schemeBuildForTestNodeTargets =
        WorkspaceAndProjectGenerator.mapFromSchemeToPBXProject(
            buildForTestNodes, buildTargetToPBXTarget);
    ImmutableSetMultimap<String, PBXTarget> schemeUngroupedTestTargets =
        WorkspaceAndProjectGenerator.mapFromSchemeToPBXProject(tests, buildTargetToPBXTarget);
    if (projectGeneratorOptions.shouldGenerateProjectSchemes()) {
      ImmutableSet<PBXTarget> schemeTargets =
          ImmutableSet.copyOf(
              mapFromOptionalSchemeToPBXProject(schemeNameToSrcTargetNode, buildTargetToPBXTarget)
                  .values());
      LOG.debug("Generating schemes for all sub-projects.");
      writeWorkspaceSchemesForProjects(
          xcodeProjectWriteOptions,
          generatedProjectToPbxTargets.get(xcodeProjectWriteOptions.project()),
          schemeTargets,
          targetToProjectPathMap,
          schemeBuildForTestNodeTargets,
          schemeUngroupedTestTargets);
    }
    writeWorkspaceSchemes(
        workspaceName,
        outputDirectory,
        schemeConfigs,
        schemeNameToSrcTargetNode,
        schemeBuildForTestNodeTargets,
        schemeUngroupedTestTargets,
        targetToProjectPathMap,
        buildTargetToPBXTarget);
    Path workspacePath = workspaceGenerator.writeWorkspace();
    return new Result(workspacePath, xcodeProjectWriteOptions.project());
  }
public Result generateWorkspaceAndDependentProjects ( ) throws IOException { LOG . debug ( "Generating workspace for target %s" , workspaceBuildTarget ) ; String workspaceName = XcodeWorkspaceConfigDescription . getWorkspaceNameFromArg ( workspaceArguments ) ; Path outputDirectory = workspaceBuildTarget . getBasePath ( ) ; WorkspaceGenerator workspaceGenerator = new WorkspaceGenerator ( rootCell . getFilesystem ( ) , workspaceName , outputDirectory ) ; ImmutableMap . Builder < String , XcodeWorkspaceConfigDescriptionArg > schemeConfigsBuilder = ImmutableMap . builder ( ) ; ImmutableSetMultimap . Builder < String , Optional < TargetNode < ? > > > schemeNameToSrcTargetNodeBuilder = ImmutableSetMultimap . builder ( ) ; ImmutableSetMultimap . Builder < String , TargetNode < ? > > buildForTestNodesBuilder = ImmutableSetMultimap . builder ( ) ; ImmutableSetMultimap . Builder < String , TargetNode < AppleTestDescriptionArg > > testsBuilder = ImmutableSetMultimap . builder ( ) ; buildWorkspaceSchemes ( projectGraph , projectGeneratorOptions . shouldIncludeTests ( ) , projectGeneratorOptions . shouldIncludeDependenciesTests ( ) , workspaceName , workspaceArguments , schemeConfigsBuilder , schemeNameToSrcTargetNodeBuilder , buildForTestNodesBuilder , testsBuilder ) ; ImmutableMap < String , XcodeWorkspaceConfigDescriptionArg > schemeConfigs = schemeConfigsBuilder . build ( ) ; ImmutableSetMultimap < String , Optional < TargetNode < ? > > > schemeNameToSrcTargetNode = schemeNameToSrcTargetNodeBuilder . build ( ) ; ImmutableSetMultimap < String , TargetNode < ? > > buildForTestNodes = buildForTestNodesBuilder . build ( ) ; ImmutableSetMultimap < String , TargetNode < AppleTestDescriptionArg > > tests = testsBuilder . build ( ) ; ImmutableSet < BuildTarget > targetsInRequiredProjects = Stream . concat ( schemeNameToSrcTargetNode . values ( ) . stream ( ) . flatMap ( RichStream :: from ) , buildForTestNodes . values ( ) . stream ( ) ) . map ( TargetNode :: getBuildTarget ) . collect ( ImmutableSet . toImmutableSet ( ) ) ; ImmutableMap . Builder < BuildTarget , PBXTarget > buildTargetToPbxTargetMapBuilder = ImmutableMap . builder ( ) ; ImmutableSetMultimap . Builder < PBXProject , PBXTarget > generatedProjectToPbxTargetsBuilder = ImmutableSetMultimap . builder ( ) ; ImmutableMap . Builder < PBXTarget , Path > targetToProjectPathMapBuilder = ImmutableMap . builder ( ) ; XcodeProjectWriteOptions xcodeProjectWriteOptions = XcodeProjectWriteOptions . of ( new PBXProject ( workspaceName ) , outputDirectory ) ; generateProject ( xcodeProjectWriteOptions , workspaceGenerator , targetsInRequiredProjects , generatedProjectToPbxTargetsBuilder , buildTargetToPbxTargetMapBuilder , targetToProjectPathMapBuilder ) ; writeWorkspaceMetaData ( outputDirectory , workspaceName ) ; ImmutableMap < BuildTarget , PBXTarget > buildTargetToPBXTarget = buildTargetToPbxTargetMapBuilder . build ( ) ; ImmutableMap < PBXTarget , Path > targetToProjectPathMap = targetToProjectPathMapBuilder . build ( ) ; ImmutableSetMultimap < PBXProject , PBXTarget > generatedProjectToPbxTargets = generatedProjectToPbxTargetsBuilder . build ( ) ; ImmutableSetMultimap < String , PBXTarget > schemeBuildForTestNodeTargets = WorkspaceAndProjectGenerator . mapFromSchemeToPBXProject ( buildForTestNodes , buildTargetToPBXTarget ) ; ImmutableSetMultimap < String , PBXTarget > schemeUngroupedTestTargets = WorkspaceAndProjectGenerator . mapFromSchemeToPBXProject ( tests , buildTargetToPBXTarget ) ; if ( projectGeneratorOptions . shouldGenerateProjectSchemes ( ) ) { ImmutableSet < PBXTarget > schemeTargets = ImmutableSet . copyOf ( mapFromOptionalSchemeToPBXProject ( schemeNameToSrcTargetNode , buildTargetToPBXTarget ) . values ( ) ) ; LOG . debug ( "Generating schemes for all sub-projects." ) ; writeWorkspaceSchemesForProjects ( xcodeProjectWriteOptions , generatedProjectToPbxTargets . get ( xcodeProjectWriteOptions . project ( ) ) , schemeTargets , targetToProjectPathMap , schemeBuildForTestNodeTargets , schemeUngroupedTestTargets ) ; } writeWorkspaceSchemes ( workspaceName , outputDirectory , schemeConfigs , schemeNameToSrcTargetNode , schemeBuildForTestNodeTargets , schemeUngroupedTestTargets , targetToProjectPathMap , buildTargetToPBXTarget ) ; Path workspacePath = workspaceGenerator . writeWorkspace ( ) ; return new Result ( workspacePath , xcodeProjectWriteOptions . project ( ) ) ; }
Generates a workspace and all projects
 @return A result indicating the output of the generation
 @throws IOException
Generates a workspace and all projects @return A result indicating the output of the generation @throws IOException
// compose the project targets of targets that are within the main (or extra) scheme's // targets