Skip to content

Commit abe2739

Browse files
committed
* set-force directive
1 parent 3227818 commit abe2739

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ set {
523523
The `set` rule assigns a value to a variable in the build script.
524524

525525
```cfg
526-
set {
526+
set | set-force {
527527
| NAME
528528
| _
529529
| parent { NAME }
@@ -581,6 +581,19 @@ set {
581581
}
582582
```
583583

584+
## set-force
585+
586+
Please note that the `set` directive assigns a variable under the given name during the init `build` phase.
587+
If you use multiple set expressions for the same variable name, only the last one will take effect.
588+
This happens because set expression values are evaluated during the `init` phase, while the `build` and `setup` phases
589+
are executed afterward - using the values cached from `init`.
590+
591+
This behavior often causes confusion in `macros` that are invoked multiple times and contain
592+
`set` directives in their bodies.
593+
594+
To ensure the variable is correctly updated across all build and setup phases, use `set-force`.
595+
Unlike set, it is executed for every phase and does not cache its results.
596+
584597
# env {...}
585598

586599
Similar to `set`, but sets an **environment variable** for the build process

dist/docs/index.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ <h1 id="set-">set {...}</h1>
773773
<p>The <code>set</code> rule assigns a value to a variable in the build
774774
script.</p>
775775
<div class="sourceCode" id="cb17"><pre
776-
class="sourceCode cfg"><code class="sourceCode ini"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="dt">set {</span></span>
776+
class="sourceCode cfg"><code class="sourceCode ini"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="dt">set | set-force {</span></span>
777777
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a><span class="dt"> | NAME</span></span>
778778
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a><span class="dt"> | _</span></span>
779779
<span id="cb17-4"><a href="#cb17-4" aria-hidden="true" tabindex="-1"></a><span class="dt"> | parent { NAME }</span></span>
@@ -823,6 +823,20 @@ <h1 id="set-">set {...}</h1>
823823
<span id="cb20-4"><a href="#cb20-4" aria-hidden="true" tabindex="-1"></a><span class="dt"> }</span></span>
824824
<span id="cb20-5"><a href="#cb20-5" aria-hidden="true" tabindex="-1"></a><span class="dt"> ... # values</span></span>
825825
<span id="cb20-6"><a href="#cb20-6" aria-hidden="true" tabindex="-1"></a><span class="dt">}</span></span></code></pre></div>
826+
<h2 id="set-force">set-force</h2>
827+
<p>Please note that the <code>set</code> directive assigns a variable
828+
under the given name during the init <code>build</code> phase. If you
829+
use multiple set expressions for the same variable name, only the last
830+
one will take effect. This happens because set expression values are
831+
evaluated during the <code>init</code> phase, while the
832+
<code>build</code> and <code>setup</code> phases are executed afterward
833+
- using the values cached from <code>init</code>.</p>
834+
<p>This behavior often causes confusion in <code>macros</code> that are
835+
invoked multiple times and contain <code>set</code> directives in their
836+
bodies.</p>
837+
<p>To ensure the variable is correctly updated across all build and
838+
setup phases, use <code>set-force</code>. Unlike set, it is executed for
839+
every phase and does not cache its results.</p>
826840
<h1 id="env-">env {...}</h1>
827841
<p>Similar to <code>set</code>, but sets an <strong>environment
828842
variable</strong> for the build process using <code>setenv(3)</code> at

0 commit comments

Comments
 (0)