Example usage for com.google.common.collect ImmutableList.Builder addAll

List of usage examples for com.google.common.collect ImmutableList.Builder addAll

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableList.Builder addAll.

Prototype

boolean addAll(Collection<? extends E> c);

Source Link

Document

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).

Usage

From source file:com.spotify.heroic.metric.FullQuery.java

public static Collector<FullQuery, FullQuery> collect(final QueryTrace.Identifier what) {
    final QueryTrace.NamedWatch w = QueryTrace.watch(what);

    return results -> {
        final ImmutableList.Builder<QueryTrace> traces = ImmutableList.builder();
        final ImmutableList.Builder<RequestError> errors = ImmutableList.builder();
        final ImmutableList.Builder<ResultGroup> groups = ImmutableList.builder();
        Statistics statistics = Statistics.empty();
        final ImmutableSet.Builder<ResultLimit> limits = ImmutableSet.builder();

        for (final FullQuery r : results) {
            traces.add(r.trace);/*  w w w. j av  a 2 s.com*/
            errors.addAll(r.errors);
            groups.addAll(r.groups);
            statistics = statistics.merge(r.statistics);
            limits.addAll(r.limits.getLimits());
        }

        return new FullQuery(w.end(traces.build()), errors.build(), groups.build(), statistics,
                new ResultLimits(limits.build()), Optional.empty());
    };
}

From source file:com.facebook.buck.support.cli.args.BuckArgsMethods.java

/**
 * Recursively expands flag files into a flat list of command line arguments.
 *
 * <p>Loops are not allowed and result in runtime exception.
 *//*from   w w w . ja v  a  2s  . com*/
private static ImmutableList<String> expandFlagFilesRecursively(Iterable<String> args,
        ImmutableMap<CellName, Path> cellMapping, Set<String> expansionPath) {
    Iterator<String> argsIterator = args.iterator();
    ImmutableList.Builder<String> argumentsBuilder = ImmutableList.builder();
    while (argsIterator.hasNext()) {
        String arg = argsIterator.next();
        if (PASS_THROUGH_DELIMITER.equals(arg)) {
            // all flags after -- should be passed through without any preprocessing
            argumentsBuilder.add(arg);
            argumentsBuilder.addAll(argsIterator);
            break;
        }
        if (FLAG_FILE_OPTIONS.contains(arg)) {
            if (!argsIterator.hasNext()) {
                throw new HumanReadableException(arg + " should be followed by a path.");
            }
            String nextFlagFile = argsIterator.next();
            argumentsBuilder.addAll(expandFlagFile(nextFlagFile, cellMapping, expansionPath));
        } else if (arg.startsWith("@")) {
            argumentsBuilder.addAll(expandFlagFile(arg.substring(1), cellMapping, expansionPath));
        } else {
            argumentsBuilder.add(arg);
        }
    }
    return argumentsBuilder.build();
}

From source file:org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.java

public static <AT, DT extends DeclaredStatement<AT>> Collection<StmtContext<AT, DT, ?>> findAllSubstatements(
        final StmtContext<?, ?, ?> stmtContext, final Class<DT> type) {
    final ImmutableList.Builder<StmtContext<AT, DT, ?>> listBuilder = ImmutableList.builder();
    listBuilder.addAll(findAllDeclaredSubstatements(stmtContext, type));
    listBuilder.addAll(findAllEffectiveSubstatements(stmtContext, type));
    return listBuilder.build();
}

From source file:com.facebook.buck.cxx.CxxLinkableEnhancer.java

/**
 * Construct a {@link CxxLink} rule that builds a native linkable from top-level input objects
 * and a dependency tree of {@link NativeLinkable} dependencies.
 *
 * @param params base params used to build the rule.  Target and deps will be overridden.
 * @param nativeLinkableDeps library dependencies that the linkable links in
 * @param immediateLinkableInput framework and libraries of the linkable itself
 *///from   w  w  w .  jav a2  s  .c o m
