runPostProcessBuilder function

Future<void> runPostProcessBuilder(
  1. PostProcessBuilder builder,
  2. AssetId inputId,
  3. AssetReader reader,
  4. AssetWriter writer,
  5. Logger logger, {
  6. required void addAsset(
    1. AssetId
    ),
  7. required void deleteAsset(
    1. AssetId
    ),
})

Run builder with inputId as the primary input.

addAsset should update the build systems knowledge of what assets exist. If an asset should not be written this function should throw. deleteAsset should remove the asset from the build system, it will not be deleted on disk since the writer has no mechanism for delete.

Implementation

Future<void> runPostProcessBuilder(PostProcessBuilder builder, AssetId inputId,
    AssetReader reader, AssetWriter writer, Logger logger,
    {required void Function(AssetId) addAsset,
    required void Function(AssetId) deleteAsset}) async {
  await scopeLogAsync(() async {
    var buildStep =
        postProcessBuildStep(inputId, reader, writer, addAsset, deleteAsset);
    try {
      await builder.build(buildStep);
    } finally {
      await buildStep.complete();
    }
  }, logger);
}