Search in sources :

Example 1 with StripStyle

use of com.facebook.buck.cxx.StripStyle 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 2 with StripStyle

use of com.facebook.buck.cxx.StripStyle in project buck by facebook.

the class AppleLibraryDescription method createLibraryBuildRule.

/**
   * @param targetGraph The target graph.
   * @param bundleLoader The binary in which the current library will be (dynamically) loaded into.
   *                     Only valid when building a shared library with MACH_O_BUNDLE link type.
   */
public <A extends AppleNativeTargetDescriptionArg> BuildRule createLibraryBuildRule(TargetGraph targetGraph, BuildRuleParams params, BuildRuleResolver resolver, A args, Optional<Linker.LinkableDepType> linkableDepType, Optional<SourcePath> bundleLoader, ImmutableSet<BuildTarget> blacklist) throws NoSuchBuildTargetException {
    // We explicitly remove flavors from params to make sure rule
    // has the same output regardless if we will strip or not.
    Optional<StripStyle> flavoredStripStyle = StripStyle.FLAVOR_DOMAIN.getValue(params.getBuildTarget());
    params = CxxStrip.removeStripStyleFlavorInParams(params, flavoredStripStyle);
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
    BuildRule unstrippedBinaryRule = requireUnstrippedBuildRule(params, resolver, targetGraph, args, linkableDepType, bundleLoader, blacklist, pathResolver);
    if (!shouldWrapIntoDebuggableBinary(params.getBuildTarget(), unstrippedBinaryRule)) {
        return unstrippedBinaryRule;
    }
    // If we built a multiarch binary, we can just use the strip tool from any platform.
    // We pick the platform in this odd way due to FlavorDomain's restriction of allowing only one
    // matching flavor in the build target.
    CxxPlatform representativePlatform = delegate.getCxxPlatforms().getValue(Iterables.getFirst(Sets.intersection(delegate.getCxxPlatforms().getFlavors(), params.getBuildTarget().getFlavors()), defaultCxxPlatform.getFlavor()));
    params = CxxStrip.restoreStripStyleFlavorInParams(params, flavoredStripStyle);
    BuildRule strippedBinaryRule = CxxDescriptionEnhancer.createCxxStripRule(params, resolver, flavoredStripStyle.orElse(StripStyle.NON_GLOBAL_SYMBOLS), unstrippedBinaryRule, representativePlatform);
    return AppleDescriptions.createAppleDebuggableBinary(params, resolver, strippedBinaryRule, (ProvidesLinkedBinaryDeps) unstrippedBinaryRule, AppleDebugFormat.FLAVOR_DOMAIN.getValue(params.getBuildTarget()).orElse(appleConfig.getDefaultDebugInfoFormatForLibraries()), delegate.getCxxPlatforms(), delegate.getDefaultCxxPlatform(), appleCxxPlatformFlavorDomain);
}
Also used : StripStyle(com.facebook.buck.cxx.StripStyle) CxxPlatform(com.facebook.buck.cxx.CxxPlatform) BuildRule(com.facebook.buck.rules.BuildRule) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder)

Aggregations

StripStyle (com.facebook.buck.cxx.StripStyle)2 CxxBinary (com.facebook.buck.cxx.CxxBinary)1 CxxLinkAndCompileRules (com.facebook.buck.cxx.CxxLinkAndCompileRules)1 CxxPlatform (com.facebook.buck.cxx.CxxPlatform)1 CxxSource (com.facebook.buck.cxx.CxxSource)1 LinkerMapMode (com.facebook.buck.cxx.LinkerMapMode)1 BuildRule (com.facebook.buck.rules.BuildRule)1 ExplicitBuildTargetSourcePath (com.facebook.buck.rules.ExplicitBuildTargetSourcePath)1 SourcePath (com.facebook.buck.rules.SourcePath)1 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)1 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)1 FrameworkPath (com.facebook.buck.rules.coercer.FrameworkPath)1 ImmutableList (com.google.common.collect.ImmutableList)1