Search in sources :

Example 1 with FrameworkPath

use of com.facebook.buck.rules.coercer.FrameworkPath in project buck by facebook.

the class AbstractPreprocessorFlags method getDeps.

public Iterable<BuildRule> getDeps(SourcePathRuleFinder ruleFinder) {
    ImmutableList.Builder<BuildRule> deps = ImmutableList.builder();
    deps.addAll(ruleFinder.filterBuildRuleInputs(OptionalCompat.asSet(getPrefixHeader())));
    for (CxxHeaders cxxHeaders : getIncludes()) {
        deps.addAll(cxxHeaders.getDeps(ruleFinder));
    }
    for (FrameworkPath frameworkPath : getFrameworkPaths()) {
        deps.addAll(frameworkPath.getDeps(ruleFinder));
    }
    return deps.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) BuildRule(com.facebook.buck.rules.BuildRule) FrameworkPath(com.facebook.buck.rules.coercer.FrameworkPath)

Example 2 with FrameworkPath

use of com.facebook.buck.rules.coercer.FrameworkPath in project buck by facebook.

the class AbstractCxxPreprocessorInput method getDeps.

public Iterable<BuildRule> getDeps(BuildRuleResolver ruleResolver, SourcePathRuleFinder ruleFinder) {
    ImmutableList.Builder<BuildRule> builder = ImmutableList.builder();
    for (CxxHeaders cxxHeaders : getIncludes()) {
        builder.addAll(cxxHeaders.getDeps(ruleFinder));
    }
    builder.addAll(ruleResolver.getAllRules(getRules()));
    for (FrameworkPath frameworkPath : getFrameworks()) {
        if (frameworkPath.getSourcePath().isPresent()) {
            Optional<BuildRule> frameworkRule = ruleFinder.getRule(frameworkPath.getSourcePath().get());
            if (frameworkRule.isPresent()) {
                builder.add(frameworkRule.get());
            }
        }
    }
    return builder.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) BuildRule(com.facebook.buck.rules.BuildRule) FrameworkPath(com.facebook.buck.rules.coercer.FrameworkPath)

Example 3 with FrameworkPath

use of com.facebook.buck.rules.coercer.FrameworkPath in project buck by facebook.

the class HalideLibraryDescription method createHalideCompiler.

