PrebuiltLibrary class

Declarative specification for building, fetching, and tree-shaking a native library across hook/build.dart, hook/link.dart, and standalone maintainer scripts.

Modeled after CLibrary in package:native_toolchain_c, a single PrebuiltLibrary instance can be defined in lib/src/hook_helpers/ and invoked from:

Constructors

PrebuiltLibrary({required String name, String? packageName, required String assetName, PrebuiltReleaseConfig? releaseConfig, String? prebuiltDirectory, SourceBuildCallback? buildFromSource, bool fallbackToBuildOnFetchFailure = true, String? envVarPrefix, bool strictBuildOptions = false, SymbolsResolver? usedSymbols, Iterable<String>? allKnownSymbols, List<String> libraries(OS targetOS)?, List<String> frameworks = const [], OptimizationLevel optimizationLevel = OptimizationLevel.o3})
const

Properties

allKnownSymbols → Iterable<String>?
Optional set of all bound symbol names (used on Windows when LinkInput.recordedUses is null or when filtering COFF archive symbols).
final
assetName → String
The @Native asset ID suffix (e.g. 'boring.dart' or 'src/bindings/lib.g.dart').
final
buildFromSource → SourceBuildCallback?
Callback to compile the native library from source when buildMode is build/checkout or when fetch falls back to building from source.
final
envVarPrefix → String?
Optional environment variable prefix (e.g. 'SIGSTORE') for overriding buildMode, localPath, and checkoutPath.
final
fallbackToBuildOnFetchFailure → bool
Whether fetch mode should fall back to buildFromSource if no hash is registered for the target or if downloading fails.
final
frameworks → List<String>
Frameworks to link against in link (defaults to const []).
final
hashCode → int
The hash code for this object.
no setterinherited
libraries → List<String> Function(OS targetOS)?
Optional callback returning system libraries to link against in link for a given target OS.
final
name → String
The library stem name passed to OS.dylibFileName and CLinker.library (e.g. 'bssl_dart', 'icu4x', 'sigstore_dart').
final
optimizationLevel → OptimizationLevel
Optimization level passed to CLinker.library in link.
final
packageName → String?
Optional package name override. Defaults to input.packageName.
final
prebuiltDirectory → String?
Optional directory relative to input.packageRoot containing pub-bundled prebuilt binaries (e.g. 'prebuilt', following prebuilt_assets_example in package:hooks).
final
releaseConfig → PrebuiltReleaseConfig?
Configuration for fetching and verifying prebuilt release binaries.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
strictBuildOptions → bool
Whether unrecognized buildMode values in hooks.user_defines should throw a BuildError instead of defaulting to BuildMode.fetch.
final
usedSymbols → SymbolsResolver?
Extracts the native symbols used by the application from LinkInput.recordedUses.
final

Methods

build({required BuildInput input, required BuildOutputBuilder output, List<Uri> additionalDependencies = const []}) → Future<void>
Runs the build hook (hook/build.dart) for this library.
buildStandalone({required OS targetOS, required Architecture targetArchitecture, required bool static, IOSSdk? iOSSdk, Uri? packageRoot, Uri? outputDirectory, Uri? outputDirectoryShared, Uri? checkoutPath, int androidTargetNdkApi = 28, int iOSTargetVersion = 13, int macOSTargetVersion = 13}) → Future<Uri>
Synthesizes a BuildInput via BuildInputBuilder (following the download_asset/tool/build.dart pattern in package:hooks) and invokes buildFromSource for standalone precompilation in CI scripts.
Runs the link hook (hook/link.dart) to link and tree-shake the static library emitted by build into a dynamic library containing only the functions referenced in input.recordedUses.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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