@Override
  public Iterable<BuildTarget> findDepsForTargetFromConstructorArgs(
      BuildTarget buildTarget, CellPathResolver cellRoots, Arg constructorArg) {
    ImmutableSet.Builder<BuildTarget> deps = ImmutableSet.builder();

    // Get any parse time deps from the C/C++ platforms.
    deps.addAll(CxxPlatforms.getParseTimeDeps(cxxPlatforms.getValues()));

    for (PythonPlatform pythonPlatform : pythonPlatforms.getValues()) {
      deps.addAll(pythonPlatform.getCxxLibrary().asSet());
    }

    return deps.build();
  }
Ejemplo n.º 2
0
 private PythonPlatform getPythonPlatform(
     ProcessExecutor processExecutor,
     Flavor flavor,
     Optional<String> interpreter,
     Optional<BuildTarget> library)
     throws InterruptedException {
   return PythonPlatform.of(flavor, getPythonEnvironment(processExecutor, interpreter), library);
 }
 private <A extends Arg> BuildRule createExtensionBuildRule(
     BuildRuleParams params,
     BuildRuleResolver ruleResolver,
     PythonPlatform pythonPlatform,
     CxxPlatform cxxPlatform,
     A args)
     throws NoSuchBuildTargetException {
   SourcePathResolver pathResolver = new SourcePathResolver(ruleResolver);
   String extensionName = getExtensionName(params.getBuildTarget());
   Path extensionPath =
       getExtensionPath(
           params.getProjectFilesystem(),
           params.getBuildTarget(),
           pythonPlatform.getFlavor(),
           cxxPlatform.getFlavor());
   return CxxLinkableEnhancer.createCxxLinkableBuildRule(
       cxxBuckConfig,
       cxxPlatform,
       params,
       ruleResolver,
       pathResolver,
       getExtensionTarget(
           params.getBuildTarget(), pythonPlatform.getFlavor(), cxxPlatform.getFlavor()),
       Linker.LinkType.SHARED,
       Optional.of(extensionName),
       extensionPath,
       Linker.LinkableDepType.SHARED,
       FluentIterable.from(params.getDeps()).filter(NativeLinkable.class),
       args.cxxRuntimeType,
       Optional.<SourcePath>absent(),
       ImmutableSet.<BuildTarget>of(),
       NativeLinkableInput.builder()
           .setArgs(getExtensionArgs(params, ruleResolver, pathResolver, cxxPlatform, args))
           .setFrameworks(args.frameworks.or(ImmutableSortedSet.<FrameworkPath>of()))
           .setLibraries(args.libraries.or(ImmutableSortedSet.<FrameworkPath>of()))
           .build());
 }
  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();
  }