private ImmutableList<BuildRule> getPlatformDeps(
      BuildRuleParams params,
      BuildRuleResolver ruleResolver,
      PythonPlatform pythonPlatform,
      Arg args) {

    ImmutableList.Builder<BuildRule> rules = ImmutableList.builder();

    // Add declared deps.
    rules.addAll(params.getDeclaredDeps().get());

    // Add platform specific deps.
    rules.addAll(
        ruleResolver.getAllRules(
            Iterables.concat(
                args.platformDeps
                    .or(PatternMatchedCollection.<ImmutableSortedSet<BuildTarget>>of())
                    .getMatchingValues(pythonPlatform.getFlavor().toString()))));

    // Add a dep on the python C/C++ library.
    rules.add(ruleResolver.getRule(pythonPlatform.getCxxLibrary().get().getBuildTarget()));

    return rules.build();
  }
 @Test
 public void platformSrcs() throws Exception {
   BuildTarget target = BuildTargetFactory.newInstance("//foo:lib");
   SourcePath matchedSource = new FakeSourcePath("foo/a.py");
   SourcePath unmatchedSource = new FakeSourcePath("foo/b.py");
   PythonLibrary library =
       (PythonLibrary)
           new PythonLibraryBuilder(target)
               .setPlatformSrcs(
                   PatternMatchedCollection.<SourceList>builder()
                       .add(
                           Pattern.compile(PythonTestUtils.PYTHON_PLATFORM.getFlavor().toString()),
                           SourceList.ofUnnamedSources(ImmutableSortedSet.of(matchedSource)))
                       .add(
                           Pattern.compile("won't match anything"),
                           SourceList.ofUnnamedSources(ImmutableSortedSet.of(unmatchedSource)))
                       .build())
               .build(
                   new BuildRuleResolver(
                       TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()));
   assertThat(
       library.getSrcs(PythonTestUtils.PYTHON_PLATFORM).values(),
       Matchers.contains(matchedSource));
 }