Search in sources :

Example 1 with DependencyAggregation

use of com.facebook.buck.rules.DependencyAggregation in project buck by facebook.

the class AbstractCxxSourceRuleFactory method requireAggregatedPreprocessDepsRule.

/**
   * Returns the no-op rule that aggregates the preprocessor dependencies.
   *
   * Individual compile rules can depend on it, instead of having to depend on every preprocessor
   * dep themselves. This turns O(n*m) dependencies into O(n+m) dependencies, where n is number of
   * files in a target, and m is the number of targets.
   */
private BuildRule requireAggregatedPreprocessDepsRule() {
    BuildTarget target = createAggregatedPreprocessDepsBuildTarget();
    Optional<DependencyAggregation> existingRule = getResolver().getRuleOptionalWithType(target, DependencyAggregation.class);
    if (existingRule.isPresent()) {
        return existingRule.get();
    } else {
        BuildRuleParams params = getParams().withBuildTarget(target).copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(getPreprocessDeps()), Suppliers.ofInstance(ImmutableSortedSet.of()));
        DependencyAggregation rule = new DependencyAggregation(params);
        getResolver().addToIndex(rule);
        return rule;
    }
}
Also used : BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) UnflavoredBuildTarget(com.facebook.buck.model.UnflavoredBuildTarget) BuildTarget(com.facebook.buck.model.BuildTarget) DependencyAggregation(com.facebook.buck.rules.DependencyAggregation)

Example 2 with DependencyAggregation

use of com.facebook.buck.rules.DependencyAggregation in project buck by facebook.

the class CxxPrecompiledHeaderTemplate method requireAggregatedDepsRule.

public DependencyAggregation requireAggregatedDepsRule(CxxPlatform cxxPlatform) {
    BuildTarget depAggTarget = createAggregatedDepsTarget(cxxPlatform);
    Optional<DependencyAggregation> existingRule = ruleResolver.getRuleOptionalWithType(depAggTarget, DependencyAggregation.class);
    if (existingRule.isPresent()) {
        return existingRule.get();
    }
    BuildRuleParams depAggParams = params.withBuildTarget(depAggTarget).copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(getPreprocessDeps(cxxPlatform)), Suppliers.ofInstance(ImmutableSortedSet.of()));
    DependencyAggregation depAgg = new DependencyAggregation(depAggParams);
    ruleResolver.addToIndex(depAgg);
    return depAgg;
}
Also used : BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) BuildTarget(com.facebook.buck.model.BuildTarget) DependencyAggregation(com.facebook.buck.rules.DependencyAggregation)

Aggregations

BuildTarget (com.facebook.buck.model.BuildTarget)2 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)2 DependencyAggregation (com.facebook.buck.rules.DependencyAggregation)2 UnflavoredBuildTarget (com.facebook.buck.model.UnflavoredBuildTarget)1