use of com.facebook.buck.rules.Tool in project buck by facebook.
the class ScalaLibraryDescription method createBuildRule.
@Override
public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph, final BuildRuleParams rawParams, final BuildRuleResolver resolver, A args) throws NoSuchBuildTargetException {
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
if (CalculateAbi.isAbiTarget(rawParams.getBuildTarget())) {
BuildTarget libraryTarget = CalculateAbi.getLibraryTarget(rawParams.getBuildTarget());
BuildRule libraryRule = resolver.requireRule(libraryTarget);
return CalculateAbi.of(rawParams.getBuildTarget(), ruleFinder, rawParams, Preconditions.checkNotNull(libraryRule.getSourcePathToOutput()));
}
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
Tool scalac = scalaBuckConfig.getScalac(resolver);
final BuildRule scalaLibrary = resolver.getRule(scalaBuckConfig.getScalaLibraryTarget());
BuildRuleParams params = rawParams.copyReplacingDeclaredAndExtraDeps(() -> ImmutableSortedSet.<BuildRule>naturalOrder().addAll(rawParams.getDeclaredDeps().get()).add(scalaLibrary).build(), rawParams.getExtraDeps());
BuildRuleParams javaLibraryParams = params.copyAppendingExtraDeps(Iterables.concat(BuildRules.getExportedRules(Iterables.concat(params.getDeclaredDeps().get(), resolver.getAllRules(args.providedDeps))), scalac.getDeps(ruleFinder)));
return new DefaultJavaLibrary(javaLibraryParams, pathResolver, ruleFinder, args.srcs, validateResources(pathResolver, params.getProjectFilesystem(), args.resources), /* generatedSourceFolder */
Optional.empty(), /* proguardConfig */
Optional.empty(), /* postprocessClassesCommands */
ImmutableList.of(), params.getDeclaredDeps().get(), resolver.getAllRules(args.providedDeps), JavaLibraryRules.getAbiInputs(resolver, javaLibraryParams.getDeps()), /* trackClassUsage */
false, /* additionalClasspathEntries */
ImmutableSet.of(), new ScalacToJarStepFactory(scalac, scalaBuckConfig.getCompilerFlags(), args.extraArguments, resolver.getAllRules(scalaBuckConfig.getCompilerPlugins())), args.resourcesRoot, args.manifestFile, args.mavenCoords, args.tests, /* classesToRemoveFromJar */
ImmutableSet.of());
}
use of com.facebook.buck.rules.Tool in project buck by facebook.
the class PythonBinaryDescriptionTest method executableCommandWithPathToPexExecutor.
@Test
public void executableCommandWithPathToPexExecutor() throws Exception {
BuildTarget target = BuildTargetFactory.newInstance("//foo:bin");
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
final Path executor = Paths.get("executor");
PythonBuckConfig config = new PythonBuckConfig(FakeBuckConfig.builder().build(), new AlwaysFoundExecutableFinder()) {
@Override
public Optional<Tool> getPexExecutor(BuildRuleResolver resolver) {
return Optional.of(new HashedFileTool(executor));
}
};
PythonBinaryBuilder builder = new PythonBinaryBuilder(target, config, PythonTestUtils.PYTHON_PLATFORMS, CxxPlatformUtils.DEFAULT_PLATFORM, CxxPlatformUtils.DEFAULT_PLATFORMS);
PythonPackagedBinary binary = (PythonPackagedBinary) builder.setMainModule("main").build(resolver);
assertThat(binary.getExecutableCommand().getCommandPrefix(pathResolver), Matchers.contains(executor.toString(), pathResolver.getAbsolutePath(binary.getSourcePathToOutput()).toString()));
}
use of com.facebook.buck.rules.Tool in project buck by facebook.
the class PythonBinaryDescriptionTest method pexToolBuilderAddedToRuntimeDeps.
@Test
public void pexToolBuilderAddedToRuntimeDeps() throws Exception {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraphFactory.newInstance(), new DefaultTargetNodeToBuildRuleTransformer());
ShBinary pyTool = new ShBinaryBuilder(BuildTargetFactory.newInstance("//:py_tool")).setMain(new FakeSourcePath("run.sh")).build(resolver);
PythonBuckConfig config = new PythonBuckConfig(FakeBuckConfig.builder().build(), new AlwaysFoundExecutableFinder()) {
@Override
public Optional<Tool> getPexExecutor(BuildRuleResolver resolver) {
return Optional.of(pyTool.getExecutableCommand());
}
};
PythonBinary standaloneBinary = new PythonBinaryBuilder(BuildTargetFactory.newInstance("//:bin"), config, PythonTestUtils.PYTHON_PLATFORMS, CxxPlatformUtils.DEFAULT_PLATFORM, CxxPlatformUtils.DEFAULT_PLATFORMS).setMainModule("hello").setPackageStyle(PythonBuckConfig.PackageStyle.STANDALONE).build(resolver);
assertThat(standaloneBinary.getRuntimeDeps().collect(MoreCollectors.toImmutableSet()), Matchers.hasItem(pyTool.getBuildTarget()));
}
use of com.facebook.buck.rules.Tool in project buck by facebook.
the class RustTestDescription method createBuildRule.
@Override
public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph, BuildRuleParams params, BuildRuleResolver resolver, A args) throws NoSuchBuildTargetException {
BuildTarget exeTarget = params.getBuildTarget().withAppendedFlavors(InternalFlavor.of("unittest"));
BinaryWrapperRule testExeBuild = resolver.addToIndex(RustCompileUtils.createBinaryBuildRule(params.withBuildTarget(exeTarget), resolver, rustBuckConfig, cxxPlatforms, defaultCxxPlatform, args.crate, args.features, Stream.of(args.framework ? Stream.of("--test") : Stream.<String>empty(), rustBuckConfig.getRustTestFlags().stream(), args.rustcFlags.stream()).flatMap(x -> x).iterator(), args.linkerFlags.iterator(), RustCompileUtils.getLinkStyle(params.getBuildTarget(), args.linkStyle), args.rpath, args.srcs, args.crateRoot, ImmutableSet.of("lib.rs", "main.rs")));
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
Tool testExe = testExeBuild.getExecutableCommand();
BuildRuleParams testParams = params.copyAppendingExtraDeps(testExe.getDeps(ruleFinder));
return new RustTest(testParams, ruleFinder, testExeBuild, args.labels, args.contacts);
}
use of com.facebook.buck.rules.Tool in project buck by facebook.
the class AppleCxxPlatformsTest method appleCxxPlatformShouldUsePreferredSwiftVersion.
@Test
public void appleCxxPlatformShouldUsePreferredSwiftVersion() throws IOException {
AppleCxxPlatform platformWithConfiguredSwift = buildAppleCxxPlatformWithSwiftToolchain(false);
Optional<SwiftPlatform> swiftPlatformOptional = platformWithConfiguredSwift.getSwiftPlatform();
assertThat(swiftPlatformOptional.isPresent(), is(true));
Tool swiftTool = swiftPlatformOptional.get().getSwift();
assertThat(((VersionedTool) swiftTool).getPath(), not(equalTo(Paths.get("Toolchains/Swift_2.3.xctoolchain/usr/bin/swift"))));
assertThat(swiftPlatformOptional.get().getSwiftRuntimePaths(), equalTo(ImmutableSet.of(temp.getRoot().resolve("usr/lib/swift/iphoneos"))));
}
Aggregations