use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.
the class WorkspaceAndProjectGeneratorTest method buildWithBuckFocused.
@Test
public void buildWithBuckFocused() throws IOException, InterruptedException {
final String fooLib = "//foo:lib";
Optional<Path> buck = new ExecutableFinder().getOptionalExecutable(Paths.get("buck"), ImmutableMap.of());
assumeThat(buck.isPresent(), is(true));
WorkspaceAndProjectGenerator generator = new WorkspaceAndProjectGenerator(rootCell, targetGraph, workspaceNode.getConstructorArg(), workspaceNode.getBuildTarget(), ImmutableSet.of(ProjectGenerator.Option.INCLUDE_TESTS, ProjectGenerator.Option.INCLUDE_DEPENDENCIES_TESTS), false, /* combinedProject */
true, /* buildWithBuck */
ImmutableList.of(), Optional.of(ImmutableSet.of(BuildTargetFactory.newInstance(fooLib).getUnflavoredBuildTarget())), false, /* parallelizeBuild */
new AlwaysFoundExecutableFinder(), ImmutableMap.of(), PLATFORMS, DEFAULT_PLATFORM, "BUCK", getBuildRuleResolverForNodeFunction(targetGraph), getFakeBuckEventBus(), halideBuckConfig, cxxBuckConfig, appleConfig, swiftBuckConfig);
Map<Path, ProjectGenerator> projectGenerators = new HashMap<>();
generator.generateWorkspaceAndDependentProjects(projectGenerators, MoreExecutors.newDirectExecutorService());
ProjectGenerator fooProjectGenerator = projectGenerators.get(Paths.get("foo"));
assertThat(fooProjectGenerator, is(notNullValue()));
for (PBXTarget target : fooProjectGenerator.getGeneratedProject().getTargets()) {
if (target.getName() != null && !target.getName().equals(fooLib) && !target.getName().endsWith("-Buck")) {
// all non-lib and non-Buck targets should have 0 steps as they are not in focus
// (focus on .*lib.* only)
assertThat(target.getBuildPhases().size(), Matchers.equalTo(0));
}
}
}
use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.
the class PythonBinaryDescriptionTest method transitiveNativeDepsUsingMergedNativeLinkStrategy.
@Test
public void transitiveNativeDepsUsingMergedNativeLinkStrategy() throws Exception {
CxxLibraryBuilder transitiveCxxDepBuilder = new CxxLibraryBuilder(BuildTargetFactory.newInstance("//:transitive_dep")).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("transitive_dep.c"))));
CxxLibraryBuilder cxxDepBuilder = new CxxLibraryBuilder(BuildTargetFactory.newInstance("//:dep")).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("dep.c")))).setDeps(ImmutableSortedSet.of(transitiveCxxDepBuilder.getTarget()));
CxxLibraryBuilder cxxBuilder = new CxxLibraryBuilder(BuildTargetFactory.newInstance("//:cxx")).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("cxx.c")))).setDeps(ImmutableSortedSet.of(cxxDepBuilder.getTarget()));
PythonBuckConfig config = new PythonBuckConfig(FakeBuckConfig.builder().build(), new AlwaysFoundExecutableFinder()) {
@Override
public NativeLinkStrategy getNativeLinkStrategy() {
return NativeLinkStrategy.MERGED;
}
};
PythonBinaryBuilder binaryBuilder = new PythonBinaryBuilder(BuildTargetFactory.newInstance("//:bin"), config, PythonTestUtils.PYTHON_PLATFORMS, CxxPlatformUtils.DEFAULT_PLATFORM, CxxPlatformUtils.DEFAULT_PLATFORMS);
binaryBuilder.setMainModule("main");
binaryBuilder.setDeps(ImmutableSortedSet.of(cxxBuilder.getTarget()));
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraphFactory.newInstance(transitiveCxxDepBuilder.build(), cxxDepBuilder.build(), cxxBuilder.build(), binaryBuilder.build()), new DefaultTargetNodeToBuildRuleTransformer());
transitiveCxxDepBuilder.build(resolver);
cxxDepBuilder.build(resolver);
cxxBuilder.build(resolver);
PythonBinary binary = binaryBuilder.build(resolver);
assertThat(Iterables.transform(binary.getComponents().getNativeLibraries().keySet(), Object::toString), Matchers.containsInAnyOrder("libomnibus.so", "libcxx.so"));
}
use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.
the class NdkCxxPlatformTest method checkRootAndPlatformDoNotAffectRuleKeys.
// The important aspects we check for in rule keys is that the host platform and the path
// to the NDK don't cause changes.
@Test
public void checkRootAndPlatformDoNotAffectRuleKeys() throws Exception {
ProjectFilesystem filesystem = new ProjectFilesystem(tmp.getRoot());
// Test all major compiler and runtime combinations.
ImmutableList<Pair<NdkCxxPlatformCompiler.Type, NdkCxxPlatforms.CxxRuntime>> configs = ImmutableList.of(new Pair<>(NdkCxxPlatformCompiler.Type.GCC, NdkCxxPlatforms.CxxRuntime.GNUSTL), new Pair<>(NdkCxxPlatformCompiler.Type.CLANG, NdkCxxPlatforms.CxxRuntime.GNUSTL), new Pair<>(NdkCxxPlatformCompiler.Type.CLANG, NdkCxxPlatforms.CxxRuntime.LIBCXX));
for (Pair<NdkCxxPlatformCompiler.Type, NdkCxxPlatforms.CxxRuntime> config : configs) {
Map<String, ImmutableMap<NdkCxxPlatforms.TargetCpuType, RuleKey>> preprocessAndCompileRukeKeys = Maps.newHashMap();
Map<String, ImmutableMap<NdkCxxPlatforms.TargetCpuType, RuleKey>> compileRukeKeys = Maps.newHashMap();
Map<String, ImmutableMap<NdkCxxPlatforms.TargetCpuType, RuleKey>> linkRukeKeys = Maps.newHashMap();
// directories.
for (String dir : ImmutableList.of("android-ndk-r9c", "android-ndk-r10b")) {
for (Platform platform : ImmutableList.of(Platform.LINUX, Platform.MACOS, Platform.WINDOWS)) {
Path root = tmp.newFolder(dir);
MoreFiles.writeLinesToFile(ImmutableList.of("r9c"), root.resolve("RELEASE.TXT"));
ImmutableMap<NdkCxxPlatforms.TargetCpuType, NdkCxxPlatform> platforms = NdkCxxPlatforms.getPlatforms(CxxPlatformUtils.DEFAULT_CONFIG, filesystem, root, NdkCxxPlatformCompiler.builder().setType(config.getFirst()).setVersion("gcc-version").setGccVersion("clang-version").build(), NdkCxxPlatforms.CxxRuntime.GNUSTL, "target-app-platform", ImmutableSet.of("x86"), platform, new AlwaysFoundExecutableFinder(), /* strictToolchainPaths */
false);
preprocessAndCompileRukeKeys.put(String.format("NdkCxxPlatform(%s, %s)", dir, platform), constructCompileRuleKeys(Operation.PREPROCESS_AND_COMPILE, platforms));
compileRukeKeys.put(String.format("NdkCxxPlatform(%s, %s)", dir, platform), constructCompileRuleKeys(Operation.COMPILE, platforms));
linkRukeKeys.put(String.format("NdkCxxPlatform(%s, %s)", dir, platform), constructLinkRuleKeys(platforms));
MoreFiles.deleteRecursively(root);
}
}
// If everything worked, we should be able to collapse all the generated rule keys down
// to a singleton set.
assertThat(Arrays.toString(preprocessAndCompileRukeKeys.entrySet().toArray()), Sets.newHashSet(preprocessAndCompileRukeKeys.values()), Matchers.hasSize(1));
assertThat(Arrays.toString(compileRukeKeys.entrySet().toArray()), Sets.newHashSet(compileRukeKeys.values()), Matchers.hasSize(1));
assertThat(Arrays.toString(linkRukeKeys.entrySet().toArray()), Sets.newHashSet(linkRukeKeys.values()), Matchers.hasSize(1));
}
}
use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.
the class NdkCxxPlatformTest method headerVerificationWhitelistsNdkRoot.
@Test
public void headerVerificationWhitelistsNdkRoot() throws IOException {
ProjectFilesystem filesystem = new ProjectFilesystem(tmp.getRoot());
String dir = "android-ndk-r9c";
Path root = tmp.newFolder(dir);
MoreFiles.writeLinesToFile(ImmutableList.of("r9c"), root.resolve("RELEASE.TXT"));
ImmutableMap<NdkCxxPlatforms.TargetCpuType, NdkCxxPlatform> platforms = NdkCxxPlatforms.getPlatforms(CxxPlatformUtils.DEFAULT_CONFIG, filesystem, root, NdkCxxPlatformCompiler.builder().setType(NdkCxxPlatformCompiler.Type.GCC).setVersion("gcc-version").setGccVersion("clang-version").build(), NdkCxxPlatforms.CxxRuntime.GNUSTL, "target-app-platform", ImmutableSet.of("x86"), Platform.LINUX, new AlwaysFoundExecutableFinder(), /* strictToolchainPaths */
false);
for (NdkCxxPlatform ndkCxxPlatform : platforms.values()) {
assertTrue(ndkCxxPlatform.getCxxPlatform().getHeaderVerification().isWhitelisted(root.resolve("test.h").toString()));
}
}
use of com.facebook.buck.io.AlwaysFoundExecutableFinder in project buck by facebook.
the class PythonBuckConfigTest method testPexArgs.
@Test
public void testPexArgs() throws Exception {
PythonBuckConfig config = new PythonBuckConfig(FakeBuckConfig.builder().setSections(ImmutableMap.of("python", ImmutableMap.of("pex_flags", "--hello --world"))).build(), new AlwaysFoundExecutableFinder());
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
assertThat(config.getPexTool(resolver).getCommandPrefix(new SourcePathResolver(new SourcePathRuleFinder(resolver))), hasConsecutiveItems("--hello", "--world"));
}
Aggregations