Search in sources :

Example 6 with CxxPreprocessorInput

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

the class CxxPythonExtensionDescription method getExtensionArgs.

private ImmutableList<com.facebook.buck.rules.args.Arg> getExtensionArgs(BuildRuleParams params, BuildRuleResolver ruleResolver, SourcePathResolver pathResolver, SourcePathRuleFinder ruleFinder, CxxPlatform cxxPlatform, Arg args) throws NoSuchBuildTargetException {
    // Extract all C/C++ sources from the constructor arg.
    ImmutableMap<String, CxxSource> srcs = CxxDescriptionEnhancer.parseCxxSources(params.getBuildTarget(), ruleResolver, ruleFinder, pathResolver, cxxPlatform, args);
    ImmutableMap<Path, SourcePath> headers = CxxDescriptionEnhancer.parseHeaders(params.getBuildTarget(), ruleResolver, ruleFinder, pathResolver, Optional.of(cxxPlatform), args);
    // Setup the header symlink tree and combine all the preprocessor input from this rule
    // and all dependencies.
    HeaderSymlinkTree headerSymlinkTree = CxxDescriptionEnhancer.requireHeaderSymlinkTree(params, ruleResolver, cxxPlatform, headers, HeaderVisibility.PRIVATE, true);
    Optional<SymlinkTree> sandboxTree = Optional.empty();
    if (cxxBuckConfig.sandboxSources()) {
        sandboxTree = CxxDescriptionEnhancer.createSandboxTree(params, ruleResolver, cxxPlatform);
    }
    ImmutableList<CxxPreprocessorInput> cxxPreprocessorInput = CxxDescriptionEnhancer.collectCxxPreprocessorInput(params, cxxPlatform, CxxFlags.getLanguageFlags(args.preprocessorFlags, args.platformPreprocessorFlags, args.langPreprocessorFlags, cxxPlatform), ImmutableList.of(headerSymlinkTree), ImmutableSet.of(), CxxPreprocessables.getTransitiveCxxPreprocessorInput(cxxPlatform, params.getDeps()), args.includeDirs, sandboxTree);
    // Generate rule to build the object files.
    ImmutableMap<CxxPreprocessAndCompile, SourcePath> picObjects = CxxSourceRuleFactory.requirePreprocessAndCompileRules(params, ruleResolver, pathResolver, ruleFinder, cxxBuckConfig, cxxPlatform, cxxPreprocessorInput, CxxFlags.getLanguageFlags(args.compilerFlags, args.platformCompilerFlags, args.langCompilerFlags, cxxPlatform), args.prefixHeader, args.precompiledHeader, srcs, CxxSourceRuleFactory.PicType.PIC, sandboxTree);
    ImmutableList.Builder<com.facebook.buck.rules.args.Arg> argsBuilder = ImmutableList.builder();
    argsBuilder.addAll(CxxDescriptionEnhancer.toStringWithMacrosArgs(params.getBuildTarget(), params.getCellRoots(), ruleResolver, cxxPlatform, CxxFlags.getFlagsWithMacrosWithPlatformMacroExpansion(args.linkerFlags, args.platformLinkerFlags, cxxPlatform)));
    // Embed a origin-relative library path into the binary so it can find the shared libraries.
    argsBuilder.addAll(StringArg.from(Linkers.iXlinker("-rpath", String.format("%s/", cxxPlatform.getLd().resolve(ruleResolver).libOrigin()))));
    // Add object files into the args.
    argsBuilder.addAll(SourcePathArg.from(picObjects.values()));
    return argsBuilder.build();
}
Also used : Path(java.nio.file.Path) SourcePath(com.facebook.buck.rules.SourcePath) HeaderSymlinkTree(com.facebook.buck.cxx.HeaderSymlinkTree) CxxPreprocessAndCompile(com.facebook.buck.cxx.CxxPreprocessAndCompile) ImmutableList(com.google.common.collect.ImmutableList) CxxSource(com.facebook.buck.cxx.CxxSource) SourcePath(com.facebook.buck.rules.SourcePath) SymlinkTree(com.facebook.buck.rules.SymlinkTree) HeaderSymlinkTree(com.facebook.buck.cxx.HeaderSymlinkTree) StringArg(com.facebook.buck.rules.args.StringArg) SourcePathArg(com.facebook.buck.rules.args.SourcePathArg) CxxConstructorArg(com.facebook.buck.cxx.CxxConstructorArg) CxxPreprocessorInput(com.facebook.buck.cxx.CxxPreprocessorInput)

