native_prebuilt 0.0.5
native_prebuilt: ^0.0.5 copied to clipboard
Reusable infrastructure for Dart packages that ship prebuilt native libraries from GitHub or GitLab releases. Provides build-hook integration, manifest generation, download/verify/cache pipelines, and [...]
native_prebuilt #
Reusable infrastructure for Dart packages that ship prebuilt native libraries from GitHub or GitLab releases.
What it provides #
PrebuiltCodeAssetBuilderforhook/build.dartPrebuiltManifest/PrebuiltArtifactimmutable release metadataArtifactInstallerfor download → verify → extract → validate → cachePrebuiltResolverchain for override / local / cached / downloaded prebuiltsNativeBinaryInspectorand library-name helpers- CLI tooling for manifest generation, fetch, verification, and workflow templates
- Reusable GitHub Actions workflow templates
Install #
dependencies:
native_prebuilt: ^0.0.5
Hook usage #
import 'package:hooks/hooks.dart';
import 'package:native_prebuilt/hooks.dart';
import 'package:my_package/src/hook/prebuilts.g.dart';
void main(List<String> args) async {
await build(args, (input, output) async {
await PrebuiltCodeAssetBuilder(
assetName: 'my_bindings.dart',
libraryStem: 'mylib',
manifest: myPrebuilts,
linkModeResolver: (_) => DynamicLoadingBundled(),
fallback: CallbackBuilder((input, output) async {
// build from source
}),
).run(input: input, output: output, logger: null);
});
}
Manifest format #
native_prebuilt expects a YAML config file like:
schema: 1
package: my_package
asset_name: my_bindings.dart
library_stem: mylib
release:
provider: github
repository: myorg/myrepo
tag: mylib-v1.0.0
artifacts:
linux-x64:
archive: mylib-linux-x64.tar.gz
payload:
type: dynamic_library
Use:
dart run native_prebuilt manifest update --config native_prebuilt.yaml --output lib/src/hook/prebuilts.g.dart
dart run native_prebuilt manifest verify --config native_prebuilt.yaml --output lib/src/hook/prebuilts.g.dart
Fetch locally #
dart run native_prebuilt fetch --config native_prebuilt.yaml --platform linux-x64
Workflow templates #
GitHub Actions:
dart run native_prebuilt workflow init
GitLab CI (Dart Docker image + dart test / native toolchain bootstrap):
dart run native_prebuilt workflow init --gitlab
Notes #
hooks.user_definesis preferred for local override paths.- Use
release.provider: gitlabandrelease.projectfor GitLab release assets. - The package exports
OS,Architecture, andIOSSdkfromcode_assets. - The cache and installer are designed for repeated hook runs and concurrent builds.