@@ -106,6 +106,53 @@ n=$(grep -o '\-DPROBE_ONCE=1' once/compile_commands.json | wc -l | tr -d ' ')
106106 exit 1; }
107107echo " ok a predicate naming both a triple key and a layer applies exactly once"
108108
109+ # ── (2b) …and it reaches a DEPENDENCY, which is the motivating case ─────────
110+ #
111+ # ⚠️ EVERY LEG ABOVE IS SATISFIED BY A PASS THAT ONLY PATCHES packages[0].
112+ # docs/14 writes this feature for "a package supplying a layer [that] frequently
113+ # supports several implementations of the layer beneath it" — a LIBRARY, reached
114+ # as someone's dependency. The build.mcpp tail that shares this pass's window
115+ # patches the root alone, correctly for its own purpose, so copying that shape
116+ # would have left the one package this feature exists for unserved and every
117+ # root-only assertion still green.
118+ mkdir -p dep/app/src dep/lib/src
119+ cat > dep/lib/mcpp.toml << EOF
120+ [package]
121+ name = "layerlib"
122+ version = "0.1.0"
123+
124+ [target.'cfg(c-abi = "$CABI ")'.build]
125+ defines = ["LIB_MATCHED=1"]
126+
127+ [target.'cfg(c-abi = "$NOTCABI ")'.build]
128+ defines = ["LIB_MUST_NOT_APPLY=1"]
129+ EOF
130+ cat > dep/lib/src/layerlib.cppm << 'EOF '
131+ export module layerlib;
132+ #ifndef LIB_MATCHED
133+ #error "a DEPENDENCY's matching cfg(c-abi = ...) section did not apply"
134+ #endif
135+ #ifdef LIB_MUST_NOT_APPLY
136+ #error "a DEPENDENCY's non-matching cfg(c-abi = ...) section applied"
137+ #endif
138+ export int lib_answer() { return 42; }
139+ EOF
140+ cat > dep/app/mcpp.toml << 'EOF '
141+ [package]
142+ name = "app"
143+ version = "0.1.0"
144+
145+ [dependencies]
146+ layerlib = { path = "../lib" }
147+ EOF
148+ cat > dep/app/src/main.cpp << 'EOF '
149+ import layerlib;
150+ int main() { return lib_answer() == 42 ? 0 : 1; }
151+ EOF
152+ ( cd dep/app && " $MCPP " build > b.log 2>&1 ) || {
153+ cat dep/app/b.log; echo " FAIL: layer predicates did not reach a dependency" ; exit 1; }
154+ echo " ok a layer predicate reaches a dependency, and its negative leg holds"
155+
109156# ── (3) an unknown key is reported, and --strict makes it an error ──────────
110157mkdir -p unknown/src
111158cat > unknown/mcpp.toml << 'EOF '
0 commit comments