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:
hook/build.dartvia buildhook/link.dartvia linktool/precompile_binaries.dartvia buildStandalone
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.recordedUsesisnullor when filtering COFF archive symbols).final - assetName → String
-
The
@Nativeasset ID suffix (e.g.'boring.dart'or'src/bindings/lib.g.dart').final - buildFromSource → SourceBuildCallback?
-
Callback to compile the native library from source when
buildModeisbuild/checkoutor whenfetchfalls back to building from source.final - envVarPrefix → String?
-
Optional environment variable prefix (e.g.
'SIGSTORE') for overridingbuildMode,localPath, andcheckoutPath.final - fallbackToBuildOnFetchFailure → bool
-
Whether
fetchmode 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.dylibFileNameandCLinker.library(e.g.'bssl_dart','icu4x','sigstore_dart').final - optimizationLevel → OptimizationLevel
-
Optimization level passed to
CLinker.libraryin link.final - packageName → String?
-
Optional package name override. Defaults to
input.packageName.final - prebuiltDirectory → String?
-
Optional directory relative to
input.packageRootcontaining pub-bundled prebuilt binaries (e.g.'prebuilt', followingprebuilt_assets_exampleinpackage: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
buildModevalues inhooks.user_definesshould throw aBuildErrorinstead 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? checkoutPath, int androidTargetNdkApi = 28, int iOSTargetVersion = 13, int macOSTargetVersion = 13}) → Future< Uri> -
Synthesizes a
BuildInputviaBuildInputBuilder(following thedownload_asset/tool/build.dartpattern inpackage:hooks) and invokes buildFromSource for standalone precompilation in CI scripts. -
link(
{required LinkInput input, required LinkOutputBuilder output, Logger? logger}) → Future< void> -
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 ininput.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