use of com.facebook.buck.util.environment.Platform 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));
}
}
Aggregations