dart_bclibc 0.2.0
dart_bclibc: ^0.2.0 copied to clipboard
Dart FFI bindings for the bclibc ballistics engine.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Unreleased #
0.2.0-beta.1 - 2026-07-22 #
Changed #
- Breaking: split the package.
dart_bclibcis now pure Dart — nopackage:flutterdependency, installable from plain Dart (non-Flutter) projects. Everything Flutter-specific (native platform bundling for Android/iOS/Linux/macOS/Windows, Web/WebAssembly support, andAsyncCalculator, which needs a real web implementation) moved to the newdart_bclibc_flutterpackage.dart_bclibcitself now only exposes the synchronousCalculator/BcLibC(native FFI); wrapCalculatorin your ownIsolate.runfor off-isolate execution in a plain Dart project. dart run dart_bclibc:build_nativenow copies the built native library into the package's ownlib/native/<platform>/directory (resolved via apackage:URI at load time) instead of abuild/bclibc/directory relative to the caller's working directory — more robust across different invocation locations, and independent of cwd.BcLibC.open()'s native-library loader was rewritten with a clearer, more robust multi-strategy resolution order (env var →package:URI → platform-specific fallback → executable-relative), and now has a real iOS code path — previously_openLibrary()threwUnsupportedErrorunconditionally on iOS.
Migration #
- Flutter apps: depend on
dart_bclibc_flutterinstead ofdart_bclibcdirectly (it re-exports everything from this package, plusAsyncCalculatorand web support). - Plain Dart apps: no changes needed beyond dropping any direct use of
AsyncCalculator.
0.1.2-beta.2 - 2026-07-22 #
Added #
web:entry (pluginClass: BclibcWebPlugin) inpubspec.yaml'sflutter.plugin.platforms, backed by a newlib/src/bclibc_web_plugin.dart. The registrant is a no-op —AsyncCalculatornever goes through platform channels on web, it calls the wasm engine directly viadart:js_interop— but Flutter's tooling requires a realpluginClassfor any platform listed underflutter.plugin.platforms, and pub.dev only lists a plugin's supported platforms from that map. Without this entry, Web support existed in practice but wasn't shown on pub.dev.- CI:
release.ymlnow runs the web/Chrome test suite (mirroringci.yml'stest-webjob) as a required check before a release can be prepared.
Changed #
- New
flutter_web_pluginsdependency (Flutter SDK package), required for theRegistrartype the no-op web registrant'sregisterWithaccepts.
0.1.2-beta.1 - 2026-07-22 #
Added #
AsyncCalculator:Future-based counterpart toCalculatorwith the same three methods (barrelElevationForTarget,setWeaponZero,fire). On native, each call runs on a fresh isolate viaIsolate.runso heavy trajectory integration doesn't block the caller's isolate (e.g. the UI isolate in a Flutter app). On web it awaits the (cached) wasm engine load once, then calls straight through — no isolate involved.- Web/wasm support:
bclibc's C ABI (bclibc_ffi.h) can now be compiled to WebAssembly (seebclibc/build_wasm.sh) and consumed viadart:js_interopthroughBcLibCWeb(lib/ffi/bclibc_ffi_web.dart) — no Embind, no third-party FFI-on-web shim; it talks to the same flatBCLIBCFFI_*exports the nativedart:ffibinding uses. Struct field offsets aren't hardcoded on the Dart side:BCLIBCFFI_get_layout()computes them viaoffsetof()/sizeof()in whichever compiler built the wasm module, so the binding can't silently drift from the C struct layout.- The compiled wasm artifact (
assets/wasm/bclibc_ffi.js+.wasm) is now bundled with the package viaflutter.assetsinpubspec.yaml, soflutter build webpicks it up automatically. package:dart_bclibc/bclibc.dartconditionally excludes the native-onlyCalculator/BcLibC/ generateddart:ffibindings when compiling for web (if (dart.library.js_interop)), so importing the package barrel compiles cleanly on both platforms — web consumers useAsyncCalculator.- New
test/web/suite (dart test -p chrome) verifies numeric parity between the wasm and native engines.
- The compiled wasm artifact (
Changed #
- Internals reorganized so native and web share one conversion-logic code
path (
lib/src/calculator_core.dart,lib/ffi/bclibc_types.dart,BcEngineinterface) instead of duplicating it — no public API changes on native;Calculator's constructor and methods are unchanged. - Pin
bclibctov1.1.6— addsbuild_wasm.shandBCLIBCFFI_get_layout()upstream, which this release's web/wasm support builds on.
0.1.0 - 2026-07-03 #
First stable release. No functional changes since 0.1.0-beta.5 — the API, build system, and platform support are unchanged; this release marks the package as stable for pub.dev.
0.1.0-beta.5 - 2026-07-02 #
Fixed #
linux/CMakeLists.txt: beta.4 usedinstall(FILES "$<TARGET_LINKER_FILE:bclibc_ffi>"), which copies the.sonamelink itself (not its target) in cmake < 3.21 — producing a broken symlink in the Flutter bundle (libbclibc_ffi.so → libbclibc_ffi.so.0) with no real library present, causingDynamicLibrary.open()to fail at runtime. Fixed by switching toinstall(TARGETS bclibc_ffi LIBRARY DESTINATION lib), which installs the real versioned file together with its soname and namelink symlinks into the same directory — matching the standard Linux shared library layout and keeping the symlink chain valid.windows/CMakeLists.txt: beta.4 added a redundantinstall(FILES bclibc_ffi.dll DESTINATION .)that doubled up with the standardPLUGIN_BUNDLED_LIBRARIESinstall loop already present in every Flutter app'swindows/CMakeLists.txt. Removed the explicitinstall()call; the DLL is now delivered exclusively viadart_bclibc_bundled_libraries → PLUGIN_BUNDLED_LIBRARIES, matching the behaviour of the previousbclibc_ffilocal package.
0.1.0-beta.4 - 2026-07-02 #
Changed #
linux/CMakeLists.txtandwindows/CMakeLists.txtnow register their own CMakeinstall()rules forbclibc_ffi, so consuming Flutter apps no longer need to add manualinstall(TARGETS bclibc_ffi …)blocks to their platformCMakeLists.txt. On Windows,add_dependencies(flutter_assemble bclibc_ffi)is also registered automatically, preserving the correct build order in Visual Studio. Android is unaffected — the Gradle/AGP native build collects shared library targets from the CMake project withoutinstall().
0.1.0-beta.3 - 2026-07-01 #
Fixed #
bin/build_native.dartresolved its own package root viaPlatform.script, which points at a cached kernel snapshot in the caller's.dart_tool/pub/bin/— not this file's real location in pub-cache — when invoked asdart run dart_bclibc:build_nativefrom a consuming project (as opposed to running it directly from within this repo, which is how it was tested for 0.1.0-beta.2). Switched toIsolate.resolvePackageUri, which goes through the actualpackage_config.jsonresolution and works regardless of pub-cache vs. path dependency vs. snapshot caching.
0.1.0-beta.2 - 2026-07-01 #
Added #
bin/build_native.dart—dart run dart_bclibc:build_nativebuilds the standalonelibbclibc_ffishared library intobuild/bclibc/, for consumers runningflutter test/dart test, which never trigger the platform build that bundles the library automatically
Changed #
Makefile'sbuildtarget now delegates tobin/build_native.dartinstead of duplicating the CMake invocation- CI (
test-submodule,test-macos) builds the native library viadart run bin/build_native.dartinstead of raw CMake commands; dropped the now-unusedninja-buildsystem dependency fromtest-submodule
0.1.0-beta.1 - 2026-07-01 #
First public release as a standalone package.
Added #
BcLibC— main entry point; open withBcLibC.open()BcLibC.integrateShot— full trajectory integrationBcLibC.integrateAtShot— trajectory integration to a specific intercept keyBcLibC.findZeroAngleShot— barrel elevation for a given zero distanceBcLibC.findApexShot— apex point of a ballistic arcBcLibC.findMaxRangeShot— maximum range and angleBcLibC.calculateEnergy,calculateOgw,getCorrection— utility functionsBcShot— user-facing shot descriptor in natural units; all physics conversion (atmosphere density, Coriolis trig, PCHIP drag curve, cant sin/cos) delegated to C++ viaBCLIBCFFI_Shot::to_shot_props()BcTrajectoryRequest,BcTrajectoryData,BcBaseTrajData,BcHitResult,BcInterception,BcMaxRangeResult— result typesBcException— structured error with per-error-code extras (requestedDistanceFt,zeroFindingError, etc.)BcConfig— solver tuning parameters (step multiplier, accuracy, limits)BcWind,BcDragPoint— wind and drag table entry value types- Unit system (
lib/unit.dart):Distance,Velocity,Temperature,Pressure,Angular,Weight,Energywithin_()/toDouble()API - Smoke-test suite (
test/ffi_test.dart,test/unit_test.dart) Makefilewithbuild,ffigen,test,cleantargets- CI workflow (
.github/workflows/ci.yml): analyze, submodule build, FetchContent build, macOS build, pub.dev dry-run jobs
Notes #
- Platforms: Linux, Windows, Android (arm64-v8a, x86_64), iOS, macOS
- Native library:
libbclibc_ffi.so/bclibc_ffi.dll/libbclibc_ffi.dylib— compiled frombclibc/(v1.1.5, LGPL-3.0) - CMake build strategy (Linux/Windows/Android):
- submodule present →
add_subdirectory(pub.dev; rungit submodule update --initbefore publishing) - pre-installed library found → use it (Flatpak
/app/lib) - fallback →
FetchContentfrom GitHub (git dep viadart pub get)
- submodule present →