public static CxxLink createCxxLinkableBuildRule(CxxBuckConfig cxxBuckConfig, CxxPlatform cxxPlatform,
        BuildRuleParams params, BuildRuleResolver ruleResolver, final SourcePathResolver resolver,
        SourcePathRuleFinder ruleFinder, BuildTarget target, Linker.LinkType linkType, Optional<String> soname,
        Path output, Linker.LinkableDepType depType, Iterable<? extends NativeLinkable> nativeLinkableDeps,
        Optional<Linker.CxxRuntimeType> cxxRuntimeType, Optional<SourcePath> bundleLoader,
        ImmutableSet<BuildTarget> blacklist, NativeLinkableInput immediateLinkableInput)
        throws NoSuchBuildTargetException {

    // Soname should only ever be set when linking a "shared" library.
    Preconditions.checkState(!soname.isPresent() || SONAME_REQUIRED_LINK_TYPES.contains(linkType));

    // Bundle loaders are only supported for Mach-O bundle libraries
    Preconditions.checkState(!bundleLoader.isPresent() || linkType == Linker.LinkType.MACH_O_BUNDLE);

    // Collect and topologically sort our deps that contribute to the link.
    ImmutableList.Builder<NativeLinkableInput> nativeLinkableInputs = ImmutableList.builder();
    nativeLinkableInputs.add(immediateLinkableInput);
    for (NativeLinkable nativeLinkable : Maps
            .filterKeys(NativeLinkables.getNativeLinkables(cxxPlatform, nativeLinkableDeps, depType),
                    Predicates.not(blacklist::contains))
            .values()) {
        NativeLinkableInput input = NativeLinkables.getNativeLinkableInput(cxxPlatform, depType,
                nativeLinkable);
        LOG.verbose("Native linkable %s returned input %s", nativeLinkable, input);
        nativeLinkableInputs.add(input);
    }
    NativeLinkableInput linkableInput = NativeLinkableInput.concat(nativeLinkableInputs.build());

    // Build up the arguments to pass to the linker.
    ImmutableList.Builder<Arg> argsBuilder = ImmutableList.builder();

    // If we're doing a shared build, pass the necessary flags to the linker, including setting
    // the soname.
    if (linkType == Linker.LinkType.SHARED) {
        argsBuilder.addAll(cxxPlatform.getLd().resolve(ruleResolver).getSharedLibFlag());
    } else if (linkType == Linker.LinkType.MACH_O_BUNDLE) {
        argsBuilder.add(new StringArg("-bundle"));
        // It's possible to build a Mach-O bundle without a bundle loader (logic tests, for example).
        if (bundleLoader.isPresent()) {
            argsBuilder.add(new StringArg("-bundle_loader"), new SourcePathArg(resolver, bundleLoader.get()));
        }
    }
    if (soname.isPresent()) {
        argsBuilder.addAll(StringArg.from(cxxPlatform.getLd().resolve(ruleResolver).soname(soname.get())));
    }

    // Add all arguments from our dependencies.
    argsBuilder.addAll(linkableInput.getArgs());

    // Add all shared libraries
    addSharedLibrariesLinkerArgs(cxxPlatform, resolver, ImmutableSortedSet.copyOf(linkableInput.getLibraries()),
            argsBuilder);

    // Add framework args
    addFrameworkLinkerArgs(cxxPlatform, resolver, ImmutableSortedSet.copyOf(linkableInput.getFrameworks()),
            argsBuilder);

    final ImmutableList<Arg> allArgs = argsBuilder.build();

    return createCxxLinkableBuildRule(cxxBuckConfig, cxxPlatform, params, ruleResolver, resolver, ruleFinder,
            target, output, allArgs, depType, cxxRuntimeType);
}

From source file:com.palantir.giraffe.file.base.ImmutableListPathCore.java

private static ImmutableListPathCore relativizeNormalizedPaths(ImmutableListPathCore base,
        ImmutableListPathCore other) {//from  w  w  w  .  ja va 2  s . co  m
    if (base.equals(other)) {
        return emptyInstance;
    } else {
        // find longest common prefix
        int i = 0;
        int limit = Math.min(base.path.size(), other.path.size());
        while (i < limit && base.path.get(i).equals(other.path.get(i))) {
            i++;
        }

        ImmutableList.Builder<String> relative = ImmutableList.builder();
        // go up once for each remaining name in this path
        relative.addAll(Collections.nCopies(Math.max(0, base.path.size() - i), PARENT_DIR));
        // append the remaining names from the other path
        relative.addAll(other.path.subList(i, other.path.size()));
        return new ImmutableListPathCore(null, relative.build());
    }
}

From source file:com.facebook.buck.features.haskell.HaskellDescriptionUtils.java

