#!/usr/bin/env dart
// Generated by alef. Do not edit by hand.
// Download platform-specific native library for {{ crate_name }} from GitHub releases
// into the versioned user cache (see `native_loader.dart`).
import 'dart:io';
import '../lib/src/native_loader.dart';
void main() async {
try {
await _run();
} catch (e) {
stderr.writeln('Error: $e');
exit(1);
}
}
Future<void> _run() async {
// Dev/test override: when the env var points at a directory, assume the
// native library is already present there and skip the network entirely.
final envDir = Platform.environment[nativeLibDirEnv];
if (envDir != null && envDir.isNotEmpty) {
stdout.writeln(
'Using $nativeLibDirEnv=$envDir; skipping download for $nativeAssetPrefix.',
);
return;
}
final cached = nativeCachedLibPath();
if (cached != null && File(cached).existsSync()) {
stdout.writeln('Native library already cached at $cached.');
return;
}
final libPath = await nativeDownloadAndCacheLibrary();
stdout.writeln('Downloaded native library to $libPath.');
}