Example 7 with CxxPreprocessorInput

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

the class OcamlRuleBuilder method createFineGrainedBuildRule.

public static BuildRule createFineGrainedBuildRule(OcamlBuckConfig ocamlBuckConfig, final BuildRuleParams params, BuildRuleResolver resolver, ImmutableList<OcamlSource> srcs, boolean isLibrary, boolean bytecodeOnly, ImmutableList<Arg> argFlags, final ImmutableList<String> linkerFlags, boolean buildNativePlugin) throws NoSuchBuildTargetException {
    CxxPreprocessorInput cxxPreprocessorInputFromDeps = CxxPreprocessorInput.concat(CxxPreprocessables.getTransitiveCxxPreprocessorInput(ocamlBuckConfig.getCxxPlatform(), FluentIterable.from(params.getDeps()).filter(CxxPreprocessorDep.class::isInstance)));
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
    ImmutableList<String> nativeIncludes = FluentIterable.from(params.getDeps()).transformAndConcat(getLibInclude(false)).toList();
    ImmutableList<String> bytecodeIncludes = FluentIterable.from(params.getDeps()).transformAndConcat(getLibInclude(true)).toList();
    NativeLinkableInput nativeLinkableInput = getNativeLinkableInput(params.getDeps());
    NativeLinkableInput bytecodeLinkableInput = getBytecodeLinkableInput(params.getDeps());
    NativeLinkableInput cLinkableInput = getCLinkableInput(ocamlBuckConfig.getCxxPlatform(), params.getDeps());
    ImmutableList<OcamlLibrary> ocamlInput = OcamlUtil.getTransitiveOcamlInput(params.getDeps());
    BuildTarget buildTarget = isLibrary ? createStaticLibraryBuildTarget(params.getBuildTarget()) : createOcamlLinkTarget(params.getBuildTarget());
    final BuildRuleParams compileParams = params.withBuildTarget(buildTarget).copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>naturalOrder().addAll(ruleFinder.filterBuildRuleInputs(getInput(srcs))).addAll(Stream.of(nativeLinkableInput, bytecodeLinkableInput, cLinkableInput).flatMap(input -> input.getArgs().stream()).flatMap(arg -> arg.getDeps(ruleFinder).stream()).iterator()).addAll(argFlags.stream().flatMap(arg -> arg.getDeps(ruleFinder).stream()).iterator()).addAll(ruleFinder.filterBuildRuleInputs(ocamlBuckConfig.getCCompiler().resolve(resolver).getInputs())).addAll(ruleFinder.filterBuildRuleInputs(ocamlBuckConfig.getCxxCompiler().resolve(resolver).getInputs())).build()), Suppliers.ofInstance(ImmutableSortedSet.of()));
    ImmutableList.Builder<Arg> flagsBuilder = ImmutableList.builder();
    flagsBuilder.addAll(argFlags);
    ImmutableSortedSet.Builder<BuildRule> nativeCompileDepsBuilder = ImmutableSortedSet.naturalOrder();
    ImmutableSortedSet.Builder<BuildRule> bytecodeCompileDepsBuilder = ImmutableSortedSet.naturalOrder();
    ImmutableSortedSet.Builder<BuildRule> bytecodeLinkDepsBuilder = ImmutableSortedSet.naturalOrder();
    for (OcamlLibrary library : ocamlInput) {
        nativeCompileDepsBuilder.addAll(library.getNativeCompileDeps());
        bytecodeCompileDepsBuilder.addAll(library.getBytecodeCompileDeps());
        bytecodeLinkDepsBuilder.addAll(library.getBytecodeLinkDeps());
    }
    OcamlBuildContext ocamlContext = OcamlBuildContext.builder(ocamlBuckConfig).setProjectFilesystem(params.getProjectFilesystem()).setSourcePathResolver(pathResolver).setFlags(flagsBuilder.build()).setNativeIncludes(nativeIncludes).setBytecodeIncludes(bytecodeIncludes).setOcamlInput(ocamlInput).setNativeLinkableInput(nativeLinkableInput).setBytecodeLinkableInput(bytecodeLinkableInput).setCLinkableInput(cLinkableInput).setBuildTarget(buildTarget.getUnflavoredBuildTarget()).setLibrary(isLibrary).setCxxPreprocessorInput(cxxPreprocessorInputFromDeps).setInput(getInput(srcs)).setNativeCompileDeps(nativeCompileDepsBuilder.build()).setBytecodeCompileDeps(bytecodeCompileDepsBuilder.build()).setBytecodeLinkDeps(bytecodeLinkDepsBuilder.build()).setCPreprocessor(ocamlBuckConfig.getCPreprocessor().resolve(resolver)).build();
    Path baseDir = params.getProjectFilesystem().getRootPath().toAbsolutePath();
    ImmutableMap<Path, ImmutableList<Path>> mlInput = getMLInputWithDeps(baseDir, ocamlContext);
    ImmutableList<SourcePath> cInput = getCInput(pathResolver, getInput(srcs));
    OcamlBuildRulesGenerator generator = new OcamlBuildRulesGenerator(compileParams, pathResolver, ruleFinder, resolver, ocamlContext, mlInput, cInput, ocamlBuckConfig.getCCompiler().resolve(resolver), ocamlBuckConfig.getCxxCompiler().resolve(resolver), bytecodeOnly, buildNativePlugin);
    OcamlGeneratedBuildRules result = generator.generate();
    if (isLibrary) {
        return new OcamlStaticLibrary(params.copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>naturalOrder().addAll(params.getDeclaredDeps().get()).addAll(result.getRules()).build()), params.getExtraDeps()), compileParams, linkerFlags, result.getObjectFiles(), ocamlContext, result.getRules().get(0), result.getNativeCompileDeps(), result.getBytecodeCompileDeps(), ImmutableSortedSet.<BuildRule>naturalOrder().add(result.getBytecodeLink()).addAll(ruleFinder.filterBuildRuleInputs(result.getObjectFiles())).build());
    } else {
        return new OcamlBinary(params.copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>naturalOrder().addAll(params.getDeclaredDeps().get()).addAll(result.getRules()).build()), params.getExtraDeps()), result.getRules().get(0));
    }
}
Also used : NativeLinkables(com.facebook.buck.cxx.NativeLinkables) Linker(com.facebook.buck.cxx.Linker) OcamlSource(com.facebook.buck.rules.coercer.OcamlSource) CxxPreprocessorDep(com.facebook.buck.cxx.CxxPreprocessorDep) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePath(com.facebook.buck.rules.SourcePath) InternalFlavor(com.facebook.buck.model.InternalFlavor) BuildRule(com.facebook.buck.rules.BuildRule) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) FluentIterable(com.google.common.collect.FluentIterable) CxxPreprocessables(com.facebook.buck.cxx.CxxPreprocessables) NoSuchBuildTargetException(com.facebook.buck.parser.NoSuchBuildTargetException) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) BuildTargetSourcePath(com.facebook.buck.rules.BuildTargetSourcePath) Suppliers(com.google.common.base.Suppliers) BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) Path(java.nio.file.Path) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) Function(com.google.common.base.Function) ImmutableSet(com.google.common.collect.ImmutableSet) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) ImmutableMap(com.google.common.collect.ImmutableMap) NativeLinkableInput(com.facebook.buck.cxx.NativeLinkableInput) Set(java.util.Set) IOException(java.io.IOException) CxxPlatform(com.facebook.buck.cxx.CxxPlatform) Console(com.facebook.buck.util.Console) ProcessExecutorParams(com.facebook.buck.util.ProcessExecutorParams) BuildRuleDependencyVisitors(com.facebook.buck.rules.BuildRuleDependencyVisitors) HumanReadableException(com.facebook.buck.util.HumanReadableException) BuildTarget(com.facebook.buck.model.BuildTarget) List(java.util.List) Arg(com.facebook.buck.rules.args.Arg) Stream(java.util.stream.Stream) CxxPreprocessorInput(com.facebook.buck.cxx.CxxPreprocessorInput) Optional(java.util.Optional) Flavor(com.facebook.buck.model.Flavor) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) VisibleForTesting(com.google.common.annotations.VisibleForTesting) TopologicalSort(com.facebook.buck.graph.TopologicalSort) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) Joiner(com.google.common.base.Joiner) ImmutableList(com.google.common.collect.ImmutableList) SourcePath(com.facebook.buck.rules.SourcePath) BuildTargetSourcePath(com.facebook.buck.rules.BuildTargetSourcePath) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) BuildTarget(com.facebook.buck.model.BuildTarget) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) CxxPreprocessorDep(com.facebook.buck.cxx.CxxPreprocessorDep) BuildRule(com.facebook.buck.rules.BuildRule) SourcePath(com.facebook.buck.rules.SourcePath) BuildTargetSourcePath(com.facebook.buck.rules.BuildTargetSourcePath) Path(java.nio.file.Path) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) NativeLinkableInput(com.facebook.buck.cxx.NativeLinkableInput) BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) Arg(com.facebook.buck.rules.args.Arg) CxxPreprocessorInput(com.facebook.buck.cxx.CxxPreprocessorInput)