/** Give a rule that will result in a ghci session for the target */
public static HaskellGhciRule requireGhciRule(BuildTarget buildTarget, ProjectFilesystem projectFilesystem,
        BuildRuleParams params, CellPathResolver cellPathResolver, ActionGraphBuilder graphBuilder,
        HaskellPlatform platform, CxxBuckConfig cxxBuckConfig, ImmutableSortedSet<BuildTarget> argDeps,
        PatternMatchedCollection<ImmutableSortedSet<BuildTarget>> argPlatformDeps, SourceSortedSet argSrcs,
        ImmutableSortedSet<BuildTarget> argPreloadDeps,
        PatternMatchedCollection<ImmutableSortedSet<BuildTarget>> argPlatformPreloadDeps,
        ImmutableList<String> argCompilerFlags, Optional<BuildTarget> argGhciBinDep,
        Optional<SourcePath> argGhciInit, ImmutableList<SourcePath> argExtraScriptTemplates,
        boolean hsProfile) {
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(graphBuilder);
    SourcePathResolver pathResolver = DefaultSourcePathResolver.from(ruleFinder);

    ImmutableSet.Builder<BuildRule> depsBuilder = ImmutableSet.builder();
    depsBuilder.addAll(CxxDeps.builder().addDeps(argDeps).addPlatformDeps(argPlatformDeps).build()
            .get(graphBuilder, platform.getCxxPlatform()));
    ImmutableSet<BuildRule> deps = depsBuilder.build();

    ImmutableSet.Builder<BuildRule> preloadDepsBuilder = ImmutableSet.builder();
    preloadDepsBuilder.addAll(CxxDeps.builder().addDeps(argPreloadDeps).addPlatformDeps(argPlatformPreloadDeps)
            .build().get(graphBuilder, platform.getCxxPlatform()));
    ImmutableSet<BuildRule> preloadDeps = preloadDepsBuilder.build();

    // Haskell visitor
    ImmutableSet.Builder<HaskellPackage> haskellPackages = ImmutableSet.builder();
    ImmutableSet.Builder<HaskellPackage> prebuiltHaskellPackages = ImmutableSet.builder();
    ImmutableSet.Builder<HaskellPackage> firstOrderHaskellPackages = ImmutableSet.builder();
    AbstractBreadthFirstTraversal<BuildRule> haskellVisitor = new AbstractBreadthFirstTraversal<BuildRule>(
            deps) {/*from w  w w.ja  v a  2 s  . c  o  m*/
        @Override
        public ImmutableSet<BuildRule> visit(BuildRule rule) {
            ImmutableSet.Builder<BuildRule> traverse = ImmutableSet.builder();
            if (rule instanceof HaskellLibrary || rule instanceof PrebuiltHaskellLibrary) {
                HaskellCompileDep haskellRule = (HaskellCompileDep) rule;
                HaskellCompileInput ci = haskellRule.getCompileInput(platform, Linker.LinkableDepType.STATIC,
                        hsProfile);

                if (params.getBuildDeps().contains(rule)) {
                    firstOrderHaskellPackages.addAll(ci.getPackages());
                }

                if (rule instanceof HaskellLibrary) {
                    haskellPackages.addAll(ci.getPackages());
                } else if (rule instanceof PrebuiltHaskellLibrary) {
                    prebuiltHaskellPackages.addAll(ci.getPackages());
                }

                traverse.addAll(haskellRule.getCompileDeps(platform));
            }

            return traverse.build();
        }
    };
    haskellVisitor.start();

    // Build the omnibus composition spec.
    HaskellGhciOmnibusSpec omnibusSpec = HaskellGhciDescription.getOmnibusSpec(buildTarget,
            platform.getCxxPlatform(), graphBuilder,
            NativeLinkables.getNativeLinkableRoots(
                    RichStream.from(deps).filter(NativeLinkable.class).toImmutableList(),
                    n -> n instanceof HaskellLibrary || n instanceof PrebuiltHaskellLibrary ? Optional.of(
                            n.getNativeLinkableExportedDepsForPlatform(platform.getCxxPlatform(), graphBuilder))
                            : Optional.empty()),
            // The preloaded deps form our excluded roots, which we need to keep them separate from
            // the omnibus library so that they can be `LD_PRELOAD`ed early.
            RichStream.from(preloadDeps).filter(NativeLinkable.class)
                    .collect(ImmutableMap.toImmutableMap(NativeLinkable::getBuildTarget, l -> l)));

    // Add an -rpath to the omnibus for shared library dependencies
    Path symlinkRelDir = HaskellGhciDescription.getSoLibsRelDir(buildTarget);
    ImmutableList.Builder<Arg> extraLinkFlags = ImmutableList.builder();
    extraLinkFlags.addAll(StringArg.from(Linkers.iXlinker("-rpath", String.format("%s/%s",
            platform.getCxxPlatform().getLd().resolve(graphBuilder).origin(), symlinkRelDir.toString()))));

    // Construct the omnibus shared library.
    BuildRule omnibusSharedObject = HaskellGhciDescription.requireOmnibusSharedObject(cellPathResolver,
            buildTarget, projectFilesystem, graphBuilder, platform.getCxxPlatform(), cxxBuckConfig,
            omnibusSpec.getBody().values(), omnibusSpec.getDeps().values(), extraLinkFlags.build());

    // Build up a map of all transitive shared libraries the the monolithic omnibus library depends
    // on (basically, stuff we couldn't statically link in).  At this point, this should *not* be
    // pulling in any excluded deps.
    SharedLibrariesBuilder sharedLibsBuilder = new SharedLibrariesBuilder();
    ImmutableMap<BuildTarget, NativeLinkable> transitiveDeps = NativeLinkables.getTransitiveNativeLinkables(
            platform.getCxxPlatform(), graphBuilder, omnibusSpec.getDeps().values());
    transitiveDeps.values().stream()
            // Skip statically linked libraries.
            .filter(l -> l.getPreferredLinkage(platform.getCxxPlatform(), graphBuilder) != Linkage.STATIC)
            .forEach(l -> sharedLibsBuilder.add(platform.getCxxPlatform(), l, graphBuilder));
    ImmutableSortedMap<String, SourcePath> sharedLibs = sharedLibsBuilder.build();

    // Build up a set of all transitive preload libs, which are the ones that have been "excluded"
    // from the omnibus link.  These are the ones we need to LD_PRELOAD.
    SharedLibrariesBuilder preloadLibsBuilder = new SharedLibrariesBuilder();
    omnibusSpec.getExcludedTransitiveDeps().values().stream()
            // Don't include shared libs for static libraries -- except for preload roots, which we
            // always link dynamically.
            .filter(l -> l.getPreferredLinkage(platform.getCxxPlatform(), graphBuilder) != Linkage.STATIC
                    || omnibusSpec.getExcludedRoots().containsKey(l.getBuildTarget()))
            .forEach(l -> preloadLibsBuilder.add(platform.getCxxPlatform(), l, graphBuilder));
    ImmutableSortedMap<String, SourcePath> preloadLibs = preloadLibsBuilder.build();

    HaskellSources srcs = HaskellSources.from(buildTarget, graphBuilder, pathResolver, ruleFinder, platform,
            "srcs", argSrcs);

    return HaskellGhciRule.from(buildTarget, projectFilesystem, params, ruleFinder, srcs, argCompilerFlags,
            argGhciBinDep.map(
                    target -> Objects.requireNonNull(graphBuilder.getRule(target).getSourcePathToOutput())),
            argGhciInit, omnibusSharedObject, sharedLibs, preloadLibs, firstOrderHaskellPackages.build(),
            haskellPackages.build(), prebuiltHaskellPackages.build(), hsProfile,
            platform.getGhciScriptTemplate().get(), argExtraScriptTemplates,
            platform.getGhciIservScriptTemplate().get(), platform.getGhciBinutils().get(),
            platform.getGhciGhc().get(), platform.getGhciIServ().get(), platform.getGhciIServProf().get(),
            platform.getGhciLib().get(), platform.getGhciCxx().get(), platform.getGhciCc().get(),
            platform.getGhciCpp().get(), platform.getGhciPackager().get());
}

