Search in sources :

Example 21 with Arg

use of com.facebook.buck.rules.args.Arg in project buck by facebook.

the class CommandTool method getInputs.

@Override
public ImmutableCollection<SourcePath> getInputs() {
    ImmutableSortedSet.Builder<SourcePath> inputs = ImmutableSortedSet.naturalOrder();
    if (baseTool.isPresent()) {
        inputs.addAll(baseTool.get().getInputs());
    }
    for (Arg arg : args) {
        inputs.addAll(arg.getInputs());
    }
    inputs.addAll(extraInputs);
    return inputs.build();
}
Also used : ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) Arg(com.facebook.buck.rules.args.Arg) StringArg(com.facebook.buck.rules.args.StringArg)

Example 22 with Arg

use of com.facebook.buck.rules.args.Arg in project buck by facebook.

the class CxxPythonExtensionDescriptionTest method createBuildRuleNativeLinkableDep.

@Test
public void createBuildRuleNativeLinkableDep() throws Exception {
    ProjectFilesystem filesystem = new FakeProjectFilesystem();
    BuildTarget target = BuildTargetFactory.newInstance("//:target");
    // Setup a C/C++ library that we'll depend on form the C/C++ binary description.
    BuildTarget cxxLibraryTarget = BuildTargetFactory.newInstance("//:dep");
    CxxLibraryBuilder cxxLibraryBuilder = new CxxLibraryBuilder(cxxLibraryTarget).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("something.cpp"), ImmutableList.of())));
    CxxPythonExtensionBuilder builder = new CxxPythonExtensionBuilder(target, FlavorDomain.of("Python Platform", PY2, PY3), new CxxBuckConfig(FakeBuckConfig.builder().build()), CxxTestBuilder.createDefaultPlatforms()).setDeps(ImmutableSortedSet.of(cxxLibraryTarget));
    TargetGraph targetGraph = TargetGraphFactory.newInstance(cxxLibraryBuilder.build(), builder.build());
    BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    CxxLibrary dep = (CxxLibrary) cxxLibraryBuilder.build(resolver, filesystem, targetGraph);
    CxxPythonExtension extension = builder.build(resolver, filesystem, targetGraph);
    NativeLinkableInput depInput = dep.getNativeLinkableInput(CxxPlatformUtils.DEFAULT_PLATFORM, Linker.LinkableDepType.SHARED);
    // Verify that the shared library dep propagated to the link rule.
    extension.getPythonPackageComponents(PY2, CxxPlatformUtils.DEFAULT_PLATFORM);
    BuildRule rule = resolver.getRule(CxxPythonExtensionDescription.getExtensionTarget(target, PY2.getFlavor(), CxxPlatformUtils.DEFAULT_PLATFORM.getFlavor()));
    assertThat(rule.getDeps(), Matchers.hasItems(FluentIterable.from(depInput.getArgs()).transformAndConcat(arg -> arg.getDeps(ruleFinder)).toArray(BuildRule.class)));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) Linker(com.facebook.buck.cxx.Linker) NativeLinkTargetMode(com.facebook.buck.cxx.NativeLinkTargetMode) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) PatternMatchedCollection(com.facebook.buck.rules.coercer.PatternMatchedCollection) InternalFlavor(com.facebook.buck.model.InternalFlavor) Assert.assertThat(org.junit.Assert.assertThat) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) BuildRule(com.facebook.buck.rules.BuildRule) FlavorDomain(com.facebook.buck.model.FlavorDomain) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) CxxPlatformUtils(com.facebook.buck.cxx.CxxPlatformUtils) ImmutableList(com.google.common.collect.ImmutableList) FluentIterable(com.google.common.collect.FluentIterable) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) PrebuiltCxxLibraryBuilder(com.facebook.buck.cxx.PrebuiltCxxLibraryBuilder) BuildTargetFactory(com.facebook.buck.model.BuildTargetFactory) NativeLinkable(com.facebook.buck.cxx.NativeLinkable) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) MoreCollectors(com.facebook.buck.util.MoreCollectors) CxxLink(com.facebook.buck.cxx.CxxLink) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) TestCellBuilder.createCellRoots(com.facebook.buck.rules.TestCellBuilder.createCellRoots) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) NativeLinkableInput(com.facebook.buck.cxx.NativeLinkableInput) CxxTestBuilder(com.facebook.buck.cxx.CxxTestBuilder) TargetGraph(com.facebook.buck.rules.TargetGraph) Matchers(org.hamcrest.Matchers) Test(org.junit.Test) ExecutableFinder(com.facebook.buck.io.ExecutableFinder) BuildTarget(com.facebook.buck.model.BuildTarget) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) NativeLinkTarget(com.facebook.buck.cxx.NativeLinkTarget) Arg(com.facebook.buck.rules.args.Arg) CxxLibrary(com.facebook.buck.cxx.CxxLibrary) SourceWithFlags(com.facebook.buck.rules.SourceWithFlags) Paths(java.nio.file.Paths) TargetGraphFactory(com.facebook.buck.testutil.TargetGraphFactory) StringWithMacrosUtils(com.facebook.buck.rules.macros.StringWithMacrosUtils) Optional(java.util.Optional) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Pattern(java.util.regex.Pattern) CxxLibraryBuilder(com.facebook.buck.cxx.CxxLibraryBuilder) CxxBinaryBuilder(com.facebook.buck.cxx.CxxBinaryBuilder) Assert.assertEquals(org.junit.Assert.assertEquals) CxxLibrary(com.facebook.buck.cxx.CxxLibrary) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) TargetGraph(com.facebook.buck.rules.TargetGraph) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) NativeLinkableInput(com.facebook.buck.cxx.NativeLinkableInput) BuildTarget(com.facebook.buck.model.BuildTarget) PrebuiltCxxLibraryBuilder(com.facebook.buck.cxx.PrebuiltCxxLibraryBuilder) CxxLibraryBuilder(com.facebook.buck.cxx.CxxLibraryBuilder) BuildRule(com.facebook.buck.rules.BuildRule) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) Test(org.junit.Test)