private CxxBinary createHalideCompiler(BuildRuleParams params, BuildRuleResolver ruleResolver, SourcePathResolver pathResolver, SourcePathRuleFinder ruleFinder, CxxPlatform cxxPlatform, ImmutableSortedSet<SourceWithFlags> halideSources, ImmutableList<String> compilerFlags, PatternMatchedCollection<ImmutableList<String>> platformCompilerFlags, ImmutableMap<CxxSource.Type, ImmutableList<String>> langCompilerFlags, ImmutableList<StringWithMacros> linkerFlags, PatternMatchedCollection<ImmutableList<StringWithMacros>> platformLinkerFlags, ImmutableList<String> includeDirs) throws NoSuchBuildTargetException {
    Optional<StripStyle> flavoredStripStyle = StripStyle.FLAVOR_DOMAIN.getValue(params.getBuildTarget());
    Optional<LinkerMapMode> flavoredLinkerMapMode = LinkerMapMode.FLAVOR_DOMAIN.getValue(params.getBuildTarget());
    params = CxxStrip.removeStripStyleFlavorInParams(params, flavoredStripStyle);
    params = LinkerMapMode.removeLinkerMapModeFlavorInParams(params, flavoredLinkerMapMode);
    ImmutableMap<String, CxxSource> srcs = CxxDescriptionEnhancer.parseCxxSources(params.getBuildTarget(), ruleResolver, ruleFinder, pathResolver, cxxPlatform, halideSources, PatternMatchedCollection.of());
    ImmutableList<String> preprocessorFlags = ImmutableList.of();
    PatternMatchedCollection<ImmutableList<String>> platformPreprocessorFlags = PatternMatchedCollection.of();
    ImmutableMap<CxxSource.Type, ImmutableList<String>> langPreprocessorFlags = ImmutableMap.of();
    ImmutableSortedSet<FrameworkPath> frameworks = ImmutableSortedSet.of();
    ImmutableSortedSet<FrameworkPath> libraries = ImmutableSortedSet.of();
    Optional<SourcePath> prefixHeader = Optional.empty();
    Optional<SourcePath> precompiledHeader = Optional.empty();
    Optional<Linker.CxxRuntimeType> cxxRuntimeType = Optional.empty();
    CxxLinkAndCompileRules cxxLinkAndCompileRules = CxxDescriptionEnhancer.createBuildRulesForCxxBinary(params, ruleResolver, cxxBuckConfig, cxxPlatform, srcs, /* headers */
    ImmutableMap.of(), params.getDeps(), flavoredStripStyle, flavoredLinkerMapMode, Linker.LinkableDepType.STATIC, preprocessorFlags, platformPreprocessorFlags, langPreprocessorFlags, frameworks, libraries, compilerFlags, langCompilerFlags, platformCompilerFlags, prefixHeader, precompiledHeader, linkerFlags, platformLinkerFlags, cxxRuntimeType, includeDirs, Optional.empty());
    params = CxxStrip.restoreStripStyleFlavorInParams(params, flavoredStripStyle);
    params = LinkerMapMode.restoreLinkerMapModeFlavorInParams(params, flavoredLinkerMapMode);
    CxxBinary cxxBinary = new CxxBinary(params.copyAppendingExtraDeps(cxxLinkAndCompileRules.executable.getDeps(ruleFinder)), ruleResolver, ruleFinder, cxxLinkAndCompileRules.getBinaryRule(), cxxLinkAndCompileRules.executable, ImmutableSortedSet.of(), ImmutableSortedSet.of(), params.getBuildTarget().withoutFlavors(cxxPlatforms.getFlavors()));
    ruleResolver.addToIndex(cxxBinary);
    return cxxBinary;
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) CxxSource(com.facebook.buck.cxx.CxxSource) LinkerMapMode(com.facebook.buck.cxx.LinkerMapMode) FrameworkPath(com.facebook.buck.rules.coercer.FrameworkPath) SourcePath(com.facebook.buck.rules.SourcePath) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) CxxLinkAndCompileRules(com.facebook.buck.cxx.CxxLinkAndCompileRules) StripStyle(com.facebook.buck.cxx.StripStyle) CxxBinary(com.facebook.buck.cxx.CxxBinary)

Example 4 with FrameworkPath

use of com.facebook.buck.rules.coercer.FrameworkPath in project buck by facebook.

the class CxxLibraryDescription method createSharedLibrary.

/**
   * Create all build rules needed to generate the shared library.
   *
   * @return the {@link CxxLink} rule representing the actual shared library.
   */
