use of com.facebook.buck.rules.args.FileListableLinkerInputArg in project buck by facebook.
the class SwiftLibraryIntegrationTest method testSwiftCompileAndLinkArgs.
@Test
public void testSwiftCompileAndLinkArgs() throws NoSuchBuildTargetException {
BuildTarget buildTarget = BuildTargetFactory.newInstance("//foo:bar#iphoneos-x86_64");
BuildTarget swiftCompileTarget = buildTarget.withAppendedFlavors(SwiftLibraryDescription.SWIFT_COMPILE_FLAVOR);
BuildRuleParams params = new FakeBuildRuleParamsBuilder(swiftCompileTarget).build();
SwiftLibraryDescription.Arg args = createDummySwiftArg();
SwiftCompile buildRule = (SwiftCompile) FakeAppleRuleDescriptions.SWIFT_LIBRARY_DESCRIPTION.createBuildRule(TargetGraph.EMPTY, params, resolver, args);
resolver.addToIndex(buildRule);
ImmutableList<Arg> astArgs = buildRule.getAstLinkArgs();
assertThat(astArgs, Matchers.hasSize(3));
assertThat(astArgs.get(0), Matchers.equalTo(StringArg.of("-Xlinker")));
assertThat(astArgs.get(1), Matchers.equalTo(StringArg.of("-add_ast_path")));
assertThat(astArgs.get(2), Matchers.instanceOf(SourcePathArg.class));
SourcePathArg sourcePathArg = (SourcePathArg) astArgs.get(2);
assertThat(sourcePathArg.getPath(), Matchers.equalTo(new ExplicitBuildTargetSourcePath(swiftCompileTarget, pathResolver.getRelativePath(buildRule.getSourcePathToOutput()).resolve("bar.swiftmodule"))));
Arg objArg = buildRule.getFileListLinkArg();
assertThat(objArg, Matchers.instanceOf(FileListableLinkerInputArg.class));
FileListableLinkerInputArg fileListArg = (FileListableLinkerInputArg) objArg;
ExplicitBuildTargetSourcePath fileListSourcePath = new ExplicitBuildTargetSourcePath(swiftCompileTarget, pathResolver.getRelativePath(buildRule.getSourcePathToOutput()).resolve("bar.o"));
assertThat(fileListArg.getPath(), Matchers.equalTo(fileListSourcePath));
BuildTarget linkTarget = buildTarget.withAppendedFlavors(CxxDescriptionEnhancer.SHARED_FLAVOR);
CxxLink linkRule = (CxxLink) FakeAppleRuleDescriptions.SWIFT_LIBRARY_DESCRIPTION.createBuildRule(TargetGraphFactory.newInstance(FakeTargetNodeBuilder.build(buildRule)), params.withBuildTarget(linkTarget), resolver, args);
assertThat(linkRule.getArgs(), Matchers.hasItem(objArg));
assertThat(linkRule.getArgs(), Matchers.not(Matchers.hasItem(SourcePathArg.of(fileListSourcePath))));
}
Aggregations