Example 23 with Arg

use of com.facebook.buck.rules.args.Arg 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 24 with Arg

use of com.facebook.buck.rules.args.Arg 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 25 with Arg

use of com.facebook.buck.rules.args.Arg in project buck by facebook.

the class PrebuiltOcamlLibrary method getLinkableInput.

private NativeLinkableInput getLinkableInput(SourcePath sourcePath) {
    // Build the library path and linker arguments that we pass through the
    // {@link NativeLinkable} interface for linking.
    ImmutableList.Builder<Arg> argsBuilder = ImmutableList.builder();
    argsBuilder.add(SourcePathArg.of(sourcePath));
    for (SourcePath staticCLibraryPath : staticCLibraryPaths) {
        argsBuilder.add(SourcePathArg.of(staticCLibraryPath));
    }
    return NativeLinkableInput.of(argsBuilder.build(), ImmutableSet.of(), ImmutableSet.of());
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) ImmutableList(com.google.common.collect.ImmutableList) SourcePathArg(com.facebook.buck.rules.args.SourcePathArg) Arg(com.facebook.buck.rules.args.Arg)

Aggregations

Arg (com.facebook.buck.rules.args.Arg)28 StringArg (com.facebook.buck.rules.args.StringArg)21 BuildTarget (com.facebook.buck.model.BuildTarget)14 ImmutableList (com.google.common.collect.ImmutableList)14 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)13 SourcePath (com.facebook.buck.rules.SourcePath)13 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)13 BuildRule (com.facebook.buck.rules.BuildRule)12 SourcePathArg (com.facebook.buck.rules.args.SourcePathArg)12 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)11 Path (java.nio.file.Path)11 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)10 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)10 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)8 Test (org.junit.Test)8 HumanReadableException (com.facebook.buck.util.HumanReadableException)7 Linker (com.facebook.buck.cxx.Linker)6 InternalFlavor (com.facebook.buck.model.InternalFlavor)6 ImmutableMap (com.google.common.collect.ImmutableMap)6 CxxPreprocessorInput (com.facebook.buck.cxx.CxxPreprocessorInput)5