native_prebuilt 0.0.10
native_prebuilt: ^0.0.10 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.10
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 \
--built-library-dir built-library
dart run native_prebuilt manifest verify \
--config native_prebuilt.yaml \
--output lib/src/hook/prebuilts.g.dart \
--built-library-dir built-library
Fetch locally #
dart run native_prebuilt fetch --config native_prebuilt.yaml --platform linux-x64
Workflow templates #
GitHub Actions:
dart run native_prebuilt workflow init
This now also writes a repo-level prebuilt.yml workflow alongside the reusable workflow templates, and tag runs publish GitHub release assets.
GitLab CI generated from the same command now uploads GitLab release assets too.
GitLab CI (defaults to the platforms declared in native_prebuilt.yaml):
dart run native_prebuilt workflow init --gitlab --config native_prebuilt.yaml
Notes #
hooks.user_definesis preferred for local override paths.- Use
release.provider: gitlabandrelease.projectfor GitLab release assets. workflow init --platform ...is repeatable; omit it to scaffold the platforms declared in the manifest.- Generated GitLab scaffolds stage built libraries in
built-library/and use the manifest to decide which platform jobs to emit. - The package exports
OS,Architecture, andIOSSdkfromcode_assets. - The cache and installer are designed for repeated hook runs and concurrent builds.