private static CxxLink createSharedLibrary(BuildRuleParams params, BuildRuleResolver ruleResolver, SourcePathResolver pathResolver, SourcePathRuleFinder ruleFinder, CxxBuckConfig cxxBuckConfig, CxxPlatform cxxPlatform, CxxLibraryDescription.Arg args, ImmutableList<StringWithMacros> linkerFlags, ImmutableSet<FrameworkPath> frameworks, ImmutableSet<FrameworkPath> libraries, Optional<String> soname, Optional<Linker.CxxRuntimeType> cxxRuntimeType, Linker.LinkType linkType, Linker.LinkableDepType linkableDepType, Optional<SourcePath> bundleLoader, ImmutableSet<BuildTarget> blacklist) throws NoSuchBuildTargetException {
    Optional<LinkerMapMode> flavoredLinkerMapMode = LinkerMapMode.FLAVOR_DOMAIN.getValue(params.getBuildTarget());
    params = LinkerMapMode.removeLinkerMapModeFlavorInParams(params, flavoredLinkerMapMode);
    // Create rules for compiling the PIC object files.
    ImmutableMap<CxxPreprocessAndCompile, SourcePath> objects = requireObjects(params, ruleResolver, pathResolver, ruleFinder, cxxBuckConfig, cxxPlatform, CxxSourceRuleFactory.PicType.PIC, args);
    // Setup the rules to link the shared library.
    BuildTarget sharedTarget = CxxDescriptionEnhancer.createSharedLibraryBuildTarget(LinkerMapMode.restoreLinkerMapModeFlavorInParams(params, flavoredLinkerMapMode).getBuildTarget(), cxxPlatform.getFlavor(), linkType);
    String sharedLibrarySoname = CxxDescriptionEnhancer.getSharedLibrarySoname(soname, params.getBuildTarget(), cxxPlatform);
    Path sharedLibraryPath = CxxDescriptionEnhancer.getSharedLibraryPath(params.getProjectFilesystem(), sharedTarget, sharedLibrarySoname);
    ImmutableList.Builder<StringWithMacros> extraLdFlagsBuilder = ImmutableList.builder();
    extraLdFlagsBuilder.addAll(linkerFlags);
    ImmutableList<StringWithMacros> extraLdFlags = extraLdFlagsBuilder.build();
    return CxxLinkableEnhancer.createCxxLinkableBuildRule(cxxBuckConfig, cxxPlatform, LinkerMapMode.restoreLinkerMapModeFlavorInParams(params, flavoredLinkerMapMode), ruleResolver, pathResolver, ruleFinder, sharedTarget, linkType, Optional.of(sharedLibrarySoname), sharedLibraryPath, linkableDepType, Iterables.filter(params.getDeps(), NativeLinkable.class), cxxRuntimeType, bundleLoader, blacklist, NativeLinkableInput.builder().addAllArgs(CxxDescriptionEnhancer.toStringWithMacrosArgs(params.getBuildTarget(), params.getCellRoots(), ruleResolver, cxxPlatform, extraLdFlags)).addAllArgs(SourcePathArg.from(objects.values())).setFrameworks(frameworks).setLibraries(libraries).build());
}
Also used : Path(java.nio.file.Path) FrameworkPath(com.facebook.buck.rules.coercer.FrameworkPath) SourcePath(com.facebook.buck.rules.SourcePath) ImmutableList(com.google.common.collect.ImmutableList) StringWithMacros(com.facebook.buck.rules.macros.StringWithMacros) SourcePath(com.facebook.buck.rules.SourcePath) BuildTarget(com.facebook.buck.model.BuildTarget)

Example 5 with FrameworkPath

use of com.facebook.buck.rules.coercer.FrameworkPath in project buck by facebook.

the class CxxLinkableEnhancer method frameworksToLinkerArg.

@VisibleForTesting
static Arg frameworksToLinkerArg(ImmutableSortedSet<FrameworkPath> frameworkPaths) {
    return new FrameworkPathArg(frameworkPaths) {

        @Override
        public void appendToCommandLine(ImmutableCollection.Builder<String> builder, SourcePathResolver pathResolver) {
            for (FrameworkPath frameworkPath : frameworkPaths) {
                builder.add("-framework");
                builder.add(frameworkPath.getName(pathResolver::getAbsolutePath));
            }
        }
    };
}
Also used : SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) FrameworkPath(com.facebook.buck.rules.coercer.FrameworkPath) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

FrameworkPath (com.facebook.buck.rules.coercer.FrameworkPath)14 BuildTarget (com.facebook.buck.model.BuildTarget)6 ImmutableList (com.google.common.collect.ImmutableList)6 SourcePath (com.facebook.buck.rules.SourcePath)5 Path (java.nio.file.Path)5 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)4 BuildRule (com.facebook.buck.rules.BuildRule)4 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)4 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)4 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)4 Test (org.junit.Test)4 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)3 FakeBuildRuleParamsBuilder (com.facebook.buck.rules.FakeBuildRuleParamsBuilder)3 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)3 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)3 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)3 PBXFileReference (com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference)2 PBXGroup (com.facebook.buck.apple.xcode.xcodeproj.PBXGroup)2 SourceTreePath (com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath)2 LinkerMapMode (com.facebook.buck.cxx.LinkerMapMode)2