From source file:org.commoncrawl.mapred.ec2.parser.EC2ParserTask.java

private static List<Path> scanForCompletedSegments(FileSystem fs, Configuration conf) throws IOException {
    ImmutableList.Builder<Path> pathListBuilder = new ImmutableList.Builder<Path>();

    String validSegmentPathPrefix = conf.get(VALID_SEGMENTS_PATH_PROPERTY);

    for (FileStatus fileStatus : fs.globStatus(new Path(validSegmentPathPrefix + "[0-9]*"))) {
        pathListBuilder.addAll(scanSegmentManifestFile(fs, fileStatus.getPath()));
    }// w w  w.j  a v  a 2 s  .  com
    return pathListBuilder.build();
}

From source file:com.spectralogic.ds3autogen.java.generators.requestmodels.BaseRequestGenerator.java

/**
 * Converts a list of optional Ds3Params into a list of optional Arguments
 * @param optionalDs3Params A list of optional Ds3Params
 * @return A list of optional Arguments//from  ww  w.ja va  2  s . c  o m
 */
protected static ImmutableList<Arguments> toOptionalArgumentsList(
        final ImmutableList<Ds3Param> optionalDs3Params) {
    if (isEmpty(optionalDs3Params)) {
        return ImmutableList.of();
    }

    final ImmutableList.Builder<Arguments> optionalArgs = ImmutableList.builder();
    optionalArgs.addAll(toArgumentsList(optionalDs3Params));
    return optionalArgs.build();
}

