feat: always process the project's grammar
Metadata
Current evaluation
Merged PR #279 (commit 3432cf7d), which always processes grammar and selects the first build-plan architecture or the host architecture when build-for is unspecified.
Resolution: closed resolved
Reason: PR #279 was approved and merged. Commit 3432cf7d added architecture fallbacks so clean can resolve conditional part sources without an explicit target architecture.
Evaluated by: mr-cal-bot
No scores available.
Issue body
The problem this commit addresses is this: Consider the following snippet:
```
parts:
hello-world:
plugin: dump
source:
- on amd64 to arm64: src/on-amd64-to-arm64
- on amd64 to armhf: src/on-amd64-to-armhf
```
... what should happen if the command `toolname clean --destructive-mode` is executed? Currently it breaks, because the grammar is not processed without an explict target arch (provided directly through the "--build-for" parameter or indirectly via the "--platform" one). This is at least inconvenient, and goes against the guideline we adopted for cleaning projects with multiple infos on the build-plan (accept the "wrong" config and remove the files).
There is no obvious, perfect answer here because at the stage that the grammar is currently processed we don't know yet what kind of command we are dealing with. Maybe the command needs the parts, maybe it doesn't. Possibly as a stop gap,
this commit introduces the following logic:
- If build-for is provided, use that (current behavior);
- If the build plan has items, use the build-for of the first one arbitrarily, just to be able to resolve and remove the grammar statements;
- Otherwise, use the host arch as build-for.
This last option is risky because there's a chance it won't generate a valid parts declaration (see the new tests). That's not as bad as it looks, because either the command won't need the parts (and thus that declaration will be ignored), or it will and the lifecycle service will then generate its own error.
- [ ] Have you followed the guidelines for contributing?
- [ ] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [ ] Have you successfully run `tox`?
-----
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #279 (commit 3432cf7d), which always processes grammar and selects the first build-plan architecture or the host architecture when build-for is unspecified. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged grammar-processing fix: without an explicit build-for, the first build-plan architecture or host architecture is used, allowing clean to handle multi-architecture projects. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged a fix for destructive-mode clean failures when no target arch is specified. Implements fallback logic to always process project grammar using the provided arch, first plan item, or host arch. Approved and passed CI. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #150 feat: evaluate project using grammar rules | craft-application | merged | Merged two-stage project grammar evaluation: first for build-plan discovery, then for the resolved build-on/build-for architectures (craft-application#150, f51c0e3b). |