You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add environment variable support to layer dependency processing.
This means:
Supporting ${VAR} syntax in X-Env-Layer-Requires
Evaluating environment variables during layer discovery
This is a trivial addition but a powerful feature.
Update test harness and documentation.
Fix hangover field name typo in docs, and regenerate.
This feature enables dynamic layer selection. For example, one usage could be to use the same layer across different build environments to support toolchain selection based on target architecture. By using variables in the 'parent' layer, dynamic dependency resolution pulls in an architecture specific toolchain 'child' layer.
265
+
266
+
[NOTE]
267
+
====
268
+
Layer discovery will fail if variables referenced in dependencies are not set in the environment.
269
+
====
270
+
271
+
[IMPORTANT]
272
+
====
273
+
Environment variable dependencies are evaluated during layer discovery, not during layer variable expansion. This ensures dependencies are resolved before layer processing begins. Because of this, only variables *already present* in the environment can be used in layer dependencies.
274
+
275
+
For example:
276
+
277
+
- System or custom environment variables (e.g., `USER`, `ARCH`, `DISTRO`)
278
+
- Configuration file variables or command line overrides
279
+
280
+
All dependencies are always included, i.e. variable names result in actual layer names at build-time. For example, `${ARCH}-toolchain` always results in a dependency, but the specific layer name depends on the `ARCH` environment variable value.
281
+
====
282
+
240
283
=== Expansion Context
241
284
242
285
During configuration processing, variables are expanded using:
<p>This feature enables dynamic layer selection. For example, one usage could be to use the same layer across different build environments to support toolchain selection based on target architecture. By using variables in the 'parent' layer, dynamic dependency resolution pulls in an architecture specific toolchain 'child' layer.</p>
579
+
</div>
580
+
<divclass="admonitionblock note">
581
+
<table>
582
+
<tr>
583
+
<tdclass="icon">
584
+
<divclass="title">Note</div>
585
+
</td>
586
+
<tdclass="content">
587
+
<divclass="paragraph">
588
+
<p>Layer discovery will fail if variables referenced in dependencies are not set in the environment.</p>
589
+
</div>
590
+
</td>
591
+
</tr>
592
+
</table>
593
+
</div>
594
+
<divclass="admonitionblock important">
595
+
<table>
596
+
<tr>
597
+
<tdclass="icon">
598
+
<divclass="title">Important</div>
599
+
</td>
600
+
<tdclass="content">
601
+
<divclass="paragraph">
602
+
<p>Environment variable dependencies are evaluated during layer discovery, not during layer variable expansion. This ensures dependencies are resolved before layer processing begins. Because of this, only variables <strong>already present</strong> in the environment can be used in layer dependencies.</p>
603
+
</div>
604
+
<divclass="paragraph">
605
+
<p>For example:</p>
606
+
</div>
607
+
<divclass="ulist">
608
+
<ul>
609
+
<li>
610
+
<p>System or custom environment variables (e.g., <code>USER</code>, <code>ARCH</code>, <code>DISTRO</code>)</p>
611
+
</li>
612
+
<li>
613
+
<p>Configuration file variables or command line overrides</p>
614
+
</li>
615
+
</ul>
616
+
</div>
617
+
<divclass="paragraph">
618
+
<p>All dependencies are always included, i.e. variable names result in actual layer names at build-time. For example, <code>${ARCH}-toolchain</code> always results in a dependency, but the specific layer name depends on the <code>ARCH</code> environment variable value.</p>
Environment variables in dependencies are evaluated during layer discovery using the current environment context. If a required environment variable is not set, layer discovery will fail.
105
+
106
+
This enables dynamic layer dependency resolution based on build-time variables such as:
107
+
108
+
- **Architecture**: `${ARCH}-toolchain` resolves to `arm64-toolchain` when `ARCH=arm64`
109
+
- **Distribution**: `${DISTRO}-packages` resolves to `debian-packages` when `DISTRO=debian`
110
+
- **Build variant**: `${VARIANT}-config` for different build configurations
111
+
112
+
[IMPORTANT]
113
+
====
114
+
Only variables present in the environment can be used in dependencies.
<h3id="_dependencies_and_providers"><aclass="anchor" href="#_dependencies_and_providers"></a><aclass="link" href="#_dependencies_and_providers">Dependencies and Providers</a></h3>
<p><strong>Concrete dependencies</strong>: Must reference actual layer names</p>
344
344
</li>
345
345
<li>
346
+
<p><strong>Environment variable expansion</strong>: Supports <code>${VAR}</code> syntax for dynamic dependencies</p>
347
+
</li>
348
+
<li>
346
349
<p><strong>Build order enforcement</strong>: Dependencies are loaded first and are pull in automatically</p>
347
350
</li>
348
351
<li>
349
352
<p><strong>Example</strong>: A device layer depends on a device base-layer because the base-layer provides mandatory settings inherited by the device layer.</p>
<p>Environment variables in dependencies are evaluated during layer discovery using the current environment context. If a required environment variable is not set, layer discovery will fail.</p>
366
+
</div>
367
+
<divclass="paragraph">
368
+
<p>This enables dynamic layer dependency resolution based on build-time variables such as:</p>
369
+
</div>
370
+
<divclass="ulist">
371
+
<ul>
372
+
<li>
373
+
<p><strong>Architecture</strong>: <code>${ARCH}-toolchain</code> resolves to <code>arm64-toolchain</code> when <code>ARCH=arm64</code></p>
374
+
</li>
375
+
<li>
376
+
<p><strong>Distribution</strong>: <code>${DISTRO}-packages</code> resolves to <code>debian-packages</code> when <code>DISTRO=debian</code></p>
377
+
</li>
378
+
<li>
379
+
<p><strong>Build variant</strong>: <code>${VARIANT}-config</code> for different build configurations</p>
380
+
</li>
381
+
</ul>
382
+
</div>
383
+
<divclass="admonitionblock important">
384
+
<table>
385
+
<tr>
386
+
<tdclass="icon">
387
+
<divclass="title">Important</div>
388
+
</td>
389
+
<tdclass="content">
390
+
<divclass="paragraph">
391
+
<p>Only variables present in the environment can be used in dependencies.</p>
0 commit comments