List of usage examples for com.google.common.collect ImmutableSortedSet of
public static <E extends Comparable<? super E>> ImmutableSortedSet<E> of(E element)
From source file:com.facebook.buck.jvm.java.ExternalJavac.java
@Override public ImmutableCollection<SourcePath> getInputs() { return pathToJavac.isRight() ? ImmutableSortedSet.of(pathToJavac.getRight()) : ImmutableSortedSet.of(); }
From source file:com.facebook.buck.apple.AppleDebuggableBinary.java
public static ImmutableSortedSet<BuildRule> getRequiredRuntimeDeps(AppleDebugFormat debugFormat, BuildRule strippedBinaryRule, ProvidesLinkedBinaryDeps unstrippedBinaryRule, Optional<AppleDsym> appleDsym) { if (debugFormat == AppleDebugFormat.NONE) { return ImmutableSortedSet.of(strippedBinaryRule); }/*from ww w. ja v a2 s . c o m*/ ImmutableSortedSet.Builder<BuildRule> builder = ImmutableSortedSet.naturalOrder(); if (debugFormat == AppleDebugFormat.DWARF) { builder.add(unstrippedBinaryRule); builder.addAll(unstrippedBinaryRule.getCompileDeps()); builder.addAll(unstrippedBinaryRule.getStaticLibraryDeps()); } else if (debugFormat == AppleDebugFormat.DWARF_AND_DSYM) { Preconditions.checkArgument(appleDsym.isPresent(), "debugFormat %s expects AppleDsym rule to be present", AppleDebugFormat.DWARF_AND_DSYM); builder.add(strippedBinaryRule); builder.add(appleDsym.get()); } return builder.build(); }
From source file:com.facebook.buck.js.ReactNativeLibraryGraphEnhancer.java
public AndroidReactNativeLibrary enhanceForAndroid(BuildRuleParams params, BuildRuleResolver resolver, AndroidReactNativeLibraryDescription.Args args) { SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver); SourcePathResolver sourcePathResolver = new SourcePathResolver(ruleFinder); BuildTarget originalBuildTarget = params.getBuildTarget(); ReactNativeBundle bundle = createReactNativeBundle(params, resolver, sourcePathResolver, ruleFinder, BuildTarget.builder(originalBuildTarget).addFlavors(REACT_NATIVE_BUNDLE_FLAVOR).build(), args, ReactNativePlatform.ANDROID); resolver.addToIndex(bundle);//from w w w .jav a 2 s . com ImmutableList.Builder<BuildRule> extraDeps = ImmutableList.builder(); extraDeps.add(bundle); if (args.rDotJavaPackage.isPresent()) { BuildRuleParams paramsForResource = params .copyWithBuildTarget(BuildTarget.builder(originalBuildTarget) .addFlavors(REACT_NATIVE_ANDROID_RES_FLAVOR).build()) .copyWithExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.of(bundle))); SourcePath resources = new BuildTargetSourcePath(bundle.getBuildTarget(), bundle.getResources()); BuildRule resource = new AndroidResource(paramsForResource, ruleFinder, /* deps */ ImmutableSortedSet.of(), resources, /* resSrcs */ ImmutableSortedSet.of(), Optional.of(resources), args.rDotJavaPackage.get(), /* assets */ null, /* assetsSrcs */ ImmutableSortedSet.of(), Optional.empty(), /* manifest */ null, /* hasWhitelistedStrings */ false); resolver.addToIndex(resource); extraDeps.add(resource); } return new AndroidReactNativeLibrary(params.appendExtraDeps(extraDeps.build()), bundle); }
From source file:com.facebook.buck.features.gwt.GwtModule.java
@Override public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) { ImmutableList.Builder<Step> steps = ImmutableList.builder(); Path workingDirectory = outputFile.getParent(); steps.addAll(MakeCleanDirectoryStep.of(BuildCellRelativePath .fromCellRelativePath(context.getBuildCellRootPath(), getProjectFilesystem(), workingDirectory))); // A CopyResourcesStep is needed so that a file that is at java/com/example/resource.txt in the // repository will be added as com/example/resource.txt in the resulting JAR (assuming that // "/java/" is listed under src_roots in .buckconfig). Path tempJarFolder = workingDirectory.resolve("tmp"); steps.add(new CopyResourcesStep(getProjectFilesystem(), context, getBuildTarget(), ResourcesParameters.builder() .setResources(ResourcesParameters.getNamedResources(context.getSourcePathResolver(), ruleFinder, getProjectFilesystem(), filesForGwtModule)) .setResourcesRoot(resourcesRoot).build(), tempJarFolder));/* w w w . j a v a2 s . c o m*/ steps.add(new JarDirectoryStep(getProjectFilesystem(), JarParameters.builder().setJarPath(outputFile) .setEntriesToJar(ImmutableSortedSet.of(tempJarFolder)).setMergeManifests(true).build())); buildableContext.recordArtifact(outputFile); return steps.build(); }
From source file:com.facebook.buck.d.DBinaryDescription.java
@Override public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph, BuildRuleParams params, BuildRuleResolver buildRuleResolver, A args) throws NoSuchBuildTargetException { SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(buildRuleResolver); SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder); SymlinkTree sourceTree = buildRuleResolver.addToIndex(DDescriptionUtils.createSourceSymlinkTree( DDescriptionUtils.getSymlinkTreeTarget(params.getBuildTarget()), params, pathResolver, args.srcs)); // Create a rule that actually builds the binary, and add that // rule to the index. CxxLink nativeLinkable = DDescriptionUtils.createNativeLinkable( params.copyWithBuildTarget(params.getBuildTarget().withAppendedFlavors(BINARY_FLAVOR)), buildRuleResolver, cxxPlatform, dBuckConfig, cxxBuckConfig, /* compilerFlags */ ImmutableList.of(), args.srcs, args.linkerFlags, DIncludes.builder().setLinkTree(new BuildTargetSourcePath(sourceTree.getBuildTarget())) .addAllSources(args.srcs.getPaths()).build()); buildRuleResolver.addToIndex(nativeLinkable); // Create a Tool for the executable. CommandTool.Builder executableBuilder = new CommandTool.Builder(); executableBuilder.addArg(//from w w w . j a v a2 s . c o m new SourcePathArg(pathResolver, new BuildTargetSourcePath(nativeLinkable.getBuildTarget()))); // Return a BinaryBuildRule implementation, so that this works // with buck run etc. return new DBinary(params.copyWithExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.of(nativeLinkable))), pathResolver, ruleFinder, executableBuilder.build(), nativeLinkable.getPathToOutput()); }
From source file:com.github.gv2011.util.icol.guava.GuavaIcolFactory.java
@Override public <T extends Comparable<? super T>> ISortedSet<T> sortedSetOf(final T element) { return new ISortedSetWrapper<>(ImmutableSortedSet.of(element)); }
From source file:com.facebook.buck.cpp.AbstractNativeBuildable.java
@Override public List<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) { ImmutableList.Builder<Step> steps = ImmutableList.builder(); ImmutableSortedSet.Builder<Path> objectFiles = ImmutableSortedSet.naturalOrder(); Set<Path> createdDirectories = Sets.newHashSet(); addMkdirStepIfNeeded(createdDirectories, steps, getPathToOutputFile().getParent()); for (SourcePath src : srcs) { Path srcFile = src.resolve(); // We expect srcFile to be relative to the buck root Preconditions.checkState(!srcFile.isAbsolute()); Path parent = srcFile.getParent(); if (parent == null) { parent = Paths.get(""); }/*from w w w .j av a2 s.c o m*/ // To avoid collisions, objects files are created in directories that reflects the path to // source files rather than the (path-like) name of build targets Path targetDir = BuckConstant.GEN_PATH.resolve(parent); addMkdirStepIfNeeded(createdDirectories, steps, targetDir); Path objectFile = targetDir .resolve(Files.getNameWithoutExtension(srcFile.getFileName().toString()) + OBJECT_EXTENSION); steps.add(new CompilerStep(/* compiler */ getCompiler(), /* shouldLink */ false, /* srcs */ ImmutableSortedSet.of(src.resolve()), /* outputFile */ objectFile, /* shouldAddProjectRootToIncludePaths */ true, /* includePaths */ ImmutableSortedSet.<Path>of())); objectFiles.add(objectFile); } for (BuildRule dep : deps) { // Only c++ static libraries are supported for now. if (dep.getBuildable() instanceof CppLibrary) { objectFiles.add(dep.getBuildable().getPathToOutputFile()); } } steps.addAll(getFinalBuildSteps(objectFiles.build(), getPathToOutputFile())); return steps.build(); }
From source file:com.facebook.buck.android.AndroidManifest.java
@Override public ImmutableSortedSet<BuildRule> getEnhancedDeps(BuildRuleResolver ruleResolver) { SourcePath skeletonFile = getSkeletonFile(); if (skeletonFile instanceof BuildRuleSourcePath) { BuildRule skeletonRule = ((BuildRuleSourcePath) skeletonFile).getRule(); return ImmutableSortedSet.of(skeletonRule); } else {//w w w . j a va 2s. com return ImmutableSortedSet.of(); } }
From source file:org.onosproject.yang.compiler.plugin.buck.YangLibrary.java
@Override public ImmutableList<Step> getBuildSteps(BuildContext buildContext, BuildableContext buildableContext) { ImmutableList.Builder<Step> steps = ImmutableList.builder(); // Delete the old output for this rule, if it exists. steps.add(new RmStep(getProjectFilesystem(), getPathToOutput(), /* shouldForceDeletion */ true, /* shouldRecurse */ true)); // Make sure that the directory to contain the output file exists. Rules get output to a // directory named after the base path, so we don't want to nuke the entire directory. steps.add(new MkdirStep(getProjectFilesystem(), outputDirectory)); steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), genSrcsDirectory)); List<Path> sourcePaths = srcs.stream().map(s -> getResolver().getRelativePath(s)) .collect(Collectors.toList()); steps.add(new YangStep(getProjectFilesystem(), sourcePaths, genSrcsDirectory, params.getDeps())); steps.add(new JarDirectoryStep(getProjectFilesystem(), output, ImmutableSortedSet.of(genSrcsDirectory), null, null));//from ww w. j av a 2 s . c o m return steps.build(); }
From source file:com.facebook.buck.features.d.DBinaryDescription.java
@Override public BuildRule createBuildRule(BuildRuleCreationContextWithTargetGraph context, BuildTarget buildTarget, BuildRuleParams params, DBinaryDescriptionArg args) { ActionGraphBuilder graphBuilder = context.getActionGraphBuilder(); SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(graphBuilder); SourcePathResolver pathResolver = DefaultSourcePathResolver.from(ruleFinder); ProjectFilesystem projectFilesystem = context.getProjectFilesystem(); if (buildTarget.getFlavors().contains(SOURCE_LINK_TREE)) { return DDescriptionUtils.createSourceSymlinkTree(buildTarget, projectFilesystem, pathResolver, ruleFinder, args.getSrcs()); }/*from w w w .j a va 2 s. c om*/ SymlinkTree sourceTree = (SymlinkTree) graphBuilder .requireRule(DDescriptionUtils.getSymlinkTreeTarget(buildTarget)); // Create a rule that actually builds the binary, and add that // rule to the index. CxxLink nativeLinkable = DDescriptionUtils.createNativeLinkable(context.getCellPathResolver(), buildTarget.withAppendedFlavors(BINARY_FLAVOR), projectFilesystem, params, graphBuilder, DDescriptionUtils.getCxxPlatform(graphBuilder, toolchainProvider, dBuckConfig), dBuckConfig, cxxBuckConfig, /* compilerFlags */ ImmutableList.of(), args.getSrcs(), args.getLinkerFlags(), DIncludes.builder().setLinkTree(sourceTree.getSourcePathToOutput()) .addAllSources(args.getSrcs().getPaths()).build()); graphBuilder.addToIndex(nativeLinkable); // Create a Tool for the executable. CommandTool.Builder executableBuilder = new CommandTool.Builder(); executableBuilder.addArg(SourcePathArg.of(nativeLinkable.getSourcePathToOutput())); // Return a BinaryBuildRule implementation, so that this works // with buck run etc. return new DBinary(buildTarget, projectFilesystem, params.withExtraDeps(ImmutableSortedSet.of(nativeLinkable)), executableBuilder.build(), nativeLinkable.getSourcePathToOutput()); }