From source file:com.facebook.buck.features.haskell.HaskellDescriptionUtils.java

/**
 * Create a Haskell link rule that links the given inputs to a executable or shared library and
 * pulls in transitive native linkable deps from the given dep roots.
 *///  w  ww  .  jav  a2s  . co m
public static HaskellLinkRule createLinkRule(BuildTarget target, ProjectFilesystem projectFilesystem,
        BuildRuleParams baseParams, ActionGraphBuilder graphBuilder, SourcePathRuleFinder ruleFinder,
        HaskellPlatform platform, Linker.LinkType linkType, ImmutableList<Arg> linkerFlags,
        Iterable<Arg> linkerInputs, Iterable<? extends NativeLinkable> deps,
        ImmutableSet<BuildTarget> linkWholeDeps, Linker.LinkableDepType depType, Path outputPath,
        Optional<String> soname, boolean hsProfile) {

    Tool linker = platform.getLinker().resolve(graphBuilder);

    ImmutableList.Builder<Arg> linkerArgsBuilder = ImmutableList.builder();
    ImmutableList.Builder<Arg> argsBuilder = ImmutableList.builder();

    // Add the base flags from the `.buckconfig` first.
    argsBuilder.addAll(StringArg.from(platform.getLinkerFlags()));

    // Pass in the appropriate flags to link a shared library.
    if (linkType.equals(Linker.LinkType.SHARED)) {
        argsBuilder.addAll(StringArg.from("-shared", "-dynamic"));
        soname.ifPresent(
                name -> argsBuilder.addAll(StringArg.from(MoreIterables.zipAndConcat(Iterables.cycle("-optl"),
                        platform.getCxxPlatform().getLd().resolve(graphBuilder).soname(name)))));
    }

    // Add in extra flags passed into this function.
    argsBuilder.addAll(linkerFlags);

    // We pass in the linker inputs and all native linkable deps by prefixing with `-optl` so that
    // the args go straight to the linker, and preserve their order.
    linkerArgsBuilder.addAll(linkerInputs);
    for (NativeLinkable nativeLinkable : NativeLinkables.getNativeLinkables(platform.getCxxPlatform(),
            graphBuilder, deps, depType)) {
        NativeLinkable.Linkage link = nativeLinkable.getPreferredLinkage(platform.getCxxPlatform(),
                graphBuilder);
        NativeLinkableInput input = nativeLinkable.getNativeLinkableInput(platform.getCxxPlatform(),
                NativeLinkables.getLinkStyle(link, depType),
                linkWholeDeps.contains(nativeLinkable.getBuildTarget()), graphBuilder);
        linkerArgsBuilder.addAll(input.getArgs());
    }

    // Since we use `-optl` to pass all linker inputs directly to the linker, the haskell linker
    // will complain about not having any input files.  So, create a dummy archive with an empty
    // module and pass that in normally to work around this.
    BuildTarget emptyModuleTarget = target.withAppendedFlavors(InternalFlavor.of("empty-module"));
    WriteFile emptyModule = graphBuilder
            .addToIndex(new WriteFile(emptyModuleTarget, projectFilesystem, "module Unused where",
                    BuildTargetPaths.getGenPath(projectFilesystem, emptyModuleTarget, "%s/Unused.hs"),
                    /* executable */ false));
    HaskellCompileRule emptyCompiledModule = graphBuilder.addToIndex(createCompileRule(
            target.withAppendedFlavors(InternalFlavor.of("empty-compiled-module")), projectFilesystem,
            baseParams, graphBuilder, ruleFinder,
            // TODO(agallagher): We shouldn't need any deps to compile an empty module, but ghc
            // implicitly tries to load the prelude and in some setups this is provided via a
            // Buck dependency.
            RichStream.from(deps).filter(BuildRule.class).toImmutableSortedSet(Ordering.natural()), platform,
            depType, hsProfile, Optional.empty(), Optional.empty(), ImmutableList.of(),
            HaskellSources.builder().putModuleMap("Unused", emptyModule.getSourcePathToOutput()).build()));
    BuildTarget emptyArchiveTarget = target.withAppendedFlavors(InternalFlavor.of("empty-archive"));
    Archive emptyArchive = graphBuilder.addToIndex(Archive.from(emptyArchiveTarget, projectFilesystem,
            graphBuilder, ruleFinder, platform.getCxxPlatform(),
            BuildTargetPaths.getGenPath(projectFilesystem, emptyArchiveTarget, "%s/libempty.a"),
            emptyCompiledModule.getObjects(), /* cacheable */ true));
    argsBuilder.add(SourcePathArg.of(emptyArchive.getSourcePathToOutput()));

    ImmutableList<Arg> args = argsBuilder.build();
    ImmutableList<Arg> linkerArgs = linkerArgsBuilder.build();

    return graphBuilder.addToIndex(new HaskellLinkRule(target, projectFilesystem, baseParams
            .withDeclaredDeps(ImmutableSortedSet.<BuildRule>naturalOrder()
                    .addAll(BuildableSupport.getDepsCollection(linker, ruleFinder))
                    .addAll(Stream.of(args, linkerArgs).flatMap(Collection::stream)
                            .flatMap(arg -> BuildableSupport.getDeps(arg, ruleFinder)).iterator())
                    .build())
            .withoutExtraDeps(), linker, outputPath, args, linkerArgs, platform.shouldCacheLinks()));
}

