native_prebuilt 0.0.12
native_prebuilt: ^0.0.12 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 and pub.dev workflow templates
Install #
dependencies:
native_prebuilt: ^0.0.11
Hook usage #
import 'package:hooks/hooks.dart';
import 'package:native_prebuilt/hooks.dart';
import 'package:my_package/src/hook/my_package_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/my_package_prebuilts.g.dart \
--built-library-dir built-library \
--release-assets-dir release-assets \
dart run native_prebuilt manifest verify \
--config native_prebuilt.yaml \
--output lib/src/hook/my_package_prebuilts.g.dart \
--built-library-dir built-library \
--release-assets-dir release-assets
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 writes a repo-level prebuilt.yml workflow, a publish.yml pub.dev workflow,
and the reusable workflow templates. The generated tag trigger is package-specific
(e.g. my_package-v*) and tag runs publish GitHub release assets.
GitLab CI generated from the same command uploads GitLab release assets too:
dart run native_prebuilt workflow init --gitlab --config native_prebuilt.yaml
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 GitHub workflows derive filenames and tag prefixes from
package:innative_prebuilt.yaml. - 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.