diff --git a/lib/src/cross/cross_keys.dart b/lib/src/cross/cross_keys.dart index a403204..0268c1b 100644 --- a/lib/src/cross/cross_keys.dart +++ b/lib/src/cross/cross_keys.dart @@ -54,8 +54,13 @@ List _sysrootParts(CrossTarget t) => [ /// rpi4 vs rpi5 on the same raspios image) share a single extraction. String sysrootKey(CrossTarget t) => contentHash([ ..._sysrootParts(t), + // Only augments that will actually be staged count toward the key: a + // `requires_define`-gated augment whose gate isn't satisfied (e.g. an + // off-by-default crash handler) is not built, so it must not perturb the + // sysroot identity or invalidate the shared store entry. for (final a in t.augment) - 'aug:${a.pkg}:${a.minVersion}:${a.url}:${a.build.name}:${a.staticLink}', + if (CrossTarget.defineSatisfied(a.requiresDefine, t.defines)) + 'aug:${a.pkg}:${a.minVersion}:${a.url}:${a.build.name}:${a.staticLink}', ]); /// Hash of the **shared sysroot base**: [sysrootKey] without the augment set, diff --git a/test/src/cross/cross_keys_test.dart b/test/src/cross/cross_keys_test.dart index 0854f7e..d2b2ae4 100644 --- a/test/src/cross/cross_keys_test.dart +++ b/test/src/cross/cross_keys_test.dart @@ -87,6 +87,35 @@ void main() { expect(sysrootBaseKey(rpi5), matches(RegExp(r'^[0-9a-f]{12}$'))); }); + test('a requires_define-gated augment counts only when its gate is on', () { + const sentry = { + 'pkg': 'sentry-native', + 'min': '0.15.3', + 'url': 'https://x/sentry.zip', + 'build': 'cmake', + 'requires_define': 'BUILD_CRASH_HANDLER', + }; + // Gate unsatisfied (no define) → not staged → key unchanged. + final gatedOff = _t(const { + 'provider': 'arm-gnu', + 'toolchain_version': '12.3.rel1', + 'image_url': 'https://example/raspios.img.xz', + 'cpu_flags': ['-mcpu=cortex-a76'], + 'augment': [sentry], + }); + expect(sysrootKey(gatedOff), sysrootKey(rpi5)); + // Gate satisfied → staged → key changes. + final gatedOn = _t(const { + 'provider': 'arm-gnu', + 'toolchain_version': '12.3.rel1', + 'image_url': 'https://example/raspios.img.xz', + 'cpu_flags': ['-mcpu=cortex-a76'], + 'defines': {'BUILD_CRASH_HANDLER': 'ON'}, + 'augment': [sentry], + }); + expect(sysrootKey(gatedOn), isNot(sysrootKey(rpi5))); + }); + test('modules change the buildKey but not the sysroot keys', () { final withModule = _t(const { 'provider': 'arm-gnu',