Builder class abstract interface

A builder to be run during a build hook.

Builders should be used to build native code, download assets, and transform assets. A build hook is only rerun when its declared BuildOutput.dependencies change. (Linkers have access to tree-shaking information in some build modes, and could potentially build or download less assets. However, due to the tree-shaking information being an input to link hooks, link hooks are re-run much more often.)

A package to be used in build hooks should implement this interface. The typical pattern of build hooks should be a declarative specification of one or more builders (constructor calls), followed by running these builders.

For example with a single builder from package:native_toolchain_c:

import 'package:logging/logging.dart';
import 'package:native_assets_cli/native_assets_cli.dart';
import 'package:native_toolchain_c/native_toolchain_c.dart';

void main(List<String> args) async {
  await build(args, (input, output) async {
    final packageName = input.packageName;
    final cbuilder = CBuilder.library(
      name: packageName,
      assetName: '$packageName.dart',
      sources: [
        'src/$packageName.c',
      ],
    );
    await cbuilder.run(
      buildInput: input,
      buildOutput: output,
      logger: Logger('')
        ..level = Level.ALL
        ..onRecord.listen((record) => print(record.message)),
    );
  });
}

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run({required BuildInput input, required BuildOutputBuilder output, required Logger? logger}) Future<void>
Runs this build.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited