bclibc 2.1.0
bclibc: ^2.1.0 copied to clipboard
Ballistic calculator for Dart, Flutter and the web: the bclibc engine as native code (build hook) or wasm.
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 #
2.1.0 - 2026-11-19 #
The C ABI of bclibc 2.2 (pin below), and what it makes possible: typed errors, and dense output from the engine up to
Calculator / AsyncCalculator, on the native and the web backend.
Added #
-
Dense output, on the native and the web backend:
BcEngine.integrateDenseShotreturns the filtered rows and the accepted steps of the integrator (BcDenseResult, withBcStepStatsfor the adaptive methods, which takerelativeToleranceandabsoluteTolerance), for every integration method;denseGetAt,denseGetAtSlantHeightandtrajectoryDataFromStepwork on those steps (the interpolation is the library's). The py-ballisticcalc driver (python/) supportsdense_outputwith it. -
BcException.kind(BcErrorKind) and the fields of the kinds bclibc 2.2 tells apart:outOfBounds(requestedValue,minimumValue,maximumValue) anddomain(lhs,rhs), next tooutOfRangeandzeroFinding. The native and the web backend build the exception in one place (BcException.fromStatus). The bridge of the py-ballisticcalc driver reports the kinds, and the driver raises what the Cython layer does for them (ValueError,IndexError,RuntimeError). -
Calculator.fire/AsyncCalculator.firetakedenseOutput(andrelativeTolerance/absoluteTolerancefor the adaptive methods): theHitResultthen carries the integrator steps (HitResult.denseSteps).Calculator.getAtandgetAtDistance(and the async ones) interpolate in them, by the library, and turn the step into a full record; without dense outputgetAtDistanceinterpolates between the rows (three-point PCHIP through the rows around the distance,BcEngine.interpolateTrajectoryData) instead of returning the nearest row, whichHitResult.getAtDistancestill does.
Changed #
- Pin
bclibctov2.2.0(bclibc #51): the C ABI tells the kinds of error apart (BCLIBCFFI_ERR_DOMAIN,_INVALID_ARGUMENT,_OUT_OF_BOUNDS,_LOGIC,_RUNTIME; they were all_GENERIC), and has a growable trajectory buffer and the interpolation over points (BCLIBCFFI_BaseTrajBuf,BCLIBCFFI_base_traj_*). The embedded wasm module is rebuilt from it and the FFI bindings are regenerated (additive: nothing in the package calls the new functions yet). - The web layer:
BCLIBCFFI_get_layoutreturns 100 values (was 96:BCLIBCFFI_BaseTrajBufis appended), andBcLibCWeb.openchecks the exact count.
2.0.1 - 2026-11-18 #
Changed #
- Pin
bclibctov2.1.0: the zero search no longer depends on the early-termination limits (cMaximumDrop,cMinimumAltitude), so a zero with either at0, or a long one (3500 yd and more) at the default limits, no longer fails with "Trajectory too short to determine error at distance"; a zero beyond the maximum range is an out-of-range error (it was a plain solver-runtime error). The embedded wasm module is rebuilt from it. - CI: the Flatpak example build uses Flutter 3.50.0 (was 3.47.8) and flutpak actions v0.8.7 (was v0.8.6).
2.0.0 - 2026-10-29 #
Release candidate: no code changes since 2.0.0-rc.1; see its entry below for what 2.0.0 contains beyond 2.0.0-rc.1.
2.0.0-rc.1 - 2026-10-28 #
Release candidate: no code changes since 2.0.0-beta.1; see its entry below for what 2.0.0 contains beyond 2.0.0-alpha.1.
2.0.0-beta.1 - 2026-10-27 #
Fixed #
- Android:
libbclibc_ffi.socould not be loaded on a device, so 2.0.0-alpha.1 does not work on Android. The hook linked libc++ dynamically (thenative_toolchain_cdefault,c++_shared), but nothing putslibc++_shared.sointo the APK: the build succeeded anddlopenfailed at run time withlibrary "libc++_shared.so" not found. libc++ is now linked statically (c++_static), together with libm (with a static libc++ nothing else pulls it in, andpowstayed unresolved), and the hook fails the build if the Android binary still referenceslibc++_shared.so. CI now loads the library on an Android emulator, which is how this was found. BcLibC.open()no longer succeeds with an unusable library. With the@Nativebindings of 2.0.0-alpha.1 the library is resolved lazily, soopen()just created an object and a missing or unloadablelibbclibc_ffionly failed later, at the first calculation, as anArgumentError("Couldn't resolve native function ...") -- which defeated startup checks such astry { BcLibC.open(); } catch (...) { exit(1); }. It now callsBCLIBCFFI_get_version()right away and throws aStateErrorthat names the library.
Added #
- The build hook checks the library it just built, so a bad build fails the build instead of the app at startup:
the file must exist, contain every
BCLIBCFFI_*function the bindings call (catches a missing export, e.g. a symbol dropped by the Linux version script or not exported from the Windows DLL), and, when the target is the machine doing the build, actually load and answerBCLIBCFFI_get_version(). On that machine every symbol is looked up in the loaded library exactly as the runtime will do it; for cross-compiled targets (Android, iOS) the names are searched for in the binary, which is a weaker check. - Android: the library is linked with
-Wl,-z,max-page-size=16384(16 KB page alignment, required by Google Play for 64-bit libraries), and CI checks everyLOADsegment of the arm64-v8a and x86_64 libraries in the APK. test/hook_test.dartruns the hook throughtestCodeBuildHook(package:code_assets): it must emit exactly one bundled code asset,package:bclibc/ffi/bclibc_bindings.g.dart, whose file name matches the target OS (libbclibc_ffi.so/.dylib,bclibc_ffi.dll).- Stricter CI: the built example is run on Linux, Windows and macOS (it must load the engine and solve a shot, and
must fail fast once the library is removed from the bundle),
scripts/ci/missing-library-check.shdoes the same for a plain Dart executable, an Android emulator job loads the library on a device and an iOS job builds the example for a device (arm64) and runs it on a simulator (example/integration_test). The Android job also checks that the library needs nolibc++_shared.so. - The Flatpak workflow has a
bclibc_versioninput: with a published version it builds the example against that release from pub.dev instead of the path dependency, which proves the offline build works from the package archive alone.
Changed #
- CI: a new push to a pull request cancels the run still going for its previous commit (runs on
mainand manual runs are never cancelled,release.ymlneeds them); the self-test inscripts/ci/flutter-smoke.shhas its own 120 s limit (macOS has notimeout) and prints the app's output when it fails; the Flutter jobs have a time limit.
2.0.0-alpha.1 - 2026-10-27 #
This release merges bclibc_flutter into bclibc: one package now works on the Dart VM, in Flutter
(Android/iOS/Linux/macOS/Windows) and on the web (Dart web and Flutter web), with a single bclibc pin.
Migrating from bclibc_flutter: depend on bclibc: ^2.0.0-alpha.1 instead and replace
package:bclibc_flutter/... imports with package:bclibc/... (bclibc.dart and unit.dart are unchanged).
No platform setup is needed: the native library is built by the package itself.
Changed #
- BREAKING: the native library is built by a build hook (
hook/build.dart,package:hooks+native_toolchain_c) from the bundledbclibc/sources and loaded as a code asset. The FFI bindings (lib/ffi/bclibc_bindings.g.dart) are regenerated in@Nativemode (ffi-nativeinffigen.yaml), sodart run,dart test,flutter run,flutter buildandflutter testresolve the library the same way, with no build step, no network access and nopackage_config.jsonlookup. Requires Dart 3.11+ and a C++ toolchain on the build machine. - BREAKING:
BcLibCFFIBindings(a class wrapping aDynamicLibrary) is gone; the bindings are top-level@Nativefunctions.BcLibC.open()is unchanged. AsyncCalculator(frombclibc_flutter) and the web binding (BcLibCWeb) now live in this package, selected bydart.library.js_interopinbclibc.dart.BcLibCWeb.open()uses the wasm module embedded in the package by default;wasmUrlis only for a differently-built or differently-hosted module.- The wasm module is embedded as a base64 constant (
lib/ffi/bclibc_wasm.g.dart, written byscripts/embed_wasm.pyfrommake build-wasm) instead of a Flutter asset, so it needs no asset bundling or hosting and works the same in Dart web, Flutter web anddart test -p chrome. - Repository layout: the package lives at the repository root (it was in
dart/) and the bclibc submodule isbclibc/(it wasdart/bclibc). A.pubignorekeeps.github/,scripts/,Makefileand the submodule's tests out of the pub.dev archive. - Dependencies:
hooks,code_assets,native_toolchain_candwebadded,pathdropped (it only served the removed library loader). - CI and release: every CI job now runs on the single package (
Analyze,Test,Test / web (Chrome),Test / Flutter consumer (Linux),pub.dev dry-run). Tests are no longer re-run for a release tag:release.ymlrequires a successfulci.ymlrun on the tagged commit instead (ci.ymlcan be started manually withworkflow_dispatch), checkspubspec.yamland this changelog, and publishes onlybclibc.scripts/ci/prepare_release.pyandmake verify-bclibcfollow the new layout.
Added #
- Web support in this package:
BcLibCWeband a webAsyncCalculator, no Flutter SDK required. scripts/ci/flutter-smoke.shand a CI job that runflutter testin a throwaway Flutter project depending on this package.make web-test(web tests in Chrome) andmake submodule.
Removed #
- BREAKING:
dart run bclibc:build_native(bin/build_native.dart) and theBCLIBC_FFI_PATHenvironment variable: the build hook replaces them. - The
bclibc_flutterpackage and its platform plugin code (CMake/Gradle/podspec): it is no longer built or released from this repository (the last published version is 1.0.1). - The
flutter/bclibcsubmodule andsync-bclibc:bclibc/is the single bclibc pin (make verify-bclibcnow checks that pin, the embedded wasm module and this changelog).
1.0.1 - 2026-10-27 #
Fixed #
- The native library is found under
flutter teston Flutter 3.47+: thereIsolate.resolvePackageUriSyncthrowsUnsupportedError, so the library placed bydart run bclibc:build_nativewas unreachable. As a last resort the loader now reads.dart_tool/package_config.jsondirectly (local files only, no network). It runs after the executable-relative lookup, so compiled and bundled builds are unchanged.
1.0.0 - 2026-10-03 #
Stable release, covering the whole arc from 0.2.3 through 1.0.0-rc.5. Highlights below; full details are in the beta/rc entries beneath this one.
Changed #
HitResultnow separates exact chronologicalrecords, physicalevents, and stable scheduledsamples.trajectoryremains as a deprecated alias forrecords.- The native library is built from bclibc's exception-free core (every fallible call returns a result that the
flat C ABI maps to a
BCLIBCFFI_*error code): same Dart API, error codes and messages. - Regenerated
lib/ffi/bclibc_bindings.g.dart(make ffigen) for the interpolation functions of the C ABI,BCLIBCFFI_hermite,BCLIBCFFI_interpolate_2pt/_3ptandBCLIBCFFI_interpolate_trajectory_data.
Added #
BcIntegrationMethod.cashKarp/.dormandPrince/.tsitouras: three adaptive RK45 integration methods, alongside the existing RK4.Calculator.aimingSolutionForTarget()returns vertical hold, windage, and the target-range trajectory point from the native zero-point solve.
Chores #
- Pin
bclibctov2.0.0
1.0.0-rc.5 - 2026-10-01 #
Changed #
- The native library is built from bclibc's exception-free core (every fallible call returns a result that the flat C
ABI maps to a
BCLIBCFFI_*error code): same Dart API, error codes and messages. - Regenerated
lib/ffi/bclibc_bindings.g.dart(make ffigen): it now also binds the interpolation functions of the C ABI,BCLIBCFFI_hermite,BCLIBCFFI_interpolate_2pt/_3ptandBCLIBCFFI_interpolate_trajectory_data.
Chores #
- Pin
bclibctov2.0.0-rc.4
1.0.0-rc.1 - 2026-09-22 #
Changed #
- Pin
bclibctov2.0.0-rc.1— replaces the embedded RK45 methods' thread-local tolerance/stats API (shared by every engine on a thread using the same method) with statefulBCLIBC_CashKarpIntegrator/BCLIBC_DormandPrinceIntegrator/BCLIBC_TsitourasIntegratorclasses. Internal to bclibc; no change to the Dart FFI surface, which only ever calls the plainBCLIBCFFI_integrate*functions, unaffected by this.
1.0.0-beta.2 - 2026-09-21 #
1.0.0-beta.1 - 2026-09-17 #
Changed #
- Pin
bclibctov2.0.0-beta.7, adding experimental Cash-Karp and Dormand-Prince integration methods and the zero-point FFI result API. HitResultnow separates exact chronologicalrecords, physicalevents, and stable scheduledsamples.trajectoryremains as a deprecated alias forrecords.
Added #
Calculator.aimingSolutionForTarget()returns vertical hold, windage, and the target-range trajectory point from the native zero-point solve.
0.2.3 - 2026-09-15 #
Changed #
- Breaking: package renamed from
dart_bclibctobclibc. Update yourpubspec.yamldependency and everypackage:dart_bclibc/...import topackage:bclibc/....
Migration #
dependencies: { dart_bclibc: ^0.2.2 }→dependencies: { bclibc: ^0.2.3 }import 'package:dart_bclibc/bclibc.dart';→import 'package:bclibc/bclibc.dart';(and likewise for every otherpackage:dart_bclibc/...import).
0.2.2 - 2026-09-15 #
Fixed #
Distance.centimeter()constructed aDistancewithUnit.inchinstead ofUnit.centimeter, silently misinterpreting the given value as inches.
0.2.0-beta.1 - 2026-07-22 #
Changed #
- Breaking: split the package.
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 newbclibc_flutterpackage.bclibcitself now only exposes the synchronousCalculator/BcLibC(native FFI); wrapCalculatorin your ownIsolate.runfor off-isolate execution in a plain Dart project. dart run 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
bclibc_flutterinstead ofbclibcdirectly (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: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 viabclibc_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 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 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 →