Example 8 with CxxPreprocessorInput

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

the class OcamlRuleBuilder method createBulkBuildRule.

public static BuildRule createBulkBuildRule(OcamlBuckConfig ocamlBuckConfig, final BuildRuleParams params, BuildRuleResolver resolver, ImmutableList<OcamlSource> srcs, boolean isLibrary, boolean bytecodeOnly, ImmutableList<Arg> argFlags, final ImmutableList<String> linkerFlags) throws NoSuchBuildTargetException {
    CxxPreprocessorInput cxxPreprocessorInputFromDeps = CxxPreprocessorInput.concat(CxxPreprocessables.getTransitiveCxxPreprocessorInput(ocamlBuckConfig.getCxxPlatform(), FluentIterable.from(params.getDeps()).filter(CxxPreprocessorDep.class::isInstance)));
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
    ImmutableList<String> nativeIncludes = FluentIterable.from(params.getDeps()).transformAndConcat(getLibInclude(false)).toList();
    ImmutableList<String> bytecodeIncludes = FluentIterable.from(params.getDeps()).transformAndConcat(getLibInclude(true)).toList();
    NativeLinkableInput nativeLinkableInput = getNativeLinkableInput(params.getDeps());
    NativeLinkableInput bytecodeLinkableInput = getBytecodeLinkableInput(params.getDeps());
    NativeLinkableInput cLinkableInput = getCLinkableInput(ocamlBuckConfig.getCxxPlatform(), params.getDeps());
    ImmutableList<OcamlLibrary> ocamlInput = OcamlUtil.getTransitiveOcamlInput(params.getDeps());
    ImmutableSortedSet.Builder<BuildRule> allDepsBuilder = ImmutableSortedSet.naturalOrder();
    allDepsBuilder.addAll(ruleFinder.filterBuildRuleInputs(getInput(srcs)));
    allDepsBuilder.addAll(Stream.of(nativeLinkableInput, bytecodeLinkableInput, cLinkableInput).flatMap(input -> input.getArgs().stream()).flatMap(arg -> arg.getDeps(ruleFinder).stream()).iterator());
    for (OcamlLibrary library : ocamlInput) {
        allDepsBuilder.addAll(library.getNativeCompileDeps());
        allDepsBuilder.addAll(library.getBytecodeCompileDeps());
    }
    allDepsBuilder.addAll(ruleFinder.filterBuildRuleInputs(ocamlBuckConfig.getCCompiler().resolve(resolver).getInputs()));
    allDepsBuilder.addAll(ruleFinder.filterBuildRuleInputs(ocamlBuckConfig.getCxxCompiler().resolve(resolver).getInputs()));
    allDepsBuilder.addAll(argFlags.stream().flatMap(arg -> arg.getDeps(ruleFinder).stream()).iterator());
    // The bulk rule will do preprocessing on sources, and so needs deps from the preprocessor
    // input object.
    allDepsBuilder.addAll(cxxPreprocessorInputFromDeps.getDeps(resolver, ruleFinder));
    ImmutableSortedSet<BuildRule> allDeps = allDepsBuilder.build();
    BuildTarget buildTarget = isLibrary ? createStaticLibraryBuildTarget(params.getBuildTarget()) : createOcamlLinkTarget(params.getBuildTarget());
    final BuildRuleParams compileParams = params.withBuildTarget(buildTarget).copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(allDeps), Suppliers.ofInstance(ImmutableSortedSet.of()));
    ImmutableList.Builder<Arg> flagsBuilder = ImmutableList.builder();
    flagsBuilder.addAll(argFlags);
    ImmutableSortedSet.Builder<BuildRule> nativeCompileDepsBuilder = ImmutableSortedSet.naturalOrder();
    ImmutableSortedSet.Builder<BuildRule> bytecodeCompileDepsBuilder = ImmutableSortedSet.naturalOrder();
    ImmutableSortedSet.Builder<BuildRule> bytecodeLinkDepsBuilder = ImmutableSortedSet.naturalOrder();
    for (OcamlLibrary library : ocamlInput) {
        nativeCompileDepsBuilder.addAll(library.getNativeCompileDeps());
        bytecodeCompileDepsBuilder.addAll(library.getBytecodeCompileDeps());
        bytecodeLinkDepsBuilder.addAll(library.getBytecodeLinkDeps());
    }
    OcamlBuildContext ocamlContext = OcamlBuildContext.builder(ocamlBuckConfig).setProjectFilesystem(params.getProjectFilesystem()).setSourcePathResolver(pathResolver).setFlags(flagsBuilder.build()).setNativeIncludes(nativeIncludes).setBytecodeIncludes(bytecodeIncludes).setOcamlInput(ocamlInput).setNativeLinkableInput(nativeLinkableInput).setBytecodeLinkableInput(bytecodeLinkableInput).setCLinkableInput(cLinkableInput).setBuildTarget(buildTarget.getUnflavoredBuildTarget()).setLibrary(isLibrary).setCxxPreprocessorInput(cxxPreprocessorInputFromDeps).setInput(getInput(srcs)).setNativeCompileDeps(nativeCompileDepsBuilder.build()).setBytecodeCompileDeps(bytecodeCompileDepsBuilder.build()).setBytecodeLinkDeps(bytecodeLinkDepsBuilder.build()).setCPreprocessor(ocamlBuckConfig.getCPreprocessor().resolve(resolver)).build();
    final OcamlBuild ocamlLibraryBuild = new OcamlBuild(compileParams, ocamlContext, ocamlBuckConfig.getCCompiler().resolve(resolver), ocamlBuckConfig.getCxxCompiler().resolve(resolver), bytecodeOnly);
    resolver.addToIndex(ocamlLibraryBuild);
    if (isLibrary) {
        return new OcamlStaticLibrary(params.copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>naturalOrder().addAll(params.getDeclaredDeps().get()).add(ocamlLibraryBuild).build()), params.getExtraDeps()), compileParams, linkerFlags, FluentIterable.from(srcs).transform(OcamlSource::getSource).transform(pathResolver::getAbsolutePath).filter(OcamlUtil.ext(OcamlCompilables.OCAML_C)).transform(ocamlContext::getCOutput).transform(input -> new ExplicitBuildTargetSourcePath(compileParams.getBuildTarget(), input)).toList(), ocamlContext, ocamlLibraryBuild, ImmutableSortedSet.of(ocamlLibraryBuild), ImmutableSortedSet.of(ocamlLibraryBuild), ImmutableSortedSet.of(ocamlLibraryBuild));
    } else {
        return new OcamlBinary(params.copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>naturalOrder().addAll(params.getDeclaredDeps().get()).add(ocamlLibraryBuild).build()), params.getExtraDeps()), ocamlLibraryBuild);
    }
}
Also used : NativeLinkables(com.facebook.buck.cxx.NativeLinkables) Linker(com.facebook.buck.cxx.Linker) OcamlSource(com.facebook.buck.rules.coercer.OcamlSource) CxxPreprocessorDep(com.facebook.buck.cxx.CxxPreprocessorDep) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePath(com.facebook.buck.rules.SourcePath) InternalFlavor(com.facebook.buck.model.InternalFlavor) BuildRule(com.facebook.buck.rules.BuildRule) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) FluentIterable(com.google.common.collect.FluentIterable) CxxPreprocessables(com.facebook.buck.cxx.CxxPreprocessables) NoSuchBuildTargetException(com.facebook.buck.parser.NoSuchBuildTargetException) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) BuildTargetSourcePath(com.facebook.buck.rules.BuildTargetSourcePath) Suppliers(com.google.common.base.Suppliers) BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) Path(java.nio.file.Path) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) Function(com.google.common.base.Function) ImmutableSet(com.google.common.collect.ImmutableSet) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) ImmutableMap(com.google.common.collect.ImmutableMap) NativeLinkableInput(com.facebook.buck.cxx.NativeLinkableInput) Set(java.util.Set) IOException(java.io.IOException) CxxPlatform(com.facebook.buck.cxx.CxxPlatform) Console(com.facebook.buck.util.Console) ProcessExecutorParams(com.facebook.buck.util.ProcessExecutorParams) BuildRuleDependencyVisitors(com.facebook.buck.rules.BuildRuleDependencyVisitors) HumanReadableException(com.facebook.buck.util.HumanReadableException) BuildTarget(com.facebook.buck.model.BuildTarget) List(java.util.List) Arg(com.facebook.buck.rules.args.Arg) Stream(java.util.stream.Stream) CxxPreprocessorInput(com.facebook.buck.cxx.CxxPreprocessorInput) Optional(java.util.Optional) Flavor(com.facebook.buck.model.Flavor) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) VisibleForTesting(com.google.common.annotations.VisibleForTesting) TopologicalSort(com.facebook.buck.graph.TopologicalSort) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) Joiner(com.google.common.base.Joiner) ImmutableList(com.google.common.collect.ImmutableList) BuildTarget(com.facebook.buck.model.BuildTarget) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) CxxPreprocessorDep(com.facebook.buck.cxx.CxxPreprocessorDep) OcamlSource(com.facebook.buck.rules.coercer.OcamlSource) BuildRule(com.facebook.buck.rules.BuildRule) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) NativeLinkableInput(com.facebook.buck.cxx.NativeLinkableInput) BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) Arg(com.facebook.buck.rules.args.Arg) CxxPreprocessorInput(com.facebook.buck.cxx.CxxPreprocessorInput)

