use of com.facebook.buck.model.BuildTarget in project buck by facebook.
the class CxxDescriptionEnhancer method createSandboxSymlinkTree.
public static SymlinkTree createSandboxSymlinkTree(BuildRuleParams params, CxxPlatform cxxPlatform, ImmutableMap<Path, SourcePath> map, SourcePathRuleFinder ruleFinder) {
BuildTarget sandboxSymlinkTreeTarget = CxxDescriptionEnhancer.createSandboxSymlinkTreeTarget(params.getBuildTarget(), cxxPlatform.getFlavor());
Path sandboxSymlinkTreeRoot = CxxDescriptionEnhancer.getSandboxSymlinkTreePath(params.getProjectFilesystem(), sandboxSymlinkTreeTarget);
return new SymlinkTree(sandboxSymlinkTreeTarget, params.getProjectFilesystem(), sandboxSymlinkTreeRoot, map, ruleFinder);
}
use of com.facebook.buck.model.BuildTarget in project buck by facebook.
the class CxxDescriptionEnhancer method requireSandboxSymlinkTree.
private static SymlinkTree requireSandboxSymlinkTree(BuildRuleParams params, BuildRuleResolver ruleResolver, CxxPlatform cxxPlatform) throws NoSuchBuildTargetException {
BuildRuleParams untypedParams = CxxLibraryDescription.getUntypedParams(params);
BuildTarget headerSymlinkTreeTarget = CxxDescriptionEnhancer.createSandboxSymlinkTreeTarget(untypedParams.getBuildTarget(), cxxPlatform.getFlavor());
BuildRule rule = ruleResolver.requireRule(headerSymlinkTreeTarget);
Preconditions.checkState(rule instanceof SymlinkTree, rule.getBuildTarget() + " " + rule.getClass().toString());
return (SymlinkTree) rule;
}
use of com.facebook.buck.model.BuildTarget in project buck by facebook.
the class AbstractCxxSourceRuleFactory method requireCompileBuildRule.
@VisibleForTesting
CxxPreprocessAndCompile requireCompileBuildRule(String name, CxxSource source) {
BuildTarget target = createCompileBuildTarget(name);
Optional<CxxPreprocessAndCompile> existingRule = getResolver().getRuleOptionalWithType(target, CxxPreprocessAndCompile.class);
if (existingRule.isPresent()) {
if (!existingRule.get().getInput().equals(source.getPath())) {
throw new RuntimeException(String.format("Hash collision for %s; a build rule would have been ignored.", name));
}
return existingRule.get();
}
return createCompileBuildRule(name, source);
}
use of com.facebook.buck.model.BuildTarget 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;
}
}
use of com.facebook.buck.model.BuildTarget in project buck by facebook.
the class AbstractCxxSourceRuleFactory method createCompileBuildRule.
/**
* @return a {@link CxxPreprocessAndCompile} rule that preprocesses, compiles, and assembles the
* given {@link CxxSource}.
*/
@VisibleForTesting
public CxxPreprocessAndCompile createCompileBuildRule(String name, CxxSource source) {
Preconditions.checkArgument(CxxSourceTypes.isCompilableType(source.getType()));
BuildTarget target = createCompileBuildTarget(name);
DepsBuilder depsBuilder = new DepsBuilder(getRuleFinder());
Compiler compiler = CxxSourceTypes.getCompiler(getCxxPlatform(), source.getType()).resolve(getResolver());
// Build up the list of compiler flags.
CxxToolFlags flags = CxxToolFlags.explicitBuilder().addAllPlatformFlags(getPicType().getFlags(compiler)).addAllPlatformFlags(getPlatformCompileFlags(source.getType())).addAllRuleFlags(getRuleCompileFlags(source.getType())).addAllRuleFlags(source.getFlags()).build();
CompilerDelegate compilerDelegate = new CompilerDelegate(getPathResolver(), getCxxPlatform().getCompilerDebugPathSanitizer(), compiler, flags);
depsBuilder.add(compilerDelegate);
depsBuilder.add(source);
// Build the CxxCompile rule and add it to our sorted set of build rules.
CxxPreprocessAndCompile result = CxxPreprocessAndCompile.compile(getParams().withBuildTarget(target).copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(depsBuilder.build()), Suppliers.ofInstance(ImmutableSortedSet.of())), compilerDelegate, getCompileOutputPath(target, name), source.getPath(), source.getType(), getCxxPlatform().getCompilerDebugPathSanitizer(), getCxxPlatform().getAssemblerDebugPathSanitizer(), getSandboxTree());
getResolver().addToIndex(result);
return result;
}
Aggregations