/** * Makes sure all build rules needed to produce the shared library are added to the action graph. * * @return the {@link SourcePath} representing the actual shared library. */ private SourcePath requireSharedLibrary(CxxPlatform cxxPlatform) throws NoSuchBuildTargetException { Path sharedLibraryPath = PrebuiltCxxLibraryDescription.getSharedLibraryPath( getBuildTarget(), params.getCellRoots(), ruleResolver, cxxPlatform, libDir, libName); // If the shared library is prebuilt, just return a reference to it. if (params.getProjectFilesystem().exists(sharedLibraryPath)) { return new PathSourcePath(params.getProjectFilesystem(), sharedLibraryPath); } // Otherwise, generate it's build rule. BuildRule sharedLibrary = ruleResolver.requireRule( getBuildTarget() .withFlavors(cxxPlatform.getFlavor(), CxxDescriptionEnhancer.SHARED_FLAVOR)); return new BuildTargetSourcePath(sharedLibrary.getBuildTarget()); }
/** * @return adds a the header {@link SymlinkTree} for the given rule to the {@link * CxxPreprocessorInput}. */ public static CxxPreprocessorInput.Builder addHeaderSymlinkTree( CxxPreprocessorInput.Builder builder, BuildTarget target, BuildRuleResolver ruleResolver, Flavor flavor, HeaderVisibility headerVisibility, IncludeType includeType) throws NoSuchBuildTargetException { BuildRule rule = ruleResolver.requireRule( BuildTarget.builder(target) .addFlavors( flavor, CxxDescriptionEnhancer.getHeaderSymlinkTreeFlavor(headerVisibility)) .build()); Preconditions.checkState( rule instanceof HeaderSymlinkTree, "Attempt to add %s of type %s and class %s to %s", rule.getFullyQualifiedName(), rule.getType(), rule.getClass(), target); HeaderSymlinkTree symlinkTree = (HeaderSymlinkTree) rule; builder .addRules(symlinkTree.getBuildTarget()) .setIncludes( CxxHeaders.builder() .setNameToPathMap(ImmutableSortedMap.copyOf(symlinkTree.getLinks())) .setFullNameToPathMap(ImmutableSortedMap.copyOf(symlinkTree.getFullLinks())) .build()); switch (includeType) { case LOCAL: builder.addIncludeRoots(symlinkTree.getIncludePath()); builder.addAllHeaderMaps(symlinkTree.getHeaderMap().asSet()); break; case SYSTEM: builder.addSystemIncludeRoots(symlinkTree.getSystemIncludePath()); break; } return builder; }