From source file:com.facebook.buck.features.go.GoDescriptors.java

static GoCompile createGoCompileRule(BuildTarget buildTarget, ProjectFilesystem projectFilesystem,
        BuildRuleParams params, ActionGraphBuilder graphBuilder, GoBuckConfig goBuckConfig, Path packageName,
        ImmutableSet<SourcePath> srcs, List<String> compilerFlags, List<String> assemblerFlags,
        GoPlatform platform, Iterable<BuildTarget> deps, Iterable<BuildTarget> cgoDeps,
        List<ListType> goListTypes) {
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(graphBuilder);
    SourcePathResolver pathResolver = DefaultSourcePathResolver.from(ruleFinder);

    Preconditions.checkState(buildTarget.getFlavors().contains(platform.getFlavor()));

    ImmutableSet<GoLinkable> linkables = requireGoLinkables(buildTarget, graphBuilder, platform, deps);

    ImmutableList.Builder<BuildRule> linkableDepsBuilder = ImmutableList.builder();
    for (GoLinkable linkable : linkables) {
        linkableDepsBuilder.addAll(linkable.getDeps(ruleFinder));
    }/*from w ww.  j  a  v a2  s .  c  om*/

    BuildTarget target = createSymlinkTreeTarget(buildTarget);
    SymlinkTree symlinkTree = makeSymlinkTree(target, projectFilesystem, ruleFinder, pathResolver, linkables);
    graphBuilder.addToIndex(symlinkTree);

    ImmutableList.Builder<SourcePath> extraAsmOutputsBuilder = ImmutableList.builder();

    ImmutableSet.Builder<SourcePath> generatedSrcBuilder = ImmutableSet.builder();
    for (BuildTarget cgoBuildTarget : cgoDeps) {
        CGoLibrary lib = getCGoLibrary(graphBuilder, platform, cgoBuildTarget);
        generatedSrcBuilder.addAll(lib.getGeneratedGoSource());
        extraAsmOutputsBuilder.add(lib.getOutput());

        linkableDepsBuilder.add(lib);
    }

    LOG.verbose("Symlink tree for compiling %s: %s", buildTarget, symlinkTree.getLinks());
    return new GoCompile(buildTarget, projectFilesystem,
            params.copyAppendingExtraDeps(linkableDepsBuilder.build())
                    .copyAppendingExtraDeps(ImmutableList.of(symlinkTree))
                    .copyAppendingExtraDeps(getDependenciesFromSources(ruleFinder, srcs)),
            symlinkTree, packageName,
            getPackageImportMap(goBuckConfig.getVendorPaths(), buildTarget.getBasePath(),
                    linkables.stream().flatMap(input -> input.getGoLinkInput().keySet().stream())
                            .collect(ImmutableList.toImmutableList())),
            srcs, generatedSrcBuilder.build(), ImmutableList.copyOf(compilerFlags),
            ImmutableList.copyOf(assemblerFlags), platform, goBuckConfig.getGensymabis(),
            extraAsmOutputsBuilder.build(), goListTypes);
}