@VisibleForTesting
  public CxxPreprocessAndCompile createPreprocessBuildRule(String name, CxxSource source) {

    Preconditions.checkArgument(CxxSourceTypes.isPreprocessableType(source.getType()));

    BuildTarget target = createPreprocessBuildTarget(name, source.getType());
    PreprocessorDelegate preprocessorDelegate =
        preprocessorDelegates.getUnchecked(
            PreprocessAndCompilePreprocessorDelegateKey.of(source.getType(), source.getFlags()));

    // Build the CxxCompile rule and add it to our sorted set of build rules.
    CxxPreprocessAndCompile result =
        CxxPreprocessAndCompile.preprocess(
            getParams()
                .copyWithChanges(
                    target,
                    new DepsBuilder()
                        .addPreprocessDeps()
                        .add(preprocessorDelegate.getPreprocessor())
                        .add(source),
                    Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>of())),
            getPathResolver(),
            preprocessorDelegate,
            new CompilerDelegate(
                getPathResolver(),
                getCxxPlatform().getDebugPathSanitizer(),
                getCompiler(source.getType()),
                computeCompilerFlags(source.getType(), source.getFlags())),
            getPreprocessOutputPath(target, source.getType(), name),
            source.getPath(),
            source.getType(),
            getCxxPlatform().getDebugPathSanitizer());
    getResolver().addToIndex(result);
    return result;
  }