Example 9 with CxxPreprocessorInput

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

the class AbstractNativeExecutableStarter method getTransitiveCxxPreprocessorInput.

private ImmutableList<CxxPreprocessorInput> getTransitiveCxxPreprocessorInput(CxxPlatform cxxPlatform, Iterable<? extends CxxPreprocessorDep> deps) throws NoSuchBuildTargetException {
    ImmutableList.Builder<CxxPreprocessorInput> inputs = ImmutableList.builder();
    inputs.addAll(CxxPreprocessables.getTransitiveCxxPreprocessorInput(cxxPlatform, FluentIterable.from(deps).filter(BuildRule.class)));
    for (CxxPreprocessorDep dep : Iterables.filter(deps, Predicates.not(BuildRule.class::isInstance))) {
        inputs.add(dep.getCxxPreprocessorInput(cxxPlatform, HeaderVisibility.PUBLIC));
    }
    return inputs.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) CxxPreprocessorDep(com.facebook.buck.cxx.CxxPreprocessorDep) CxxPreprocessorInput(com.facebook.buck.cxx.CxxPreprocessorInput)

Example 10 with CxxPreprocessorInput

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

the class AbstractOcamlBuildContext method getCCompileFlags.

public ImmutableList<String> getCCompileFlags() {
    ImmutableList.Builder<String> compileFlags = ImmutableList.builder();
    CxxPreprocessorInput cxxPreprocessorInput = getCxxPreprocessorInput();
    compileFlags.addAll(MoreIterables.zipAndConcat(Iterables.cycle("-ccopt"), CxxHeaders.getArgs(cxxPreprocessorInput.getIncludes(), getSourcePathResolver(), Optional.empty(), getCPreprocessor())));
    for (String cFlag : cxxPreprocessorInput.getPreprocessorFlags().get(CxxSource.Type.C)) {
        compileFlags.add("-ccopt", cFlag);
    }
    return compileFlags.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) CxxPreprocessorInput(com.facebook.buck.cxx.CxxPreprocessorInput)

Aggregations

CxxPreprocessorInput (com.facebook.buck.cxx.CxxPreprocessorInput)12 ImmutableList (com.google.common.collect.ImmutableList)11 SourcePath (com.facebook.buck.rules.SourcePath)9 Path (java.nio.file.Path)7 BuildTarget (com.facebook.buck.model.BuildTarget)5 BuildRule (com.facebook.buck.rules.BuildRule)5 CxxPlatform (com.facebook.buck.cxx.CxxPlatform)4 NativeLinkableInput (com.facebook.buck.cxx.NativeLinkableInput)4 CxxPreprocessables (com.facebook.buck.cxx.CxxPreprocessables)3 CxxPreprocessorDep (com.facebook.buck.cxx.CxxPreprocessorDep)3 HeaderSymlinkTree (com.facebook.buck.cxx.HeaderSymlinkTree)3 NoSuchBuildTargetException (com.facebook.buck.parser.NoSuchBuildTargetException)3 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)3 ExplicitBuildTargetSourcePath (com.facebook.buck.rules.ExplicitBuildTargetSourcePath)3 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)3 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 ImmutableSet (com.google.common.collect.ImmutableSet)3 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)3